UNPKG

@maplibre/maplibre-gl-leaflet

Version:

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

45 lines (36 loc) 1.2 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([38.912753, -77.032194], 15); L.marker([38.912753, -77.032194]) .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=get_your_own_OpIi9ZULNHzrESv6T2vL' }).addTo(map); </script> </body> </html>