mirror of https://github.com/aredn/aredn.git
parent
205f6e4ad8
commit
44f7f43abb
|
@ -1,10 +1,11 @@
|
|||
#!/bin/sh
|
||||
#check for old default map tiles and change to the new map tiles if req'd
|
||||
#will not change existing custom entries.
|
||||
OLDTILES='http://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiazVkbHEiLCJhIjoiY2lqMnlieTM4MDAyNXUwa3A2eHMxdXE3MiJ9.BRFvx4q2vi70z5Uu2zRYQw'
|
||||
NEWTILES='http://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg'
|
||||
OLDTILES_1='http://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiazVkbHEiLCJhIjoiY2lqMnlieTM4MDAyNXUwa3A2eHMxdXE3MiJ9.BRFvx4q2vi70z5Uu2zRYQw'
|
||||
OLDTILES_2='http://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg'
|
||||
NEWTILES='http://tile.openstreetmap.org/{z}/{x}/{y}.png'
|
||||
MAPTILESERVER=$(/sbin/uci -c /etc/config.mesh get aredn.@map[0].maptiles)
|
||||
if [ "$MAPTILESERVER" = "$OLDTILES" ]; then
|
||||
if [ "$MAPTILESERVER" = "$OLDTILES_1" -o "$MAPTILESERVER" = "$OLDTILES_2" ]; then
|
||||
/sbin/uci -c /etc/config.mesh set aredn.@map[0].maptiles="$NEWTILES"
|
||||
/sbin/uci -c /etc/config.mesh commit aredn
|
||||
fi
|
||||
|
|
|
@ -844,19 +844,18 @@ function loadScript(url, callback) {
|
|||
|
||||
var map;
|
||||
var marker;
|
||||
var dotIcon;
|
||||
|
||||
var leafletLoad = function() {
|
||||
map = L.map('map').setView([0.0, 0.0], 1);
|
||||
var dotIcon = L.icon({iconUrl: '/dot.png'});
|
||||
dotIcon = L.icon({iconUrl: '/dot.png'});
|
||||
]])
|
||||
html.print("L.tileLayer('" .. maptiles .. "',")
|
||||
html.print([[
|
||||
{
|
||||
maxZoom: 18,
|
||||
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
|
||||
'<a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>, ' +
|
||||
'Imagery ©<a href="http://stamen.com">Stamen Design</a>',
|
||||
id: 'mapbox.streets'
|
||||
attribution: 'Map data and images © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
|
||||
'<a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>'
|
||||
}).addTo(map);
|
||||
]])
|
||||
|
||||
|
@ -873,11 +872,15 @@ html.print([[
|
|||
}
|
||||
|
||||
function onMapClick(e) {
|
||||
if (marker) {
|
||||
marker.setLatLng(e.latlng.wrap());
|
||||
}
|
||||
else {
|
||||
marker = new L.marker(e.latlng.wrap(),{draggable: true, icon: dotIcon});
|
||||
map.addLayer(marker);
|
||||
}
|
||||
document.getElementsByName('latitude')[0].value=e.latlng.wrap().lat.toFixed(6).toString();
|
||||
document.getElementsByName('longitude')[0].value=e.latlng.wrap().lng.toFixed(6).toString();
|
||||
map.off('click', onMapClick);
|
||||
marker.on('drag', onMarkerDrag);
|
||||
}
|
||||
|
||||
|
@ -908,7 +911,13 @@ function foundLocation(position) {
|
|||
// try to update the map if Javascript libs have been loaded
|
||||
if (typeof L != 'undefined') {
|
||||
var latlng = L.latLng(jlat, jlon);
|
||||
if (marker) {
|
||||
marker.setLatLng(latlng);
|
||||
}
|
||||
else {
|
||||
marker = new L.marker(latlng.wrap(),{draggable: true, icon: dotIcon});
|
||||
map.addLayer(marker);
|
||||
}
|
||||
map.setView(latlng,13);
|
||||
}
|
||||
}
|
||||
|
@ -919,11 +928,9 @@ function noLocation() {
|
|||
try {
|
||||
const json = JSON.parse(this.responseText);
|
||||
foundLocation({ coords: { latitude: json.lat, longitude: json.lon }})
|
||||
return;
|
||||
}
|
||||
catch (_) {
|
||||
}
|
||||
alert('Could not find location. Try pinning it on the map.');
|
||||
});
|
||||
req.open("GET", "http://ip-api.com/json");
|
||||
req.send();
|
||||
|
|
Loading…
Reference in New Issue