ArcGIS Maps SDK for JavaScriptSample Code

  • Home
  • Sample Code
  • References
  • Showcase
  • Blogs
Layers / Other tiled layers / WebTileLayer
      • WebTileLayer
      • OpenStreetMapLayer
    • KnowledgeGraphLayer
    • MapNotesLayer

WebTileLayer

This sample shows how to add a WebTileLayer to a Scene.

Tags

3D
WebTileLayer
Scene
viewOnReady
arcgis-compass
arcgis-home
arcgis-navigation-toggle
arcgis-scene
arcgis-zoom
map-components
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>WebTileLayer | Sample | ArcGIS Maps SDK for JavaScript</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.1/"></script>
<style>
html,
body,
#viewDiv {
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<arcgis-scene ground="world-elevation" scale="50000000" center="-65, -17">
<arcgis-home slot="top-left"></arcgis-home>
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle>
<arcgis-compass slot="top-left"></arcgis-compass>
</arcgis-scene>
<script type="module">
const [WebTileLayer] = await $arcgis.import(["@arcgis/core/layers/WebTileLayer.js"]);
const viewElement = document.querySelector("arcgis-scene");
await viewElement.viewOnReady();
const tiledLayer = new WebTileLayer({
urlTemplate: "https://{subDomain}.tile.openstreetmap.org/{z}/{x}/{y}.png",
subDomains: ["a", "b", "c"],
copyright:
'Map data from &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
});
viewElement.map.add(tiledLayer);
</script>
</body>
</html>