-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathcommon.js
54 lines (51 loc) · 1.59 KB
/
common.js
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
L.Google.prototype.addTo =
L.Yandex.prototype.addTo =
function(map) {
map.addLayer(this);
return this;
};
L.Yandex.prototype.getContainer =
L.Google.prototype.getContainer = function() {
return this._container;
};
L.mapbox.accessToken = 'pk.eyJ1IjoibHhiYXJ0aCIsImEiOiJFVXdYcUlvIn0.bbaHTEWlnAwGgyVwJngMdQ';
var addLayer = function(layerid, map) {
var split = layerid.split('.');
var layer = null;
switch(split[0]) {
case 'bing':
layer = new L.BingLayer('AjCTNNlzpfcDOc0G58A4Hzx1N0OGrO8IXpFj1TVqlPG7sUxc8LqXbClnVK9RLk4q');
break;
case 'google':
// split[1] can be one of:
// ROADMAP
// SATELLITE
// HYBRID
// TERRAIN
layer = new L.Google(split[1] || 'ROADMAP');
break;
case 'yandex':
layer = new L.Yandex();
break;
case 'osm':
map.attributionControl.addAttribution('<a href="http://openstreetmap.org/copyright">© OpenStreetMap contributors</a>');
layer = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
break;
default:
if (layerid.indexOf('http') === 0) {
layer = new L.TileLayer(decodeURIComponent(layerid));
} else {
layer = L.mapbox.tileLayer(layerid);
}
break;
}
return layer.addTo(map);
};
var getLayerIds = function() {
if (!location.search) {
return null;
}
return (location.search.split('?')[1] || '')
.split('/')[0]
.split('&');
};