forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.html
156 lines (137 loc) · 4.3 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html>
<head>
<title>Mapbox GL JS debug page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel='stylesheet' href='/dist/mapbox-gl.css' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
#checkboxes {
position: absolute;
background: #fff;
top:0;
left:0;
padding:10px;
}
</style>
</head>
<body>
<div id='map'></div>
<div id='checkboxes'>
<label><input id='show-tile-boundaries-checkbox' type='checkbox'> tile debug</label><br />
<label><input id='show-symbol-collision-boxes-checkbox' type='checkbox'> collision debug</label><br />
<label><input id='show-overdraw-checkbox' type='checkbox'> overdraw debug</label><br />
<label><input id='pitch-checkbox' type='checkbox' checked> pitch with rotate</label><br />
</div>
<script src='/dist/mapbox-gl-dev.js'></script>
<script src='/debug/access_token_generated.js'></script>
<script>
var map = window.map = new mapboxgl.Map({
container: 'map',
zoom: 12.5,
center: [-77.01866, 38.888],
style: 'mapbox://styles/mapbox/streets-v10',
hash: true
});
map.addControl(new mapboxgl.NavigationControl());
map.addControl(new mapboxgl.GeolocateControl({
positionOptions: {
enableHighAccuracy: true
},
trackUserLocation: true,
showUserLocation: true,
fitBoundsOptions: {
maxZoom: 20
}
}));
map.addControl(new mapboxgl.ScaleControl());
map.on('load', function() {
map.addSource('geojson', {
"type": "geojson",
"data": "/test/integration/data/linestring.geojson",
"attribution": "GeoJSON Attribution"
});
map.addLayer({
"id": "route",
"type": "line",
"source": "geojson",
"paint": {
"line-color": "#EC8D8D",
"line-width": {"base": 1.5, "stops": [[5, 0.75], [18, 32]]}
}
}, 'country-label-lg');
map.addSource("points", {
"type": "geojson",
"data": '/debug/cross_source_points.geojson'
});
map.addLayer({
"id": "points",
"type": "symbol",
"source": "points",
"layout": {
"text-field": "{name}",
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"]
}
});
map.addLayer({
id: "marker",
type: "symbol",
source: "points",
layout: {
"icon-image": "bus-11",
"icon-size": 2,
"icon-ignore-placement": true,
"icon-allow-overlap": true
}
});
map.addLayer({
id: "marker-hover",
type: "symbol",
filter: ["==", "name", ""],
source: "points",
layout: {
"icon-image": "bus-15",
"icon-size": 2,
"icon-ignore-placement": true,
"icon-allow-overlap": true
}
});
map.on('mouseenter', 'marker', function(e) {
map.setFilter('marker-hover', ['==', 'name', e.features[0].properties.name]);
});
map.on('mouseleave', 'marker', function(e) {
map.setFilter('marker-hover', ['==', 'name', '']);
});
});
map.on('click', function(e) {
if (e.originalEvent.shiftKey) return;
(new mapboxgl.Popup())
.setLngLat(map.unproject(e.point))
.setHTML("<h1>Hello World!</h1>")
.addTo(map);
});
document.getElementById('show-tile-boundaries-checkbox').onclick = function() {
map.showTileBoundaries = !!this.checked;
};
document.getElementById('show-symbol-collision-boxes-checkbox').onclick = function() {
map.showCollisionBoxes = !!this.checked;
};
document.getElementById('show-overdraw-checkbox').onclick = function() {
map.showOverdrawInspector = !!this.checked;
};
document.getElementById('pitch-checkbox').onclick = function() {
map.dragRotate._pitchWithRotate = !!this.checked;
};
// keyboard shortcut for comparing rendering with Mapbox GL native
document.onkeypress = function(e) {
if (e.charCode === 111 && !e.shiftKey && !e.metaKey && !e.altKey) {
var center = map.getCenter();
location.href = "mapboxgl://?center=" + center.lat + "," + center.lng + "&zoom=" + map.getZoom() + "&bearing=" + map.getBearing();
return false;
}
};
</script>
</body>
</html>