Skip to content

Commit 6edb0a0

Browse files
committed
Add Esri imagery basemap sources
1 parent 78ffb54 commit 6edb0a0

File tree

2 files changed

+62
-11
lines changed

2 files changed

+62
-11
lines changed

src/components/changeset/map_options.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ const toggle = (arr, elem) => {
2424

2525
class MapOptions extends React.PureComponent {
2626
layerOptions = [
27-
{ label: 'Bing aerial imagery', value: 'bing' },
27+
{ label: 'Bing Maps Aerial', value: 'bing' },
28+
{ label: 'Esri World Imagery', value: 'esri' },
29+
{ label: 'Esri World Imagery (Clarity) Beta', value: 'esri-clarity' },
2830
{ label: 'OpenStreetMap Carto', value: 'carto' }
2931
];
3032

src/views/map.js

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const BING_AERIAL_IMAGERY_STYLE = {
1515
sources: {
1616
bing: {
1717
type: 'raster',
18+
scheme: 'xyz',
1819
tiles: [
1920
'https://ecn.t0.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=587&mkt=en-gb&n=z',
2021
'https://ecn.t1.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=587&mkt=en-gb&n=z',
@@ -35,6 +36,53 @@ const BING_AERIAL_IMAGERY_STYLE = {
3536
]
3637
};
3738

39+
const ESRI_WORLD_IMAGERY_STYLE = {
40+
version: 8,
41+
sources: {
42+
esri: {
43+
type: 'raster',
44+
scheme: 'xyz',
45+
tiles: [
46+
'https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}?blankTile=false',
47+
'https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}?blankTile=false'
48+
],
49+
tileSize: 256,
50+
maxzoom: 20,
51+
attribution: 'Imagery © Esri'
52+
}
53+
},
54+
layers: [
55+
{
56+
id: 'imagery',
57+
type: 'raster',
58+
source: 'esri'
59+
}
60+
]
61+
};
62+
63+
const ESRI_WORLD_IMAGERY_CLARITY_STYLE = {
64+
version: 8,
65+
sources: {
66+
esri: {
67+
type: 'raster',
68+
scheme: 'xyz',
69+
tiles: [
70+
'https://clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}?blankTile=false'
71+
],
72+
tileSize: 256,
73+
maxzoom: 20,
74+
attribution: 'Imagery © Esri'
75+
}
76+
},
77+
layers: [
78+
{
79+
id: 'imagery',
80+
type: 'raster',
81+
source: 'esri'
82+
}
83+
]
84+
};
85+
3886
const OPENSTREETMAP_CARTO_STYLE = {
3987
version: 8,
4088
sources: {
@@ -61,6 +109,15 @@ const OPENSTREETMAP_CARTO_STYLE = {
61109
]
62110
};
63111

112+
const BASEMAP_STYLES = {
113+
bing: BING_AERIAL_IMAGERY_STYLE,
114+
esri: ESRI_WORLD_IMAGERY_STYLE,
115+
'esri-clarity': ESRI_WORLD_IMAGERY_CLARITY_STYLE,
116+
carto: OPENSTREETMAP_CARTO_STYLE
117+
};
118+
119+
const DEFAULT_BASEMAP_STYLE = BING_AERIAL_IMAGERY_STYLE;
120+
64121
class CMap extends React.PureComponent {
65122
props: {
66123
changesetId: number,
@@ -120,11 +177,7 @@ class CMap extends React.PureComponent {
120177
this.map.remove();
121178
}
122179

123-
let style = BING_AERIAL_IMAGERY_STYLE;
124-
125-
if (this.props.style === 'carto') {
126-
style = OPENSTREETMAP_CARTO_STYLE;
127-
}
180+
let style = BASEMAP_STYLES[this.props.style] ?? DEFAULT_BASEMAP_STYLE;
128181

129182
let map = new maplibre.Map({
130183
container,
@@ -194,11 +247,7 @@ class CMap extends React.PureComponent {
194247
updateMap() {
195248
if (this.state.loading || !this.map || !this.adiffViewer) return;
196249

197-
let style = BING_AERIAL_IMAGERY_STYLE;
198-
199-
if (this.props.style === 'carto') {
200-
style = OPENSTREETMAP_CARTO_STYLE;
201-
}
250+
let style = BASEMAP_STYLES[this.props.style] ?? DEFAULT_BASEMAP_STYLE;
202251

203252
this.map.setStyle(style);
204253

0 commit comments

Comments
 (0)