forked from klokantech/gl-style-package-spec
-
Notifications
You must be signed in to change notification settings - Fork 3
/
debug.html
81 lines (67 loc) · 2.79 KB
/
debug.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<title>Debug your style</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.51.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.51.0/mapbox-gl.css' rel='stylesheet'/>
<script src='http://mapbox-gl-inspect.lukasmartinelli.ch/dist/mapbox-gl-inspect.min.js'></script>
<link href='http://mapbox-gl-inspect.lukasmartinelli.ch/dist/mapbox-gl-inspect.css' rel='stylesheet'/>
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<div id='map'></div>
<script>
var map = new mapboxgl.Map({
container: 'map',
style: 'built-style-debug.json',
zoom: 14,
center: [
2.2900, 48.8719
],
hash: true
});
var inspect_control = new MapboxInspect();
map.addControl(inspect_control, 'bottom-right');
var nav_control = new mapboxgl.NavigationControl();;
map.addControl(nav_control, 'bottom-right');
map.on('load', function () {
for (const lvl of['poi-level-1', 'poi-level-2', 'poi-level-3']) {
map.on('mousemove', lvl, function (e) {
// Change the cursor style as a UI indicator.
map.getCanvas().style.cursor = 'pointer';
});
map.on('mouseleave', lvl, function () {
map.getCanvas().style.cursor = '';
});
map.on('click', lvl, function (e) {
// Single out the first found feature.
var feature = e.features[0];
var popup_content = feature.properties.name || "pas de nom :("
const tags = JSON.parse(feature.properties.tags)
let html = feature.properties.name;
html += '<ul>'
for (const [k, v] of Object.entries(tags)) {
html += '<li>' + k + ': ' + v + '</li>'
}
html += '</ul>'
// Display a popup
var popup = new mapboxgl.Popup({closeButton: false}).setLngLat(e.lngLat).setHTML(html).addTo(map);
});
}
});
</script>
</body>
</html>