add leaflet demo with osm carto raster tiles, pass leaflet options

This commit is contained in:
Brandon Liu
2021-03-31 15:11:16 +08:00
parent 0720931e48
commit 5f3ffb83bf
3 changed files with 4 additions and 9 deletions

View File

@@ -17,14 +17,9 @@
<body> <body>
<div id="map"></div> <div id="map"></div>
<script> <script>
const map = L.map('map') const map = L.map('map',{maxZoom:4}).setView([0,0],0)
const ready = metadata => { const p = new pmtiles.PMTiles('osm_carto.pmtiles')
map.options.maxZoom = +metadata.maxzoom p.leafletLayer({attribution:'© <a href="https://openstreetmap.org">OpenStreetMap</a> contributors'}).addTo(map)
const b = metadata.bounds.split(',')
map.fitBounds([[+b[1],+b[0]],[+b[3],+b[2]]],{maxZoom:+metadata.maxzoom})
}
const p = new pmtiles.PMTiles('http://localhost:8500/example.pmtiles',ready);
p.leafletLayer().addTo(map)
</script> </script>
</body> </body>
</html> </html>

BIN
examples/osm_carto.pmtiles Normal file

Binary file not shown.

View File

@@ -178,7 +178,7 @@
}) })
}, },
}) })
return new cls() return new cls(options)
} }
} }
return {PMTiles:PMTiles} return {PMTiles:PMTiles}