Skip to content

Commit

Permalink
layers: Add bing satellite
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz committed Jun 3, 2023
1 parent 6ec16b3 commit 306e6ff
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/components/LayerSwitcher/osmappLayers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export const osmappLayers: Layers = {
Icon: SatelliteIcon,
attribution: ['maptiler'],
},
bingSat: {
name: t('layers.bingSat'),
type: 'basemap',
url: 'https://ecn.{bingSubdomains}.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=13657',
Icon: SatelliteIcon,
attribution: ['bing'],
},
// mtb: {
// name: t('layers.mtb'),
// type: 'basemap',
Expand Down
28 changes: 21 additions & 7 deletions src/components/Map/styles/rasterStyle.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import maplibregl from 'maplibre-gl';
import { GLYPHS, OSMAPP_SOURCES, OSMAPP_SPRITE } from '../consts';

const getSource = (url) => {
if (url.match('{bingSubdomains}')) {
return {
tiles: ['t0', 't1', 't2', 't3'].map((c) =>
url?.replace('{bingSubdomains}', c),
),
};
}

if (url.match('{x}')) {
return {
tiles: ['a', 'b', 'c'].map((c) => url?.replace('{s}', c)),
};
}

return {
url, // url as a tileset.json
};
};

export const rasterStyle = (id, url): maplibregl.Style => {
const source = url.match('{x}')
? {
tiles: ['a', 'b', 'c'].map((c) => url?.replace('{s}', c)),
}
: {
url, // tileset.json
};
const source = getSource(url);
return {
version: 8,
sprite: OSMAPP_SPRITE,
Expand Down

0 comments on commit 306e6ff

Please sign in to comment.