-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
59 lines (54 loc) · 1.67 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@observablehq/stdlib"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mapbox-gl/1.2.1/mapbox-gl.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/mapbox-gl/1.2.1/mapbox-gl.css" rel="stylesheet" />
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
#map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
const {DOM, require} = new observablehq.Library;
mapboxgl.accessToken = "pk.eyJ1IjoidG1jdyIsImEiOiJjamN0Z3ZiOXEwanZkMnh2dGFuemkzemE3In0.gibebYiJ5TEdXvwjpCY0jg";
const showNavigationControl = true;
require()('@observablehq/flare')
.then(data => {
{
let map = new mapboxgl.Map({
container: "map",
center: [-73.61457, 45.524149],
zoom: 5,
style: "mapbox://styles/mapbox/streets-v9",
scrollZoom: showNavigationControl
});
map.on('load', function() {
map.addSource('admin', {
'type': 'vector',
"tiles": [ window.location + "admin/{z}/{x}/{y}.pbf"],
"tolerance": 0
});
map.addLayer({
"id": "admin",
"source": "admin",
"source-layer": "admin",
"type": "fill",
"paint": {
"fill-color": "#FF0000",
}
});
});
map.on('error', e => {
console.log(e.error);
});
if (showNavigationControl) {
map.addControl(new mapboxgl.NavigationControl(), "top-right");
}
}
});
</script>
</body>