Skip to content

Commit

Permalink
rev fetch method
Browse files Browse the repository at this point in the history
  • Loading branch information
gowin20 committed Dec 4, 2023
1 parent 6ceeb03 commit b19e2e1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions examples/worldview.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@
}

// Retrieve list of supported worldviews from /self url
const selfUrl = 'https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/self'
const worldviews = (await (await fetch(selfUrl, {method:'GET'})).json()).worldviews;

// Add leaflet control to map
const worldviewOptions = Object.fromEntries(worldviews.map(worldview => [worldview.name,getLayer(worldview.code)]));
L.control.layers(worldviewOptions, null, { collapsed: false }).addTo(map);

L.esri.get('https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/self',{}, (error,response)=>{
// Add leaflet control to map
const worldviewOptions = Object.fromEntries(response.worldviews.map(worldview => [worldview.name,getLayer(worldview.code)]));
L.control.layers(worldviewOptions, null, { collapsed: false }).addTo(map);
})

map.on('baselayerchange', e=>{
console.log(e);
})
Expand Down

0 comments on commit b19e2e1

Please sign in to comment.