UNPKG

@maplibre/maplibre-gl-leaflet

Version:

Supports adding Maplibre GL Web to a Leaflet Map as a layer

47 lines (38 loc) 1.17 kB
<!DOCTYPE html> <html> <head> <title>WebGL</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> html, body, #map { width: 100%; height: 100%; margin: 0; } </style> <!-- Leaflet --> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" /> <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script> <!-- Maplibre GL --> <link href="https://unpkg.com/maplibre-gl@5.0.1/dist/maplibre-gl.css" rel='stylesheet' /> <script src="https://unpkg.com/maplibre-gl@5.0.1/dist/maplibre-gl.js"></script> </head> <body> <div id="map"></div> <script src="../leaflet-maplibre-gl.js"></script> <script> var map = L.map('map', {}).setView([0, 0], 2); L.marker([179, 0]) .bindPopup("Hello <b>Leaflet GL</b>!<br>Whoa, it works!") .addTo(map) .openPopup(); var gl = L.maplibreGL({ // get your own MapTiler token at https://cloud.maptiler.com/ or use MapBox style style: 'https://api.maptiler.com/maps/topo/style.json?key=gbetYLSD5vR8MdtZ88AQ' }).addTo(map); </script> </body> </html>