Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>

<head>
  <title>CMoC Basemap in Leaflet</title>

  <!-- Load Leaflet from CDN -->
  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" crossorigin="" />
  <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js" crossorigin=""></script>
  <!-- Load Esri Leaflet and Esri Leaflet Vector plugins from CDN -->
  <script src="https://unpkg.com/esri-leaflet@3.0.10/dist/esri-leaflet.js"></script>
  <script src="https://unpkg.com/esri-leaflet-vector@4.0.1/dist/esri-leaflet-vector.js"></script>
</head>
  
<body>
<div id="map"></div>

</body>
</html>
              
            
!

CSS

              
                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;
}
              
            
!

JS

              
                // Reference: https://developers.arcgis.com/esri-leaflet/samples/simple-feature-layer/

// An ArcGIS Developer API key is required if you want to use the Basemap styles service
//const apiKey = "YOUR_API_KEY_HERE";

const map = L.map("map", {
  minZoom: 2
}).setView([49.2134, -123.0933], 11);


// https://leafletjs.com/reference.html#map-mappane
map.createPane("world_hillshade");
map.createPane("world_topo");
map.createPane("canada_hillshade");
map.createPane("canada_topo");

// World Hillshade
// https://www.arcgis.com/home/item.html?id=1b243539f4514b6ba35e7d995890db1d
const worldHillshade = L.esri.tiledMapLayer({
  url: "https://services.arcgisonline.com/arcgis/rest/services/Elevation/World_Hillshade/MapServer",
  pane: "world_hillshade"
});

// Canada Hillshade
// https://exchange.maps.arcgis.com/home/item.html?id=558eb0df1e014dc78b2c0fd30f4476b3
const canadaHillshade = L.esri.tiledMapLayer({
  url: 'https://tiles.arcgis.com/tiles/B6yKvIZqzuOr0jBR/arcgis/rest/services/Canada_Hillshade/MapServer',
  pane: "canada_hillshade"
});

// World Topographic Canadian Style
// https://www.arcgis.com/home/item.html?id=6d0ed88458c6429d99331260fb7bf2b0#
const worldTopoCanadaStyle = L.esri.Vector.vectorTileLayer("6d0ed88458c6429d99331260fb7bf2b0", {
  pane: "world_topo"
});

// Canada Topo
// https://exchange.maps.arcgis.com/home/item.html?id=4dd425da08fe4df7afc30112d6e716be
const canadaTopo = L.esri.Vector.vectorTileLayer(
  "https://tiles.arcgis.com/tiles/B6yKvIZqzuOr0jBR/arcgis/rest/services/Canada_Topographic/VectorTileServer", {
    pane: "canada_topo"
  });

// Create layer group using the 4 layers to display as the single Canadian Topographic basemap
const canadian_topo = L.layerGroup([
  canadaTopo,
  worldTopoCanadaStyle,
  canadaHillshade,
  worldHillshade
]).addTo(map);
              
            
!
999px

Console