Created
October 13, 2022 03:43
-
-
Save bdon/a106219d5714ed9dc80aa5327900aa89 to your computer and use it in GitHub Desktop.
example use of pmtiles 2.0.0 with maplibre
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Display a map</title> | |
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> | |
<script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script> | |
<link href="https://unpkg.com/[email protected]/dist/maplibre-gl.css" rel="stylesheet" /> | |
<script src="https://unpkg.com/[email protected]/dist/index.js"></script> | |
<style> | |
body { margin: 0; padding: 0; } | |
#map { position: absolute; top: 0; bottom: 0; width: 100%; } | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script> | |
let protocol = new pmtiles.Protocol(); | |
maplibregl.addProtocol("pmtiles",protocol.tile); | |
var map = new maplibregl.Map({ | |
container: 'map', | |
style: { | |
version: 8, | |
sources: { | |
example_source: { | |
type: "vector", | |
tiles: ["pmtiles://https://protomaps-static.sfo3.digitaloceanspaces.com/cb_2018_us_zcta510_500k_gzip.pmtiles/{z}/{x}/{y}"] | |
} | |
}, | |
layers: [ | |
{ | |
id: "zcta", | |
type: "fill", | |
source: "example_source", | |
"source-layer":"zcta", | |
paint: { | |
"fill-color":"steelblue" | |
} | |
} | |
] | |
}, | |
center: [-100, 36], | |
zoom: 3 | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment