Examples
Styles (11)Add a default markerAdd an animated icon to the mapAdd a generated icon to the mapGenerate and add a missing icon to the mapAdd a stretchable image to the mapAdd an icon to the mapDisplay a map with a custom styleRender world copiesChange a map's styleDisplay a mapDisplay a satellite mapLayers (32)Display buildings in 3DExtrude polygons for 3D indoor mappingAdd a 3D modelAdjust a layer's opacityAnimate a lineAnimate a series of imagesAnimate a pointChange building color based on zoom levelChange the case of labelsDisplay HTML clusters with custom propertiesCreate and style clustersChange a layer's color with buttonsAdd a custom style layerStyle lines with a data-driven propertyStyle circles with a data-driven propertyDisplay and style rich text labelsAdd a pattern to a polygonAdd a GeoJSON lineAdd a new layer below labelsAdd a GeoJSON polygonDraw GeoJSON pointsCreate a heatmap layerAdd hillshadingCreate a gradient line using an expressionAdd multiple geometries from one GeoJSON sourceUse a fallback imageStyle ocean depth dataShow and hide layersChange worldview of administrative boundariesUpdate a choropleth layer by zoom levelVariable label placementVisualize population densitySources (10)Add a canvas sourceJoin local JSON data with vector tile geometriesAdd an imageAdd live realtime dataUpdate a feature in realtimeAdd a raster tile sourceAdd a third party vector tile sourceAdd a videoAdd a vector tile sourceAdd a WMS sourceUser interaction (21)Customize camera animationsAnimate 3D buildings based on ambient soundsDisable map rotationCreate a draggable pointFilter features within map viewFilter symbols by text inputFilter symbols by toggling a listCreate a hover effectDisplay a non-interactive mapChange a map's languageMeasure distancesGet coordinates of the mouse pointerHighlight features containing similar dataSelect features around a clicked pointGet features under the mouse pointerRestrict map panning to an areaCreate a draggable MarkerCreate a time sliderToggle interactionsHighlight features within a bounding boxFit to the bounds of a LineStringCamera (12)Animate map camera around a pointAnimate a point along a routeCenter the map on a clicked symbolFit a map to a bounding boxSlowly fly to a locationFly to a locationNavigate the map with game-like controlsJump to a series of locationsOffset the vanishing point using paddingPlay map locations as a slideshowSet pitch and bearingFly to a location based on scroll positionControls and overlays (17)Animate a markerChange the default position for attributionAdd custom icons with MarkersDisable scroll zoomView a fullscreen mapLocate the userSwipe between mapsDisplay driving directionsShow drawn polygon areaAdd a geocoderAdd a marker using a place nameDisplay map navigation controlsShow polygon information on clickDisplay a popup on clickDisplay a popup on hoverDisplay a popupAttach a popup to a marker instanceGeocoder (9)Supplement forward geocoding search results from another data sourceAccept coordinates as input to a geocoderUse a custom render function with a geocoderLimit geocoder results to a named regionUse the geocoder without a mapPlace the geocoder input outside the mapUse a custom camera animation with a geocoderLocalize the geocoder to a given languageSet a point after Geocoder resultBrowser support (1)Check if Mapbox GL JS is supportedInternationalization support (2)Use locally generated ideographsAdd support for right-to-left scripts

Add an image

Dark vector baselayer with radar weather image overlay.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Add an image</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.css" rel="stylesheet" />
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
// TO MAKE THE MAP APPEAR YOU MUST
// ADD YOUR ACCESS TOKEN FROM
// https://account.mapbox.com
mapboxgl.accessToken = '<your access token here>';
var mapStyle = {
'version': 8,
'name': 'Dark',
'sources': {
'mapbox': {
'type': 'vector',
'url': 'mapbox://mapbox.mapbox-streets-v8'
},
'overlay': {
'type': 'image',
'url': 'https://docs.mapbox.com/mapbox-gl-js/assets/radar.gif',
'coordinates': [
[-80.425, 46.437],
[-71.516, 46.437],
[-71.516, 37.936],
[-80.425, 37.936]
]
}
},
'sprite': 'mapbox://sprites/mapbox/dark-v10',
'glyphs': 'mapbox://fonts/mapbox/{fontstack}/{range}.pbf',
'layers': [
{
'id': 'background',
'type': 'background',
'paint': { 'background-color': '#111' }
},
{
'id': 'water',
'source': 'mapbox',
'source-layer': 'water',
'type': 'fill',
'paint': { 'fill-color': '#2c2c2c' }
},
{
'id': 'boundaries',
'source': 'mapbox',
'source-layer': 'admin',
'type': 'line',
'paint': {
'line-color': '#797979',
'line-dasharray': [2, 2, 6, 2]
},
'filter': ['all', ['==', 'maritime', 0]]
},
{
'id': 'overlay',
'source': 'overlay',
'type': 'raster',
'paint': { 'raster-opacity': 0.85 }
},
{
'id': 'cities',
'source': 'mapbox',
'source-layer': 'place_label',
'type': 'symbol',
'layout': {
'text-field': '{name_en}',
'text-font': ['DIN Offc Pro Bold', 'Arial Unicode MS Bold'],
'text-size': [
'interpolate',
['linear'],
['zoom'],
4,
9,
6,
12
]
},
'paint': {
'text-color': '#969696',
'text-halo-width': 2,
'text-halo-color': 'rgba(0, 0, 0, 0.85)'
}
},
{
'id': 'states',
'source': 'mapbox',
'source-layer': 'place_label',
'type': 'symbol',
'layout': {
'text-transform': 'uppercase',
'text-field': '{name_en}',
'text-font': ['DIN Offc Pro Bold', 'Arial Unicode MS Bold'],
'text-letter-spacing': 0.15,
'text-max-width': 7,
'text-size': [
'interpolate',
['linear'],
['zoom'],
4,
10,
6,
14
]
},
'filter': ['==', ['get', 'class'], 'state'],
'paint': {
'text-color': '#969696',
'text-halo-width': 2,
'text-halo-color': 'rgba(0, 0, 0, 0.85)'
}
}
]
};
var map = new mapboxgl.Map({
container: 'map',
maxZoom: 5.99,
minZoom: 4,
zoom: 5,
center: [-75.789, 41.874],
style: mapStyle
});
</script>
</body>
</html>
Was this example helpful?