-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·81 lines (64 loc) · 2.49 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
<!doctype html>
<!--
Tangram: real-time WebGL rendering for OpenStreetMap
http://github.com/tangrams/tangram
http://mapzen.com
-->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>XYZ - GRID - DARK</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<style>
body {
margin: 0px;
border: 0px;
padding: 0px;
}
#map {
height: 100%;
width: 100%;
position: absolute;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- leaflet -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-hash/0.2.1/leaflet-hash.min.js"></script>
<!-- Main tangram library -->
<!-- <script src="https://www.nextzen.org/tangram/0.16/tangram.min.js"></script> -->
<script src="https://www.nextzen.org/tangram/tangram.min.js"></script>
<!-- Demo setup -->
<script>
var map = L.map('map');
var hash = new L.Hash(map);
var tangramLayer = Tangram.leafletLayer({
scene: 'scene.yaml',
attribution: '<a href="https://mapzen.com/tangram" target="_blank">Tangram</a> | © OSM contributors'
});
tangramLayer.addTo(map);
// from refill-style
// location
var url_hash = window.location.hash.slice(1).split('/'); // map location as #z/x/y
var map_start_location = [37.7784, -122.4331, 12]; // 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);
}
}
map.setView(map_start_location.slice(0, 2), map_start_location[2]);
</script>
</body>
</html>