Files
PMTiles/js/examples/maplibre_raster_dem.html
Brandon Liu 3472fd89f9 Option to load metadata in MapLibre adapter [#247] (#461)
* Option to load metadata in MapLibre adapter [#247]

* pass metadata: true to new Protocol() to make an extra request and populate attribution + vector_layers
* js 3.2.0 [#247]
* simplify examples
* update leaflet and maplibre versions
* add maplibre_headers.html example for custom headers [#397]
2024-09-22 19:04:50 +08:00

60 lines
1.9 KiB
HTML

<html>
<head>
<title>PMTiles MapLibre Raster DEM Example</title>
<meta charset="utf-8"/>
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@4.7.0/dist/maplibre-gl.css" crossorigin="anonymous">
<script src="https://unpkg.com/maplibre-gl@4.7.0/dist/maplibre-gl.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/pmtiles@3.2.0/dist/pmtiles.js"></script>
<style>
body {
margin: 0;
}
#map {
height:100%; width:100%;
}
#overlay {
position: absolute;
top: 1rem;
left: 1rem;
font: 600 16px sans-serif;
background-color: white;
border-radius: 4px;
padding: 0.5rem;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="overlay">
</div>
<script type="text/javascript">
let protocol = new pmtiles.Protocol({metadata: true});
maplibregl.addProtocol("pmtiles", protocol.tile);
const map = new maplibregl.Map({
container: "map",
zoom: 0,
center: [0, 0],
style: {
version: 8,
sources: {
example_source: {
type: "raster-dem",
url: "pmtiles://https://r2-public.protomaps.com/protomaps-sample-datasets/terrarium_z9.pmtiles",
encoding: "terrarium",
},
},
layers: [
{
id: "dem",
source: "example_source",
"source-layer": "landuse",
type: "hillshade",
},
],
},
});
</script>
</body>
</html>