Examples

Add a GeoJSON line to a map using addSource, then style it using addLayer’s paint properties.

Add an external Web Map Service raster layer to the map using addSource's tiles option.

Add an animated icon to the map that was generated at runtime with the Canvas API.

Add a polygon and circle layer from the same GeoJSON source.

Use the mapbox-gl-rtl-text plugin to support right-to-left languages such as Arabic and Hebrew.

Use the interpolate expression to ease-in the building layer and smoothly fade from one color to the next.

Place attribution in the top-left position when initializing a map.

Drag the marker to a new location on a map and populate its coordinates in a display.

Drag the point to a new location on a map and populate its coordinates in a display.

Use the line-gradient paint property and an expression to visualize distance from the starting point of a line.

When a user hovers over a custom marker, show a popup containing more information.

Use the format expression to display country labels in larger size.

Extend clustering with HTML markers and custom property expressions.

Draw a line across the 180th meridian using a GeoJSON source.

Create a 3D indoor map with the fill-extrude-height paint property.

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

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

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

Show mouse position on hover with pixel and latitude and longitude coordinates.

Use queryRenderedFeatures to show properties of hovered-over map elements.

Geolocate the user and then track their current location on the map using the GeolocateControl.

Use the keyboard's arrow keys to move around the map with game-like controls.

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.

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

Use mapbox-gl-draw to draw a polygon and Turf.js to calculate its area in square meters.

When a user clicks a polygon, show a popup containing more information.

Create a visualization with a data expression for line-color.

Change an existing feature on your map in real-time by updating its data.

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

Use goong-geocoder-js to display a search box without a map.

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

Use a variable binding expression to calculate and display population density.