-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.js
33 lines (28 loc) · 1009 Bytes
/
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
map = L.map('map', {
center: [0, 0],
zoom: 18,
maxZoom: 19,
minZoom: 5,
detectRetina: true,
zoomControl: false
});
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.control.zoom({
position: 'bottomright'
}).addTo(map);
L.control.scale({position: 'bottomleft'}).addTo(map);
function updateMap (data) {
if (data.type == 'node') {
ll = new L.LatLng(data.lat, data.lon);
}
else {
ll = new L.LatLng(data.center.lat, data.center.lon);
}
map.setView(ll);
L.marker(ll).addTo(map);
map.attributionControl._attributions = {};
map.attributionControl.addAttribution('© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors | ' +
'<a href="https://www.openstreetmap.org/note/new#map=18/' + data.lat + '/' + data.lon + '" target="_blank">Report a map error</a>')
}