-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaflet.groupedlayercontrol.html
152 lines (121 loc) · 5.72 KB
/
leaflet.groupedlayercontrol.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!doctype html>
<html>
<head>
<title>Leaflet GroupedLayerControl</title>
<link rel="stylesheet" href="assets/leaflet-0.7.3/leaflet.css">
<link rel="stylesheet" href="assets/leaflet.groupedlayercontrol/leaflet.groupedlayercontrol.css">
<style type="text/css">
html,
body,
#map {
margin: 0px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="assets/jquery-1.11.1.min.js"></script>
<script src="assets/leaflet-0.7.3/leaflet.js"></script>
<script src="assets/leaflet.groupedlayercontrol/leaflet.groupedlayercontrol.js"></script>
<script>
var BingLayer = L.TileLayer.extend({
getTileUrl: function(tilePoint) {
this._adjustTilePoint(tilePoint);
return L.Util.template(this._url, {
s: this._getSubdomain(tilePoint),
q: this._quadKey(tilePoint.x, tilePoint.y, this._getZoomForUrl())
});
},
_quadKey: function(x, y, z) {
var quadKey = [];
for (var i = z; i > 0; i--) {
var digit = '0';
var mask = 1 << (i - 1);
if ((x & mask) != 0) {
digit++;
}
if ((y & mask) != 0) {
digit++;
digit++;
}
quadKey.push(digit);
}
return quadKey.join('');
}
});
var layerBA = new BingLayer('http://t{s}.tiles.virtualearth.net/tiles/a{q}.jpeg?g=2732', {
maxZoom: 19,
subdomains: ['0', '1', '2', '3', '4'],
attribution: '© <a href="http://bing.com/maps">Bing Maps</a>'
});
var layerOSM = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
zIndex: -1,
attribution: '© Map Data <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors'
});
var layerMapQuestOSM = L.tileLayer("http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png", {
maxZoom: 19,
zIndex: -1,
subdomains: ["otile1", "otile2", "otile3", "otile4"],
attribution: '© Tiles courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a>. © Map data <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> contributors'
});
var layerTFL = L.tileLayer('http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png', {
maxZoom: 18,
zIndex: -1,
attribution: '© <a href="http://www.opencyclemap.org">OpenCycleMap</a>, © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
});
var layerMSHyb = L.tileLayer('http://openmapsurfer.uni-hd.de/tiles/hybrid/x={x}&y={y}&z={z}', {
maxZoom: 19,
zIndex: -1,
attribution: 'Data © <a href="http://www.openstreetmap.org/copyright/en">OSM</a> contributors (ODbL), rendering ' +
'<a href="http://giscience.uni-hd.de/" target="_blank">GIScience Research Group @ University of Heidelberg</a>'
});
var layerMapBoxImagery = L.tileLayer('http://{s}.tiles.mapbox.com/v4/openstreetmap.map-inh7ifmo/{z}/{x}/{y}.png?access_token=pk.eyJ1Ijoib3BlbnN0cmVldG1hcCIsImEiOiJhNVlHd29ZIn0.ti6wATGDWOmCnCYen-Ip7Q', {
maxZoom: 17,
zIndex: -1,
attribution: 'Data © <a href="http://www.openstreetmap.org/copyright/en">OSM</a> contributors (ODbL), rendering ' +
'<a href="http://giscience.uni-hd.de/" target="_blank">GIScience Research Group @ University of Heidelberg</a>'
});
var layerOSMTopo = L.tileLayer('http://opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 16,
zIndex: -1,
attribution: 'Map Data: © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a>-Mitwirkende, <a href="http://viewfinderpanoramas.org">SRTM</a> | Display Map: © <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
});
var layerEmpty = L.tileLayer('assets/img/blank.png', {
maxZoom: 19,
zIndex: -1,
});
var layerOSMGPSTrack = L.tileLayer('http://{s}.gps-tile.openstreetmap.org/lines/{z}/{x}/{y}.png', {
maxZoom: 18,
zIndex: 1,
attribution: '© Tracks <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors'
});
var map = new L.Map('map', {
minZoom: 13,
maxZoom: 19,
layers: [layerTFL]
}).setView([50.0658, 35.1658], 14);
var baseLayers = {
"Thunderforest Landscape": layerTFL,
"MapBox Imagery": layerMapBoxImagery,
"OpenStreetMap": layerOSM,
"MapQuest OSM": layerMapQuestOSM,
"OpenTopoMap": layerOSMTopo,
"Bing Aerial": layerBA,
"Empty Layer": layerEmpty
};
var LayerControlBase = L.control.groupedLayers(baseLayers, {}, {
collapsed: false
});
var LayerControlServices = L.control.groupedLayers({}, {}, {
collapsed: false
});
LayerControlServices.addOverlay(layerOSMGPSTrack, "OSM GPS Tracks", "Custom Layers");
LayerControlBase.addTo(map);
LayerControlServices.addTo(map);
$('.leaflet-top.leaflet-right .leaflet-control-layers').css('width', '178px');
</script>
</body>
</html>