forked from ptv-logistics/SpatialTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
03-TilesAndGeography.html
84 lines (72 loc) · 2.73 KB
/
03-TilesAndGeography.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Leaflet NonTiledLayer Example</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="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" rel="stylesheet">
<style>
body {
padding: 0;
margin: 0;
}
html,
body,
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="./NonTiledLayer.js"></script>
<script src="./NonTiledLayer.WMS.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), 7);
// using the xmap WMS servlet
var xMapUrl = 'https://xmap-eu-n-test.cloud.ptvgroup.com';
var xMapAttribution = '<a href="http://www.ptvgroup.com">PTV<\/a>, HERE';
// add the xServer layers
// set the layer groups for default and sandbox
var baseLayers = {
"PTV classic": getLayers(xMapUrl + '/WMS/WMS', "", xMapAttribution),
"PTV sandbox": getLayers(xMapUrl + '/WMS/WMS', "sandbox", xMapAttribution).addTo(map),
"PTV silkysand": getLayers(xMapUrl + '/WMS/WMS', "silkysand", xMapAttribution)
};
L.control.layers(baseLayers, null).addTo(map);
// add dymamic tile layer
var myTileLayerUrl = '03-TilesAndGeographyHandler.ashx?x={x}&y={y}&z={z}',
myTileLayer = new L.TileLayer(myTileLayerUrl, {
maxZoom: 20, minZoom: 0, zIndex: 100
});
map.addLayer(myTileLayer);
// returns a layer group for xmap back- and foreground layers
function getLayers(url, style, attribution) {
var background = new L.TileLayer.WMS(url, {
maxZoom: 19,
minZoom: 0,
opacity: 1.0,
noWrap: true,
layers: style? 'xmap-' + style + '-bg' : 'xmap-ajaxbg',
format: 'image/gif',
transparent: false,
attribution: attribution
});
var foreground = new L.NonTiledLayer.WMS(url + '?xtok=' + token, {
zIndex: 0,
opacity: 1.0,
layers: style? 'xmap-' + style + '-fg' : 'xmap-ajaxfg',
format: 'image/gif',
transparent: true,
attribution: attribution
});
return L.layerGroup([background, foreground]);
}
</script>
</body>
</html>