Skip to content

Overview

Map Basics

Use flyTo to smoothly interpolate between locations.

Fly to a location

Use flyTo to smoothly interpolate between locations.

Use the jumpTo function to showcase multiple locations.

Jump to a series of locations

Use the jumpTo function to showcase multiple locations.

Initialize a map with pitch and bearing camera options.

Set pitch and bearing

Initialize a map with pitch and bearing camera options.

Use flyTo with flyOptions to slowly zoom to a location.

Slowly fly to a location

Use flyTo with flyOptions to slowly zoom to a location.

Animate a line by updating a GeoJSON source on each frame.

Animate a line

Animate a line by updating a GeoJSON source on each frame.

Animate the position of a point by updating a GeoJSON source on each frame.

Animate a point

Animate the position of a point by updating a GeoJSON source on each frame.

Use Turf to smoothly animate a point along the distance of a line.

Animate a point along a route

Use Turf to smoothly animate a point along the distance of a line.

Animate the map camera around a point.

Animate map camera around a point

Animate the map camera around a point.

Customize camera animations using AnimationOptions.

Customize camera animations

Customize camera animations using AnimationOptions.

Customize the constrain callback of the map transform. For example, to allow users to underzoom and overpan the bounds.

Customize the map transform constrain

Customize the constrain callback of the map transform. For example, to allow users to underzoom and overpan the bounds.

Click a marker to smoothly enter an immersive 360° photosphere at a fixed point, blended with the live map; exit to return to normal navigation. new

Enter a 360° photosphere

Click a marker to smoothly enter an immersive 360° photosphere at a fixed point, blended with the live map; exit to return to normal navigation.

Fit the map to a specific area, regardless of the pixel size of the map.

Fit a map to a bounding box

Fit the map to a specific area, regardless of the pixel size of the map.

Get the bounds of a LineString.

Fit to the bounds of a LineString

Get the bounds of a LineString.

Scroll down through the story and the map will fly to the chapter's location.

Fly to a location based on scroll position

Scroll down through the story and the map will fly to the chapter's location.

Keep the viewport state in the url with hash routing.

Hash routing

Keep the viewport state in the url with hash routing.

Modify how Level of Detail behaves at high pitch angles.

Level of Detail Control

Modify how Level of Detail behaves at high pitch angles.

Offset the center or vanishing point of the map to reduce distortion when floating elements are displayed over the map.

Offset the vanishing point using padding

Offset the center or vanishing point of the map to reduce distortion when floating elements are displayed over the map.

Toggle between rendering a single world and multiple copies of the world using setRenderWorldCopies.

Render world copies

Toggle between rendering a single world and multiple copies of the world using setRenderWorldCopies.

Prevent a map from being panned to a different place by setting maxBounds.

Restrict map panning to an area

Prevent a map from being panned to a different place by setting maxBounds.

Set the center point above ground level.

Set center point above ground

Set the center point above ground level.

Drive an eye-height, level first-person camera over 3D buildings with the keyboard or on-screen buttons new

Walk around a map in first person

Drive an eye-height, level first-person camera over 3D buildings with the keyboard or on-screen buttons

Sources

Layers

Add an icon to the map from an external URL and use it in a symbol layer.

Add an icon to the map

Add an icon to the map from an external URL and use it in a symbol layer.

Add an icon to the map that was generated at runtime.

Add a generated icon to the map

Add an icon to the map that was generated at runtime.

Use a stretchable image as a background for text.

Add a stretchable image to the map

Use a stretchable image as a background for text.

Add an animated icon to the map that was generated at runtime with the Canvas API. If performance is important, consider using a <a href=plugin that draws the icon directly on the GPU via StyleImageWebGLData.">

Add an animated icon to the map

Add an animated icon to the map that was generated at runtime with the Canvas API. If performance is important, consider using a plugin that draws the icon directly on the GPU via StyleImageWebGLData.

Draw an animated icon straight into the icon atlas with WebGL, without moving its pixels through the CPU. Writing WebGL by hand is hard to get right, consider using a <a href=plugin that implements StyleImageWebGLData for you."> new

Animate an icon on the GPU

Draw an animated icon straight into the icon atlas with WebGL, without moving its pixels through the CPU. Writing WebGL by hand is hard to get right, consider using a plugin that implements StyleImageWebGLData for you.

Uses a missing style image resolver to load a remote image and use it.

Display a remote SVG symbol

Uses a missing style image resolver to load a remote image and use it.

Use the symbol-height-offset property to float icons and text above the ground in 3D. new

Elevate symbols above the terrain

Use the symbol-height-offset property to float icons and text above the ground in 3D.

Dynamically generate a missing icon at runtime and add it to the map.

Generate and add a missing icon to the map

Dynamically generate a missing icon at runtime and add it to the map.

Use a coalesce expression to display another image when a requested image is not available.

Use a fallback image

Use a coalesce expression to display another image when a requested image is not available.

Annotations & Labels

Use the format expression to display country labels in both English and in the local language.

Display and style rich text labels

Use the format expression to display country labels in both English and in the local language.

Apply Web fonts to your style’s text labels. Unlike signed distance field (SDF) glyph sets, Web fonts are available from a variety of providers, or your can make your own using popular tools. This option is suitable for fonts that are only available through a third-party content delivery network (CDN) for technical or legal reasons, as well as fonts that are incompatible with SDF, such as variable fonts. For compatibility with Android and iOS applications, specify equivalent fonts in the style’s font-faces property.

Style labels with Web fonts

Apply Web fonts to your style’s text labels. Unlike signed distance field (SDF) glyph sets, Web fonts are available from a variety of providers, or your can make your own using popular tools. This option is suitable for fonts that are only available through a third-party content delivery network (CDN) for technical or legal reasons, as well as fonts that are incompatible with SDF, such as variable fonts. For compatibility with Android and iOS applications, specify equivalent fonts in the style’s font-faces property.

Point your style at the font files used to draw its text labels. The font-faces property names a font file per text-font name, optionally narrowed to a unicode-range, so a style can cover scripts its glyphs server does not. Anything the browser can render text with may be used, and it is understood by Android and iOS as well. Here Georgian and Armenian labels come from font files while the Latin ones still come from the glyphs URL. new

Style labels with font faces

Point your style at the font files used to draw its text labels. The font-faces property names a font file per text-font name, optionally narrowed to a unicode-range, so a style can cover scripts its glyphs server does not. Anything the browser can render text with may be used, and it is understood by Android and iOS as well. Here Georgian and Armenian labels come from font files while the Latin ones still come from the glyphs URL.

Use the upcase and downcase expressions to change the case of labels.

Change the case of labels

Use the upcase and downcase expressions to change the case of labels.

Apply local fonts to your style’s text labels. This option is suitable if you don’t need every user to see exactly the same font, or if you want to avoid relying on a third-party content delivery network (CDN). For maximum compatibility, the text-font property should include fonts commonly found on multiple platforms.

Style labels with local fonts

Apply local fonts to your style’s text labels. This option is suitable if you don’t need every user to see exactly the same font, or if you want to avoid relying on a third-party content delivery network (CDN). For maximum compatibility, the text-font property should include fonts commonly found on multiple platforms.

Use text-variable-anchor to allow high priority labels to shift position to stay on the map.

Variable label placement

Use text-variable-anchor to allow high priority labels to shift position to stay on the map.

Use text-variable-anchor-offset to allow high priority labels to shift position to stay on the map.

Variable label placement with offset

Use text-variable-anchor-offset to allow high priority labels to shift position to stay on the map.

Interactivity & Extensions