-
Notifications
You must be signed in to change notification settings - Fork 2
/
raster-tiles.html
104 lines (94 loc) · 3.8 KB
/
raster-tiles.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
<!DOCTYPE html>
<html>
<head>
<title>leaflet-ptv-developer example</title>
<meta charset="utf-8" />
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" />
<style>
body {
padding: 0;
margin: 0;
}
html,
body,
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript" src="https://unpkg.com/leaflet@1.9.3/dist/leaflet-src.js"></script>
<script type="text/javascript" src="./dist/leaflet-ptv-developer-src.js"></script>
<script type="text/javascript" src="./api-key.js"></script>
<script>
var coordinate = L.latLng(49.012, 8.4044); // Karlsruhe, Germany
var tileSize = 256; // 512 or 1024 are also possible
var zoomOffset = tileSize === 256 ? 0 : tileSize === 512 ? -1 : - 2;
var map = L.map('map', {
fullscreenControl: true
}).setView(coordinate, 17);
// insert a standard PTV Developer raster base tiles.
var basemapLayer = L.tileLayer(
'https://api.myptv.com/rastermaps/v1/image-tiles/{z}/{x}/{y}' +
'?apiKey={token}&layers={layers}&size={tileSize}', {
attribution: '© ' + new Date().getFullYear() + ' PTV Group, HERE, TomTom',
layers: 'background,transport',
tileSize: tileSize,
token: window.apiKey,
maxZoom: 22,
zoomOffset: zoomOffset,
pane: 'tilePane'
}).addTo(map);
// create a new pane for our overlay layer
map.createPane('clickableTiles');
map.getPane('clickableTiles').style.zIndex = 500;
// insert clickable restrictions layer.
var restrictionsLayer = L.tileLayer.ptvDeveloper(
'https://api.myptv.com/rastermaps/v1/data-tiles/{z}/{x}/{y}' +
'?apiKey={token}&layers={layers}&size={tileSize}', {
tileSize: tileSize,
layers: 'restrictions',
token: window.apiKey,
maxZoom: 22,
zoomOffset: zoomOffset,
pane: 'clickableTiles'
}).addTo(map);
// insert clickable traffic incident layer.
var trafficIncidentsLayer = L.tileLayer.ptvDeveloper(
'https://api.myptv.com/rastermaps/v1/data-tiles/{z}/{x}/{y}' +
'?apiKey={token}&layers={layers}&size={tileSize}', {
tileSize: tileSize,
layers: 'trafficIncidents',
token: window.apiKey,
maxZoom: 22,
zoomOffset: zoomOffset,
pane: 'clickableTiles'
})
// insert label layer on the top
var labelsLayer = L.tileLayer(
'https://api.myptv.com/rastermaps/v1/image-tiles/{z}/{x}/{y}' +
'?apiKey={token}&layers={layers}&size={tileSize}', {
tileSize: tileSize,
layers: 'labels',
token: window.apiKey,
maxZoom: 22,
zoomOffset: zoomOffset,
pane: 'clickableTiles'
}).addTo(map);
// add a layer switcher
var layers = {
"Base Map": basemapLayer,
"Restrictions": restrictionsLayer,
"Traffic Incidents": trafficIncidentsLayer,
"Labels": labelsLayer
};
L.control.layers({}, layers, {
position: 'bottomleft',
autoZIndex: false
}).addTo(map);
</script>
</body>
</html>