Skip to content

Display a popup

Add a popup to the map.

<!DOCTYPE html>
<html lang="en">
    <title>Display a popup</title>
    <meta property="og:description" content="Add a popup to the map." />
    <meta charset='utf-8'>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel='stylesheet' href='' />
    <script src=''></script>
        body { margin: 0; padding: 0; }
        html, body, #map { height: 100%; }
<div id="map"></div>
    const map = new maplibregl.Map({
        container: 'map',
        center: [-96, 37.8],
        zoom: 3

    const popup = new maplibregl.Popup({closeOnClick: false})
        .setLngLat([-96, 37.8])
        .setHTML('<h1>Hello World!</h1>')