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 styles service.
You can use the basemap styles service in your application to:
- Display different types of geographic data of the world for a map.
- Display default vector tile basemap styles such as streets navigation, light gray canvas, and OSM.
- Display custom basemap styles with your own colors, glyphs, and fonts.
- Display map tile (raster) basemap layers for satellite imagery and hillshade.
How to access the basemap styles 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
- Reference the MapLibre CSS and JS libraries.
- Define a basemap style enumeration.
- Set the style URL and API key.
Examples
Display a basemap layer
This example loads and displays the arcgis/streets
style from the basemap styles service. To see all of the basemap style enumerations, go to Basemap styles service in the REST API documentation.
<link href="https://unpkg.com/maplibre-gl@4/dist/maplibre-gl.css" rel="stylesheet" />
<script src="https://unpkg.com/maplibre-gl@4/dist/maplibre-gl.js"></script>
<script>
const accessToken = "YOUR_ACCESS_TOKEN";
const basemapEnum = "arcgis/streets";
const map = new maplibregl.Map({
container: "map", // the id of the div element
style: `https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/${basemapEnum}?token=${accessToken}`,
zoom: 12, // starting zoom
center: [-118.805, 34.027] // starting location [longitude, latitude]
});
</script>
Tutorials
Display a map
Create and display a map with the basemap styles service.
Change the basemap style
Switch a basemap style in a map using the basemap styles service.
Change the basemap style
Switch a basemap style in a map using the basemap styles service.
Change the place label language
Switch the language of place labels on a basemap.
Display basemap places
Display places of interest on a basemap and request additional information about them.