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 ArcGIS basemap layers is based on the Mapbox vector tile specification. To access vector basemap layers, you use the ol-mapbox-style library.

  1. Reference the OpenLayers CSS, JS, and ol-mapbox-style libraries.
  2. Select a basemap style enumeration.
  3. Set the style URL and your API key.
  4. Load and apply the basemap style to a map using olms.

Example

Display a basemap layer

This example loads and displays the ArcGIS:Streets vector tile style in the map. To see all of the basemap 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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.15.1/css/ol.css" type="text/css" />
    <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.15.1/build/ol.js"></script>

    <script src="https://cdn.jsdelivr.net/npm/ol-mapbox-style@6.1.4/dist/olms.js"></script>

    <script>

      const map = new ol.Map({ target: "map" });

      map.setView(
        new ol.View({
          center: ol.proj.fromLonLat([-118.805, 34.027]),
          zoom: 12
        })
      );

      const apiKey = "YOUR_API_KEY";

      const basemapId = "ArcGIS:Streets";

      const basemapURL = "https://basemaps-api.arcgis.com/arcgis/rest/services/styles/" + basemapId + "?type=style&token=" + apiKey;

      olms(map, basemapURL);

    </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.