@maplibre/maplibre-gl-leaflet
Version:
Supports adding Maplibre GL Web to a Leaflet Map as a layer
49 lines (39 loc) • 1.13 kB
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/dist/maplibre-gl.css" rel='stylesheet' />
<script src="https://unpkg.com/maplibre-gl@5/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)
L.marker([0, 0])
.bindPopup("Hello <b>Leaflet GL</b>!<br>Whoa, it works!")
.addTo(map)
var gl = L.maplibreGL({
style: 'https://demotiles.maplibre.org/style.json'
}).addTo(map);
</script>
</body>
</html>