-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add worldview and places params (#214)
* add worldview param and places wip * obfuscate apikey * add places param support * Update src/Util.js Co-authored-by: Gavin Rehkemper <[email protected]> * update worldview example * rev fetch method --------- Co-authored-by: Gavin Rehkemper <[email protected]>
- Loading branch information
1 parent
2e47516
commit 299f3f3
Showing
6 changed files
with
204 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> | ||
<title>Esri Leaflet Vector: Display basemap places</title> | ||
|
||
<!-- Load Leaflet from CDN or local node_modules --> | ||
<link rel="stylesheet" href="../node_modules/leaflet/dist/leaflet.css" /> | ||
<script src="../node_modules/leaflet/dist/leaflet.js"></script> | ||
|
||
<!-- | ||
Load maplibre-gl from CDN or local node_modules for dev/debug purposes because it is not bundled in Esri Leaflet Vector's dev/debug code | ||
(note also that loading maplibre-gl.css is not necessary) | ||
--> | ||
<!-- script src="../node_modules/maplibre-gl/dist/maplibre-gl.js"></script --> | ||
<script src=https://unpkg.com/[email protected]/dist/maplibre-gl.js></script> | ||
|
||
<!-- Load Esri Leaflet and Esri Leaflet Vector plugin dev/debug version --> | ||
<script src="../node_modules/esri-leaflet/dist/esri-leaflet.js"></script> | ||
<script src="../dist/esri-leaflet-vector-debug.js"></script> | ||
|
||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
#map { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
right: 0; | ||
left: 0; | ||
font-family: Arial, Helvetica, sans-serif; | ||
font-size: 14px; | ||
color: #323232; | ||
|
||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
<script> | ||
const map = L.map("map", { | ||
minZoom: 2 | ||
}).setView([34.101, -118.339], 17); | ||
const apiKey = "<YOUR ARCGIS API KEY HERE>"; | ||
|
||
const basemapStyle = "arcgis/navigation"; | ||
|
||
const getLayer = places => { | ||
return L.esri.Vector.vectorBasemapLayer(basemapStyle, { | ||
apiKey: apiKey, | ||
version: 2, | ||
places:places | ||
}) | ||
} | ||
|
||
const placeOptions = { | ||
"all":getLayer("all").addTo(map), // Show all places | ||
"attributed":getLayer("attributed"), // Show places with attributes | ||
"none":getLayer("none") // Hide all places | ||
}; | ||
|
||
L.control.layers(placeOptions, null, { collapsed: false }).addTo(map); | ||
|
||
map.on('baselayerchange', e=>{ | ||
console.log(e); | ||
}) | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> | ||
<title>Esri Leaflet Vector: Display basemap places</title> | ||
|
||
<!-- Load Leaflet from CDN or local node_modules --> | ||
<link rel="stylesheet" href="../node_modules/leaflet/dist/leaflet.css" /> | ||
<script src="../node_modules/leaflet/dist/leaflet.js"></script> | ||
|
||
<!-- | ||
Load maplibre-gl from CDN or local node_modules for dev/debug purposes because it is not bundled in Esri Leaflet Vector's dev/debug code | ||
(note also that loading maplibre-gl.css is not necessary) | ||
--> | ||
<script src="../node_modules/maplibre-gl/dist/maplibre-gl.js"></script> | ||
|
||
<!-- Load Esri Leaflet and Esri Leaflet Vector plugin dev/debug version --> | ||
<script src="../node_modules/esri-leaflet/dist/esri-leaflet.js"></script> | ||
<script src="../dist/esri-leaflet-vector-debug.js"></script> | ||
|
||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
#map { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
right: 0; | ||
left: 0; | ||
font-family: Arial, Helvetica, sans-serif; | ||
font-size: 14px; | ||
color: #323232; | ||
|
||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
<script type="module"> | ||
const map = L.map("map", { | ||
minZoom: 2 | ||
}).setView([35.7088, 48.8790], 4); | ||
|
||
const apiKey = "< YOUR ARCGIS API KEY HERE >"; | ||
|
||
const basemapStyle = "arcgis/light-gray"; | ||
|
||
const getLayer = code => { | ||
return L.esri.Vector.vectorBasemapLayer(basemapStyle, { | ||
apiKey: apiKey, | ||
version: 2, | ||
worldview:code | ||
}) | ||
} | ||
|
||
// Retrieve list of supported worldviews from /self url | ||
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); | ||
}) | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters