-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.js
104 lines (88 loc) · 2.59 KB
/
map.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
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
// set up the map
var map = new L.Map('map');
var lat = getUrlParameter('lat');
var lon = getUrlParameter('lon');
if(lat && lon) {
map.setView(new L.LatLng(lat, lon), 15);
var icon = L.AwesomeMarkers.icon({
prefix: 'ion',
icon: 'android-locate',
markerColor: 'red'
});
var marker = L.marker([lat, lon], {icon: icon}).addTo(map);
marker.bindPopup("You are here!");
} else {
map.fitWorld();
}
// create the tile layer with correct attribution
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='map data © <a href="http://openstreetmap.org">OpenStreetMap</a> | made by <a href="http://fraulyoner.de">fraulyoner</a>';
var osm = new L.TileLayer(osmUrl, {attribution: osmAttrib});
map.addLayer(osm);
// markers for containers
var clothesMarker = L.AwesomeMarkers.icon({
prefix: 'ion',
icon: 'tshirt',
markerColor: 'cadetblue'
});
var glassMarker = L.AwesomeMarkers.icon({
prefix: 'ion',
icon: 'wineglass',
markerColor: 'blue'
});
var batteriesMarker = L.AwesomeMarkers.icon({
prefix: 'ion',
icon: 'battery-low',
markerColor: 'orange'
});
var minZoomMessage = "Please zoom in to see the recycling containers<br/>(current zoom level is CURRENTZOOM, required is MINZOOMLEVEL)";
// OverPassAPI overlays
var clothesLayer = new L.OverPassLayer({
query: 'node["amenity"="recycling"]["recycling:clothes"="yes"]({{bbox}});out;',
markerIcon: clothesMarker,
minZoomIndicatorOptions: {
minZoomMessage: minZoomMessage
},
beforeRequest: function() {
map.spin(true);
},
afterRequest: function() {
map.spin(false);
}
});
var glassLayer = new L.OverPassLayer({
query: 'node["amenity"="recycling"]["recycling:glass"="yes"]({{bbox}});out;',
markerIcon: glassMarker,
minZoomIndicatorOptions: {
minZoomMessage: minZoomMessage
},
beforeRequest: function() {
map.spin(true);
},
afterRequest: function() {
map.spin(false);
}
});
var batteriesLayer = new L.OverPassLayer({
query: 'node["amenity"="recycling"]["recycling:batteries"="yes"]({{bbox}});out;',
markerIcon: batteriesMarker,
minZoomIndicatorOptions: {
minZoomMessage: minZoomMessage
},
beforeRequest: function() {
map.spin(true);
},
afterRequest: function() {
map.spin(false);
}
});
map.addLayer(clothesLayer);
map.addLayer(glassLayer);
map.addLayer(batteriesLayer);
// Layer control (switch on/off layers)
var overlays = {
'<i class="ion ion-battery-low"></i>': batteriesLayer,
'<i class="ion ion-tshirt"></i>': clothesLayer,
'<i class="ion ion-wineglass"></i>': glassLayer
};
L.control.layers({}, overlays, {collapsed: false}).addTo(map);