Playground: Add Marker

How to place a basic marker on a map.

A Marker is a DOM element placed at a geographic coordinate. As you pan or zoom the map, MapLibre keeps the marker anchored at its real-world position.

Warning

Coordinates in MapLibre are always [longitude, latitude]not [latitude, longitude]. This is the convention used by GeoJSON and most spatial libraries, and it bites everyone at least once.

The minimal workflow:

new maplibregl.Marker({ color: '#c00' })
	.setLngLat([12.34, 45.43])
	.addTo(map);

Common customizations:

Browse the MapLibre examples for more patterns.