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>
<div id="map"></div>
<script>
const map = L.map('map')
const ready = metadata => {
map.options.maxZoom = +metadata.maxzoom
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)
const map = L.map('map',{maxZoom:4}).setView([0,0],0)
const p = new pmtiles.PMTiles('osm_carto.pmtiles')
p.leafletLayer({attribution:'© <a href="https://openstreetmap.org">OpenStreetMap</a> contributors'}).addTo(map)
</script>
</body>
</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}