-
Notifications
You must be signed in to change notification settings - Fork 5
/
02-DynamicTileProvider.html
92 lines (80 loc) · 3.28 KB
/
02-DynamicTileProvider.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>ptv-logistics SpatialTutorial</title>
<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 href="https://unpkg.com/[email protected]/dist/leaflet.css" rel="stylesheet">
<style>
body {
padding: 0;
margin: 0;
}
html,
body,
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="./token.js"></script>
<script>
// initialize leaflet
var map = new L.Map('map');
// center Karlsruhe
map.setView(new L.LatLng(51, 10), 9);
// create xMapServer-2 base layers
var baseLayers = createBaseLayers();
// add dymamic tile layer
var myTileLayerUrl = '02-DynamicTilesHandler.ashx?x={x}&y={y}&z={z}',
myTileLayer = new L.TileLayer(myTileLayerUrl, {
maxZoom: 20,
minZoom: 0,
zIndex: 100
});
map.addLayer(myTileLayer);
function createBaseLayers() {
if (!window.token) {
// no token defined - use xMap-1 background tlies
var url = 'https://api{s}-test.cloud.ptvgroup.com/WMS/GetTile/xmap-{profile}-bg/{x}/{y}/{z}.png'
var background = new L.TileLayer.WMS(url, {
maxZoom: 19,
minZoom: 0,
opacity: 1.0,
noWrap: true,
attribution: '<a target="_blank" href="http://www.ptvgroup.com">PTV</a>, TOMTOM',
profile: 'silkysand',
subdomains: '1234'
});
return L.layerGroup([background]).addTo(map);
} else {
var background = L.tileLayer(
'https://s0{s}-xserver2-europe-test.cloud.ptvgroup.com/services/rest/XMap/tile/{z}/{x}/{y}' +
'?storedProfile={profile}&layers=background,transport&xtok={token}', {
profile: 'silkysand',
token: window.token,
attribution: '<a target="_blank" href="http://www.ptvgroup.com">PTV</a>, TOMTOM',
subdomains: '1234',
maxZoom: 22,
pane: 'tilePane'
}).addTo(map);
var foreground = L.tileLayer(
'https://s0{s}-xserver2-europe-test.cloud.ptvgroup.com/services/rest/XMap/tile/{z}/{x}/{y}' +
'?storedProfile={profile}&layers=labels&xtok={token}', {
profile: 'silkysand',
token: window.token,
attribution: '<a target="_blank" href="http://www.ptvgroup.com">PTV</a>, TOMTOM',
subdomains: '1234',
maxZoom: 22,
zIndex: 200,
pane: 'shadowPane'
}).addTo(map);
return L.layerGroup([background, foreground]).addTo(map);
}
}
</script>
</body>
</html>