forked from tangrams/tangram-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
121 lines (98 loc) · 3.58 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
<!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>Tangram Documentation</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2/leaflet.css" />
<style>
body {
margin: 0px;
border: 0px;
padding: 0px;
}
#map {
background: rgba(0, 0, 0, 0);
height: 100%;
width: 100%;
position: absolute;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- 3rd party libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2/leaflet.js"></script>
<!-- bog-standard leaflet URL hash -->
<script src="src/leaflet-hash.js"></script>
<!-- End of 3rd party libraries -->
<!-- Main tangram library -->
<script src="https://mapzen.com/tangram/0.11/tangram.min.js"></script>
<!-- Demo module -->
<script type="text/javascript">
map = (function () {
'use strict';
var map_start_location = [40.70531887544228, -74.00976419448853, 16];
/*** URL parsing ***/
// leaflet-style URL hash pattern:
// ?style.yaml#[zoom],[lat],[lng]
var url_hash = window.location.hash.slice(1).split('/');
if (url_hash.length == 3) {
map_start_location = [url_hash[1],url_hash[2], url_hash[0]];
// convert from strings
map_start_location = map_start_location.map(Number);
}
var style_file = 'scene.yaml';
var url_search = window.location.search.slice(1);
if (url_search.length > 0) {
var ext = url_search.lastIndexOf('yaml');
if (ext > -1) {
style_file = url_search.substr(0, ext + 4);
}
}
/*** Map ***/
var map = L.map('map',
{'keyboardZoomOffset': .05}
);
var layer = Tangram.leafletLayer({
scene: style_file,
attribution: '<a href="https://mapzen.com/tangram" target="_blank">Tangram</a> | © OSM contributors | <a href="https://mapzen.com/" target="_blank">Mapzen</a>'
});
window.layer = layer;
var scene = layer.scene;
window.scene = scene;
map.setView(map_start_location.slice(0, 2), map_start_location[2]);
var hash = new L.Hash(map);
window.addEventListener('load', function () {
// Scene initialized
layer.addTo(map);
});
return map;
}());
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-47035811-1', 'auto');
ga('send', 'pageview');
</script>
<!-- Mapzen map UI components -->
<script src="//mapzen.com/common/ui/mapzen-ui.min.js"></script>
<script>
MPZN.bug({
name: 'Tangram docs-assets',
link: 'https://mapzen.com/projects/tangram',
tweet: 'Tangram demo from @mapzen',
repo: 'https://github.com/tangrams/tangram/'
});
</script>
</body>
</html>