mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
add leaflet demo with osm carto raster tiles, pass leaflet options
This commit is contained in:
@@ -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
BIN
examples/osm_carto.pmtiles
Normal file
Binary file not shown.
@@ -178,7 +178,7 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return new cls()
|
return new cls(options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {PMTiles:PMTiles}
|
return {PMTiles:PMTiles}
|
||||||
|
|||||||
Reference in New Issue
Block a user