-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathtinysdf.html
96 lines (82 loc) · 2.43 KB
/
tinysdf.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
<!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, #originalMap, #newMap { height: 100%; }
#originalMap, #newMap { width: 49%; }
#originalLabel {
position: absolute;
background: #fff;
top:0;
left:0;
padding:10px;
}
#newLabel {
position: absolute;
background: #fff;
top:0;
right:0;
padding:10px;
}
#checkboxes {
position: absolute;
background: #fff;
bottom:35px;
left:0;
padding:10px;
}
</style>
</head>
<body>
<div id='originalMap' style="float: left"></div>
<div id='newMap' style="float: right"></div>
<label id='originalLabel'>Original Map</label>
<label id='newLabel'>New Map</label>
<div id='checkboxes'>
<label><input id='show-overdraw-checkbox' type='checkbox'> overdraw debug</label><br />
</div>
<script src='../dist/mapbox-gl-dev.js'></script>
<script src='../debug/access_token_generated.js'></script>
<script>
function localizeLayers(map) {
map.on('load', function() {
var style = map.getStyle();
for (var layerID in style.layers) {
var layer = style.layers[layerID];
if (layer.layout && layer.layout['text-field'] === "{name_en}") {
layer.layout['text-field'] = "{name}";
}
}
map.setStyle(style);
});
}
var originalMap = window.originalMap = new mapboxgl.Map({
container: 'originalMap',
zoom: 8.8,
center: [121.574, 31.1489],
style: 'mapbox://styles/mapbox/streets-v10',
hash: true,
localIdeographFontFamily: false
});
localizeLayers(originalMap);
var newMap = window.newMap = new mapboxgl.Map({
container: 'newMap',
zoom: 8.8,
center: [121.574, 31.1489],
style: 'mapbox://styles/mapbox/streets-v10',
//Uses default localIdeographFontFamily 'sans-serif'
hash: true
});
localizeLayers(newMap);
document.getElementById('show-overdraw-checkbox').onclick = function() {
originalMap.showOverdrawInspector = !!this.checked;
newMap.showOverdrawInspector = !!this.checked;
};
</script>
</body>
</html>