-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
executable file
·731 lines (643 loc) · 30.3 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
<!doctype html>
<!--
Tangram: real-time WebGL rendering for OpenStreetMap
http://github.com/tangrams/tangram
http://mapzen.com
-->
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Zinc</title>
<!-- 3rd party libraries -->
<!-- Leaflet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.js"></script>
<!-- bog-standard leaflet URL hash -->
<script type="text/javascript" src="https://cdn.rawgit.com/mlevans/leaflet-hash/master/leaflet-hash.js"></script>
<!-- Main tangram library -->
<!-- production -->
<script src="https://mapzen.com/tangram/0.12/tangram.min.js"></script>
<!-- production debug -->
<!-- <script src="https://mapzen.com/tangram/0.12/tangram.debug.js"></script> -->
<!-- dev -->
<!-- <script src="https://precog.mapzen.com/tangrams/tangram/master/dist/tangram.debug.js"></script> -->
<!-- dev branch -->
<!-- <script src="https://precog.mapzen.com/tangrams/tangram/labels-rebase/dist/tangram.min.js"></script> -->
<!-- A lightweight graphical user interface for changing variables in JavaScript. -->
<script type="text/javascript" src="lib/dat.gui.min.js"></script>
<!-- FileSaver.js implements the HTML5 W3C saveAs(), used in the demo to save screenshots -->
<script type="text/javascript" src="lib/FileSaver.js"></script>
<!-- Keymaster handles keyboard input -->
<script type="text/javascript" src="lib/keymaster.js"></script>
<!-- End of 3rd party libraries -->
<style>
body {
margin: 0px;
border: 0px;
padding: 0px;
}
#map {
background: rgba(0, 0, 0, 0);
height: 100%;
width: 100%;
position: absolute;
}
.label {
width: auto;
/*margin-left: -100px;*/
position: absolute;
z-index: 500;
text-align: left;
margin: 10px;
/*background: #E1E1E1;*/
background: rgba(3,3,3,0.6);
opacity: 0.9;
padding: 2px;
visibility: hidden;
/*text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;*/
/*word-wrap: break-word;*/
}
.label a {
color: white;
}
.label a:hover {
color: lightblue;
}
.labelInner {
padding: 3px 0px;
font-family: Helvetica, sans-serif;
font-weight: bold;
font-size: 12px;
color: white;
opacity: 2.0;
margin: 0px;
}
.labelLine {
/*border: 2px solid gold;*/
}
.labelLine:hover {
/* border: 2px solid gold; */
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: default;
}
.title {
text-align: center;
font-weight: bold;
color: white;
margin-left: 6px;
}
hr {
border: 0;
height: 1px;
background: rgba(255,255,255,0.5);
}
.coorner {
position: absolute;
background-color: rgba(255,255,255,0.0);
width: 10px;
height: 10px;
z-index: 103;
}
div#coorner-top-left {
top: -2px;
left: -2px;
border-top: 2px solid rgba(255,255,255,0.7);
border-left: 2px solid rgba(255,255,255,0.7);
}
div#coorner-top-right {
top: -2px;
right: -2px;
border-top: 2px solid rgba(255,255,255,0.7);
border-right: 2px solid rgba(255,255,255,0.7);
}
div#coorner-bottom-left {
bottom: -2px;
left: -2px;
border-bottom: 2px solid rgba(255,255,255,0.7);
border-left: 2px solid rgba(255,255,255,0.7);
}
div#coorner-bottom-right {
bottom: -2px;
right: -2px;
border-bottom: 2px solid rgba(255,255,255,0.7);
border-right: 2px solid rgba(255,255,255,0.7);
}
</style>
</head>
<body>
<div class="label" id="popup"></div>
<div id="map"></div>
<!-- Demo module -->
<script>
/*** URL parsing ***/
var animated = true;
var url_search = window.location.search.slice(1);
if (url_search.length > 0) {
if (url_search.indexOf('animated=false') > -1) {
animated = false;
}
}
// location
var url_hash = window.location.hash.slice(1).split('/'); // map location as #z/x/y
var map_start_location = [37.7926, -122.4003, 15]; // San Francisco
var defaultpos = true; // use default position
// location is passed through url
if (url_hash.length == 3) {
var defaultpos = false;
if (url_hash[1] > 180) { // parse hash as tile coordinates
// example: http://localhost:9001/#15/5242/12663
// add .5 to coords to center tile on screen
map_start_location = [tile2lat(parseFloat(url_hash[2]) + .5, url_hash[0]), tile2long(parseFloat(url_hash[1]) + .5, url_hash[0]), url_hash[0]];
}
else { // parse hash as lat/lng coordinates
map_start_location = [url_hash[1],url_hash[2], url_hash[0]];
// convert from strings
map_start_location = map_start_location.map(Number);
}
}
// enable setting language by URL argument
// eg: '?language=en&this=no'
var query = splitQueryParams();
// { language: 'en', this: 'no'}
function splitQueryParams () {
var str = window.location.search;
var kvArray = str.slice(1).split('&');
// ['language=en', 'this=no']
var obj = {};
for (var i = 0, j=kvArray.length; i<j; i++) {
var value = kvArray[i].split('=');
var k = window.decodeURIComponent(value[0]);
var v = window.decodeURIComponent(value[1]);
obj[k] = v;
}
return obj;
}
/*** Map ***/
var map = L.map('map',
{"keyboardZoomOffset" : .05, maxZoom: 20, "scrollWheelZoom": false }
);
map.setView(map_start_location.slice(0, 2), map_start_location[2]);
var layer = Tangram.leafletLayer({
// more: 'vector-tiles-9Dggrv4'
// default (some): 'vector-tiles-id4gZ6k'
// no: 'vector-tiles-yk8LOEY'
scene: { import: 'zinc-style.yaml', global: { sdk_mapzen_api_key: 'vector-tiles-id4gZ6k' } },
attribution: '<a href="https://mapzen.com/tangram" target="_blank">Tangram</a>, © OSM contributors'
});
var scene = layer.scene;
var latlng = {};
var popup = document.getElementById('popup'); // click-popup
var hash = new L.Hash(map);
function updateKey(value) {
keytext = value;
for (layer in scene.config.layers) {
if (layer == "earth") continue;
scene.config.layers[layer].properties.key_text = value;
}
scene.rebuildGeometry();
scene.requestRedraw();
}
function updateValue(value) {
valuetext = value;
for (layer in scene.config.layers) {
if (layer == "earth") continue;
scene.config.layers[layer].properties.value_text = value;
}
scene.rebuildGeometry();
scene.requestRedraw();
}
window.addEventListener('load', function () {
// Scene initialized
layer.scene.subscribe({
load: function (data) {
data.config.global.sdk_animated = animated;
}
});
layer.addTo(map);
});
// Feature selection
var picking = false;
function initFeatureSelection () {
layer.setSelectionEvents({
hover: function(selection) {
if (!picking) {
if (!selection || selection.feature == null || selection.feature.properties == null) {
picking = false;
popup.style.visibility = 'hidden';
return;
}
var properties = selection.feature.properties;
popup.style.width = 'auto';
popup.style.left = (selection.pixel.x + 0) + 'px';
popup.style.top = (selection.pixel.y + 0) + 'px';
popup.style.margin = '10px';
if (properties.name) {
popup.innerHTML = '<span class="labelInner">' + properties.name + '</span><br>';
} else {
popup.innerHTML = '<span class="labelInner">' + 'unnamed ' + properties.kind + '</span><br>';
}
popup.innerHTML += '<span class="labelInner" style="font-size:10px;">' + 'Click to view more...' + '</span><br>';
popup.style.visibility = 'visible';
}
}
});
}
function createEditLinkElement (url, type, label) {
var el = document.createElement('div');
var anchor = document.createElement('a');
el.className = 'labelInner';
anchor.href = url;
anchor.target = '_blank';
anchor.textContent = label;
anchor.addEventListener('click', function (event) {
trackOutboundLink(url, 'mapzen_carto_debug', type);
}, false);
el.appendChild(anchor);
return el;
}
/**
* Function that tracks a click on an outbound link in Google Analytics.
* This function takes a valid URL string as an argument, and uses that URL string
* as the event label. Setting the transport method to 'beacon' lets the hit be sent
* using 'navigator.sendBeacon' in browser that support it.
*/
function trackOutboundLink (url, post_name, editor) {
// ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
ga('send', 'event', 'outbound', post_name, url, {
'transport': 'beacon',
// If opening a link in the current window, this opens the url AFTER
// registering the hit with Analytics. Disabled because here want the
// link to open in a new window, so this hit can occur in the current tab.
//'hitCallback': function(){document.location = url;}
});
}
// convert tile coordinates to lat-lng
// from http://gis.stackexchange.com/questions/17278/calculate-lat-lon-bounds-for-individual-tile-generated-from-gdal2tiles
function tile2long(x,z) { return (x/Math.pow(2,z)*360-180); }
function tile2lat(y,z) {
var n=Math.PI-2*Math.PI*y/Math.pow(2,z);
return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n))));
}
function long2tile(lon,zoom) { return (Math.floor((lon+180)/360*Math.pow(2,zoom))); }
function lat2tile(lat,zoom) { return (Math.floor((1-Math.log(Math.tan(lat*Math.PI/180) + 1/Math.cos(lat*Math.PI/180))/Math.PI)/2 *Math.pow(2,zoom))); }
function mapzenTileURL() {
// find minimum max_zoom of all sources
var max_zoom = 16;
for (source in scene.config.sources) {
if (scene.config.sources.hasOwnProperty(source)) {
if (scene.config.sources[source].max_zoom != "undefined") {
max_zoom = Math.min(max_zoom, scene.config.sources[source].max_zoom);
}
}
}
var zoom = max_zoom < map.getZoom() ? max_zoom : Math.floor(map.getZoom());
var tileCoords = { x : long2tile(latlng.lng,zoom), y: lat2tile(latlng.lat,zoom), z: zoom };
var url = 'http://tile.mapzen.com/mapzen/vector/v1/all/' + zoom + '/' + tileCoords.x + '/' + tileCoords.y + '.topojson';
return url;
}
/***** Render loop *****/
// Create dat GUI
var gui = new dat.GUI({ autoPlace: true });
function addGUI() {
gui.domElement.parentNode.style.zIndex = 10000;
window.gui = gui;
// Language selector
var langs = {
'(default)': false,
'العربية (Arabic)': 'ar',
'中文 (Chinese)': 'zh',
'English': 'en',
'français (French)': 'fr',
'Русский (Russian)': 'ru',
'español (Spanish)': 'es',
'বাংলা (Bengali)': 'bn',
'Deutsch (German)': 'de',
'ελληνικά (Greek)': 'gr',
'हिन्दी (Hindi)': 'hi',
'Bahasa Indonesia (Indonesian)': 'id',
'italiano (Italian)': 'it',
'日本語 (Japanese)': 'ja',
'한국어 (Korean)': 'ko',
'Português (Portuguese)': 'pt',
'Türkçe (Turkish)': 'tr',
'Tiếng Việt (Vietnamese)': 'vi'
};
// use query language, else default to English
gui.language = query.language || false;
gui.add(gui, 'language', langs).onChange(function(value) {
scene.config.global.ux_language = value;
scene.updateConfig();
//window.location.search = 'language=' + value;
});
gui.fallback_lang = query.language || false;
gui.fallback_button = gui.add(gui, 'fallback_lang', langs).onChange(function(value) {
scene.config.global.ux_language_fallback = value;
scene.updateConfig();
//window.location.search = 'language=' + value;
});
gui.fallback_button.name('lang fallback');
// Labels selector
var labels = {
'(default)': 'some',
'More': 'more',
'Some': 'some',
'Some (no shields)': 'some_no_shields',
'None': 'none'
};
gui.labels = query.labels || 'some';
gui.add(gui, 'labels', labels).onChange(function(value) {
var _default = true;
var _more = false;
var _road_shields = true;
if(value === 'more') {
_more = true;
_default = true;
_road_shields = true;
} else if(value === 'some') {
_more = false;
_default = true;
_road_shields = true;
} else if(value === 'some_no_shields') {
_more = false;
_default = true;
_road_shields = false;
} else {
_more = false;
_default = false;
_road_shields = false;
}
scene.config.global.text_visible_continent = _default;
scene.config.global.text_visible_admin = _default;
scene.config.global.text_visible_populated_places = _default;
scene.config.global.icon_visible_populated_places = _default;
scene.config.global.text_visible_neighbourhoods = _default;
scene.config.global.text_visible_neighbourhoods_e = _default;
scene.config.global.text_visible_water = _default;
scene.config.global.text_visible_water_labels = _default;
scene.config.global.text_visible_island = _default;
scene.config.global.sdk_road_shields = _road_shields;
scene.config.global.text_visible_roads = _default;
scene.config.global.text_visible_highway = _default;
scene.config.global.text_visible_highway_e = _default;
scene.config.global.text_visible_trunk_primary_route = _default;
scene.config.global.text_visible_trunk_primary = _default;
scene.config.global.text_visible_secondary = _default;
scene.config.global.text_visible_tertiary = _default;
scene.config.global.text_visible_minor_road = _default;
scene.config.global.text_visible_minor_road_e = _default;
scene.config.global.text_visible_service_road = _default;
scene.config.global.text_visible_path = _default;
scene.config.global.text_visible_piste = _default;
scene.config.global.text_visible_steps = _default;
scene.config.global.text_visible_highway_e = _default;
scene.config.global.text_visible_trunk_primary_e2 = _default;
scene.config.global.text_visible_trunk_primary_e = _default;
scene.config.global.text_visible_secondary_e = _default;
scene.config.global.text_visible_tertiary_e = _default;
scene.config.global.text_visible_minor_road_e = _default;
scene.config.global.text_visible_exits_e = _default;
scene.config.global.text_visible_aerialway = _default;
scene.config.global.text_visible_airport_gate = _default;
scene.config.global.text_visible_exits = _default;
scene.config.global.text_visible_building = _more;
scene.config.global.text_visible_address = _more;
scene.config.global.label_visible_poi_landuse = _more;
scene.config.global.text_visible_poi_landuse = _more;
scene.config.global.label_visible_poi_landuse_e = _more;
scene.config.global.icon_visible_poi_landuse = _more;
scene.config.global.icon_visible_poi_landuse_e = _more;
scene.config.global.text_visible_poi_landuse_e = _more;
scene.config.global.icon_visible_station = _more;
scene.config.global.icon_visible_landuse_green = _default;
scene.config.global.text_visible_landuse_green = _default;
scene.config.global.text_visible_landuse_generic = _more;
if( _more ) {
scene.config.global.icon_size_green = [[13, '14px'], [16, '18px'], [18, '19px']];
scene.config.global.icon_size_green_nationl_park = [[10,'18px'],[12,'28px'],[13,'36px']];
scene.config.global.icon_size_green_airport = [[13,'12px'],[14,'12px'],[17,'18px'],[19,'36px']];
scene.config.global.icon_size_green_l = [[14,'24px'],[16,'32px']];
} else {
scene.config.global.icon_size_green = [[0, '0px']];
scene.config.global.icon_size_green_nationl_park = [[0, '0px']];
scene.config.global.icon_size_green_airport = [[0, '0px']];
scene.config.global.icon_size_green_l = [[0, '0px']];
}
scene.updateConfig();
//window.location.search = 'language=' + value;
});
// Transit selector
var transit_overlay = {
'(default)': false,
'Show': true,
'Hide': false
};
// use transit ux, else default to false
gui.transit_overlay = query.transit_overlay || false;
gui.transit_button = gui.add(gui, 'transit_overlay', transit_overlay).onChange(function(value) {
scene.config.global.sdk_transit_overlay = (value === 'true' || value === true); // dat.gui passes a string
if (value === 'true' || value === true) {
scene.config.global.sdk_road_shields = false;
} else {
if( scene.config.global.text_visible_roads ) {
scene.config.global.sdk_road_shields = true;
}
}
scene.updateConfig();
});
gui.transit_button.name('transit');
// Building extrusion selector
var building_3d = {
'(default)': false,
'Yes': true,
'No': false
};
// use transit ux, else default to false
gui.building_3d = query.building_3d || false;
gui.building_button = gui.add(gui, 'building_3d', building_3d).onChange(function(value) {
scene.config.global.sdk_building_extrude = (value === 'true' || value === true); // dat.gui passes a string
scene.updateConfig();
});
gui.building_button.name( '3D buildings' );
// // Animation selector
// var animated = {
// '(default)': true,
// 'Yes': true,
// 'No': false
// };
// gui.animated = query.animated || true;
// gui.add(gui, 'animated', animated).onChange(function(value) {
// scene.config.global.sdk_animated = (value === 'true' || value === true); // dat.gui passes a string
// scene.updateConfig();
// //window.location.search = 'animated=' + value;
// });
// Enable/disable interactivity for all features
var interactive_label = 'interactive';
gui[interactive_label] = false;
gui.add(gui, interactive_label).onChange(function(value) {
scene.setIntrospection(value);
});
scene.setIntrospection(gui[interactive_label]);
// Take a screenshot and save to file
gui.save_screenshot = function () {
return scene.screenshot().then(function(screenshot) {
// uses FileSaver.js: https://github.com/eligrey/FileSaver.js/
timestamp = new Date();
month = timestamp.getMonth()+1;
if( month < 10 ) { month = '0' + month; }
prettydate = timestamp.getFullYear() + month + timestamp.getDate() + timestamp.getHours() + timestamp.getMinutes();
map_location = map.getZoom() + '-' + map.getCenter().lat.toFixed(5) + '-' + map.getCenter().lng.toFixed(5);
saveAs(screenshot.blob, 'tangram-' + map_location + '-' + prettydate + '.png');
});
};
gui.screenshot = gui.add(gui, 'save_screenshot');
gui.screenshot.name('save screenshot');
// Take a video capture and save to file
if (typeof window.MediaRecorder == 'function') {
gui.video = function () {
if (!gui.video_capture) {
if (scene.startVideoCapture()) {
gui.video_capture = true;
gui.video_button.name('stop video');
}
}
else {
return scene.stopVideoCapture().then(function(video) {
gui.video_capture = false;
gui.video_button.name('capture video');
saveAs(video.blob, 'tangram-video-' + (+new Date()) + '.webm');
});
}
};
gui.video_button = gui.add(gui, 'video');
gui.video_button.name('capture video');
gui.video_capture = false;
}
// Link to edit in OSM - hold 'e' and click
map.getContainer().addEventListener('dblclick', function (event) {
//console.log( 'dblclick was had' );
if( timer ) { clearTimeout( timer ); timer = null; }
popup.style.visibility = 'hidden';
});
var timer;
map.getContainer().addEventListener('mousemove', function (event) {
picking = false;
popup.style.visibility = 'hidden';
return;
});
layer.setSelectionEvents({
click: function(selection) {
if( timer ) { clearTimeout( timer ); timer = null; }
timer = setTimeout( function() {
picking = true;
latlng = selection.leaflet_event.latlng;
if( key.cmd || key.alt ) {
window.open( mapzenTileURL(), '_blank' );
} else {
var url = 'https://www.openstreetmap.org/edit?';
if (!selection || selection.feature == null || selection.feature.properties == null) {
picking = false;
popup.style.visibility = 'hidden';
return;
}
//console.log(selection.feature, selection.changed);
// enable iD to show properties sidebar for selected feature
osm_type = 'node';
osm_zoom = '19'
// tilezen adds sort_rank for any way or relation thing, but because we generate
// label positions for area features, we need to do two tests
if( selection.feature.properties.sort_rank || selection.feature.properties.area ) {
osm_type = 'way';
osm_zoom = Math.max( 17, map.getZoom() );
}
osm_id = selection.feature.properties.id;
if( osm_id < 0 ) {
osm_type = 'relation'
osm_id = Math.abs( osm_id );
// zoom out a bit because we assume this is a larger feature
// but don't zoom out too far, as iD breaks
osm_zoom = Math.max( 16, map.getZoom() );
}
url += osm_type + '=' + osm_id;
// and position the map so it's at a similar zoom to Tangram
if (latlng) {
url += '#map=' + osm_zoom + '/' + latlng.lat + '/' + latlng.lng;
}
if( key.shift ) {
window.open(url, '_blank');
} else {
var properties = selection.feature.properties;
var label = '';
//console.log(properties);
for (var x in properties) {
var val = properties[x]
label += "<span class='labelLine' key="+x+" value="+val+"'>"+x+" : "+val+"</span><br>"
}
if (label != '') {
popup.style.left = (selection.pixel.x) + 'px';
popup.style.top = (selection.pixel.y) + 'px';
popup.style.margin = '0px';
popup.innerHTML = '<span class="labelInner">' + label + '</span>';
}
// JOSM editor link
var position = '19' + '/' + latlng.lat + '/' + latlng.lng;
var josmUrl = 'http://www.openstreetmap.org/edit?editor=remote#map='+position;
popup.appendChild(createEditLinkElement( url, 'iD', 'Edit with iD ➹') );
popup.appendChild(createEditLinkElement( mapzenTileURL(), 'rawTile', 'View tile data ➹') );
//popup.appendChild(createEditLinkElement( josmUrl, 'JOSM', 'Edit with JOSM ➹') );
popup.style.visibility = 'visible';
}
}
timer = null;
}, 200 );
}
});
}
function inIframe () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}
// Add map
window.addEventListener('load', function () {
// Scene initialized
layer.on('init', function() {
var camera = scene.config.cameras[scene.getActiveCamera()];
// if a camera position is set in the scene file, use that
if (defaultpos && typeof camera.position != "undefined") {
map_start_location = [camera.position[1], camera.position[0], camera.position[2]]
}
map.setView([map_start_location[0], map_start_location[1]], map_start_location[2]);
if (!inIframe()) {
addGUI();
}
});
if (!inIframe()) {
map.scrollWheelZoom.enable();
initFeatureSelection();
}
function addToMap () {
layer.addTo(map);
}
});
</script>
<!-- Mapzen map UI -->
<script src='https://mapzen.com/common/ui/mapzen-ui.min.js'></script>
<script>
MPZN.bug({
name: 'Mapzen Zinc cartography',
link: 'https://tangrams.github.io/zinc-style/',
tweet: 'Zinc cartography from @mapzen',
repo: 'https://github.com/tangrams/zinc-style/'
});
</script>
</body>
</html>