Introduction to basemap layers

A map is a container for layers. You use a map together with a map view to display layers of geographic data in 2D. Most applications contain a basemap layer to display geographic data with streets or satellite imagery, and the data is typically provided by the basemap layer service.

You can use the basemap layer service in your application to:

  • Display different types of geographic data of the world for a map.
  • Dsiplay default vector tile basemp styles such as streets navigation, light gray canvas, and OSM.
  • Display custom basemap styles with your own colors, glyphs, and fonts.
  • Display default image tile (raster) basemp layers for satyellite imagery and hillshade.

How to access the basemap layer service

The data format for basemap layers is based on the Mapbox vector tile specification. To access basemap layers, you reference the style URL for the basemap enumeration and set your API key.

Steps

  1. Reference the MapLibre CSS and JS libraries.
  2. Define a basemap style enumeration.
  3. Set the style URL and API key.

Example

This example loads and displays the ArcGIS:Streets vector tile style in the map. To see all of the style enumerations, go to Basemap layer service in the Mapping APIs and location services guide.

Use dark colors for code blocksCopy
               
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<link href="https://unpkg.com/maplibre-gl@2.1.9/dist/maplibre-gl.css" rel="stylesheet" />
<script src="https://unpkg.com/maplibre-gl@2.1.9/dist/maplibre-gl.js"></script>
<script>

  const apiKey = "YOUR_API_KEY";
  const basemapEnum = "ArcGIS:Streets";

  const map = new maplibregl.Map({
    container: "map", // the id of the div element
    style: `https://basemaps-api.arcgis.com/arcgis/rest/services/styles/${basemapEnum}?type=style&token=${apiKey}`,
    zoom: 12, // starting zoom
    center: [-118.805, 34.027] // starting location [longitude, latitude]
  });

</script>

To learn more, see the Display a map and Change the basemap layer tutorials.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.