mirror of https://github.com/aredn/aredn.git
bugfix: invalid lat/lon values when dragging marker across wrapped boundry
refs AREDN->ticket:221 Change-Id: Id60213e72428c86f51b17c9c137785e340bca3eb
This commit is contained in:
parent
8ee8fbefe0
commit
507ceed577
|
@ -224,6 +224,7 @@ if($parms{button_updatelocation})
|
||||||
{
|
{
|
||||||
# validate values
|
# validate values
|
||||||
if($parms{latitude} =~ /^([-+]?\d{1,2}([.]\d+)?)$/ and $parms{longitude} =~ /^([-+]?\d{1,3}([.]\d+)?)$/) {
|
if($parms{latitude} =~ /^([-+]?\d{1,2}([.]\d+)?)$/ and $parms{longitude} =~ /^([-+]?\d{1,3}([.]\d+)?)$/) {
|
||||||
|
if($parms{latitude} >= -90 and $parms{latitude} <= 90 and $parms{longitude} >= -180 and $parms{longitude} <= 180) {
|
||||||
# delete/define file
|
# delete/define file
|
||||||
unlink("/etc/latlon") if(-f "/etc/latlon");
|
unlink("/etc/latlon") if(-f "/etc/latlon");
|
||||||
$rcgood=open(my $ll, ">", "/etc/latlon");
|
$rcgood=open(my $ll, ">", "/etc/latlon");
|
||||||
|
@ -232,6 +233,9 @@ if($parms{button_updatelocation})
|
||||||
print $ll "$parms{longitude}\n";
|
print $ll "$parms{longitude}\n";
|
||||||
close($ll);
|
close($ll);
|
||||||
push @output, "Lat/lon updated.\n";
|
push @output, "Lat/lon updated.\n";
|
||||||
|
} else {
|
||||||
|
push @errors, "ERROR: Lat/lon values must be between -90/90 and -180/180, respectively.\n";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
push @errors, "ERROR: Lat/lon format is decimal: (ex. 30.121456 or -95.911154)\n";
|
push @errors, "ERROR: Lat/lon format is decimal: (ex. 30.121456 or -95.911154)\n";
|
||||||
}
|
}
|
||||||
|
@ -965,10 +969,10 @@ print <<EOF;
|
||||||
var marker;
|
var marker;
|
||||||
|
|
||||||
function onMapClick(e) {
|
function onMapClick(e) {
|
||||||
marker= new L.marker(e.latlng,{draggable: true, icon: dotIcon});
|
marker= new L.marker(e.latlng.wrap(),{draggable: true, icon: dotIcon});
|
||||||
map.addLayer(marker);
|
map.addLayer(marker);
|
||||||
document.getElementsByName('latitude')[0].value=e.latlng.lat.toFixed(6).toString();
|
document.getElementsByName('latitude')[0].value=e.latlng.wrap().lat.toFixed(6).toString();
|
||||||
document.getElementsByName('longitude')[0].value=e.latlng.lng.toFixed(6).toString();
|
document.getElementsByName('longitude')[0].value=e.latlng.wrap().lng.toFixed(6).toString();
|
||||||
map.off('click', onMapClick);
|
map.off('click', onMapClick);
|
||||||
marker.on('drag', onMarkerDrag);
|
marker.on('drag', onMarkerDrag);
|
||||||
}
|
}
|
||||||
|
@ -987,7 +991,7 @@ EOF
|
||||||
print <<EOF;
|
print <<EOF;
|
||||||
function onMarkerDrag(e) {
|
function onMarkerDrag(e) {
|
||||||
var m = e.target;
|
var m = e.target;
|
||||||
var p = m.getLatLng();
|
var p = m.getLatLng().wrap();
|
||||||
document.getElementsByName('latitude')[0].value=p.lat.toFixed(6).toString();
|
document.getElementsByName('latitude')[0].value=p.lat.toFixed(6).toString();
|
||||||
document.getElementsByName('longitude')[0].value=p.lng.toFixed(6).toString();
|
document.getElementsByName('longitude')[0].value=p.lng.toFixed(6).toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue