Skip to content

Commit

Permalink
Update the "Gallery" example to use v2 basemaps (#209)
Browse files Browse the repository at this point in the history
* fix: key can't be null

* chore: change to use v2 styles
  • Loading branch information
BrunoCaimar authored Oct 26, 2023
1 parent 869c253 commit f4ebd35
Showing 1 changed file with 24 additions and 57 deletions.
81 changes: 24 additions & 57 deletions examples/gallery-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,71 +49,38 @@
var map = L.map("map", {}).setView([34.0522, -118.2437], 15);

var vectorTiles = {};
var allEnums = [
"ArcGIS:Imagery",
"ArcGIS:Imagery:Standard",
"ArcGIS:Imagery:Labels",
"ArcGIS:LightGray",
"ArcGIS:LightGray:Base",
"ArcGIS:LightGray:Labels",
"ArcGIS:DarkGray",
"ArcGIS:DarkGray:Base",
"ArcGIS:DarkGray:Labels",
"ArcGIS:Navigation",
"ArcGIS:NavigationNight",
"ArcGIS:Streets",
"ArcGIS:StreetsNight",
"ArcGIS:StreetsRelief",
"ArcGIS:Topographic",
"ArcGIS:Oceans",
"ArcGIS:Oceans:Base",
"ArcGIS:Oceans:Labels",
"OSM:Standard",
"OSM:StandardRelief",
"OSM:StandardRelief:Base",
"OSM:Streets",
"OSM:StreetsRelief",
"OSM:LightGray",
"OSM:LightGray:Base",
"OSM:LightGray:Labels",
"OSM:DarkGray",
"OSM:DarkGray:Base",
"OSM:DarkGray:Labels",
"ArcGIS:Terrain",
"ArcGIS:Terrain:Base",
"ArcGIS:Terrain:Detail",
"ArcGIS:Community",
"ArcGIS:ChartedTerritory",
"ArcGIS:ColoredPencil",
"ArcGIS:Nova",
"ArcGIS:ModernAntique",
"ArcGIS:Midcentury",
"ArcGIS:Newspaper",
"ArcGIS:Hillshade:Light",
"ArcGIS:Hillshade:Dark",
];

var apiKey = "< YOUR VALID API KEY HERE >";

vectorTiles[
"Default"
] = L.esri.Vector.vectorBasemapLayer(null, {
] = L.esri.Vector.vectorBasemapLayer("", {
apiKey
});
allEnums.forEach((enumString) => {
vectorTiles[
enumString
] = L.esri.Vector.vectorBasemapLayer(enumString, {
apiKey
})
})

var layerControl = L.control
.layers(vectorTiles, null, {
collapsed: false
})
.addTo(map);

L.esri.get('https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/self', {}, function (error, response) {
if (error) {
console.error('Error getting the available styles. See the error details:', error);
return;
}

response.styles.forEach((style) => {
vectorTiles[style.name] = L.esri.Vector.vectorBasemapLayer(
style.path,
{
apiKey
}
);
});

L.control
.layers(vectorTiles, null, {
collapsed: false,
})
.addTo(map);

});

vectorTiles["Default"].addTo(map);
</script>
</body>
Expand Down

0 comments on commit f4ebd35

Please sign in to comment.