mirror of https://github.com/aredn/aredn.git
feature: find me using browser location services
This commit is contained in:
parent
7314a868e5
commit
38d2c1fc8b
|
@ -481,6 +481,26 @@ print "<body><center>\n";
|
||||||
print "
|
print "
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
function findLocation() {
|
||||||
|
navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
function foundLocation(position)
|
||||||
|
{
|
||||||
|
var jlat = position.coords.latitude;
|
||||||
|
var jlon = position.coords.longitude;
|
||||||
|
var latlng = L.latLng(jlat, jlon);
|
||||||
|
marker.setLatLng(latlng);
|
||||||
|
map.setView(latlng,13);
|
||||||
|
|
||||||
|
document.getElementsByName('latitude')[0].value=jlat.toFixed(6).toString();
|
||||||
|
document.getElementsByName('longitude')[0].value=jlon.toFixed(6).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function noLocation()
|
||||||
|
{
|
||||||
|
alert('Could not find location. Try pinning it on the map.');
|
||||||
|
}
|
||||||
function updDist(x) {
|
function updDist(x) {
|
||||||
var u = document.getElementById('distance_unit_text').innerHTML;
|
var u = document.getElementById('distance_unit_text').innerHTML;
|
||||||
var xc= calcDistance(x,u);
|
var xc= calcDistance(x,u);
|
||||||
|
@ -503,13 +523,13 @@ function updDistUnit(u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcDistance(x, u) {
|
function calcDistance(x, u) {
|
||||||
var dv=0;
|
var dv=0.0;
|
||||||
if(u=='kilometers') {
|
if(u=='kilometers') {
|
||||||
dv=x*1000;
|
dv=x*1000;
|
||||||
} else {
|
} else {
|
||||||
dv=x/0.00062137;
|
dv=x/0.00062137;
|
||||||
}
|
}
|
||||||
dv=Math.round(dv);
|
dv=Math.ceil(dv);
|
||||||
return dv;
|
return dv;
|
||||||
}";
|
}";
|
||||||
|
|
||||||
|
@ -992,6 +1012,9 @@ print "<table cellpadding=5 border=0><tr><th colspan=4>Optional Settings</th></t
|
||||||
print "<tr><td colspan=4><hr /></td></tr>";
|
print "<tr><td colspan=4><hr /></td></tr>";
|
||||||
print "<tr><td align=left>Latitude</td><td><input type=text name=latitude size=10 value='$lat' title='Latitude value (in decimal) (ie. 30.312354)' /></td>";
|
print "<tr><td align=left>Latitude</td><td><input type=text name=latitude size=10 value='$lat' title='Latitude value (in decimal) (ie. 30.312354)' /></td>";
|
||||||
print "<td align='right' colspan='2'>";
|
print "<td align='right' colspan='2'>";
|
||||||
|
|
||||||
|
print "<button type='button' id='findlocation' value='findloc' onClick='findLocation();'>Find Me!</button> ";
|
||||||
|
|
||||||
if($pingOk)
|
if($pingOk)
|
||||||
{
|
{
|
||||||
print "<button type='button' id='hideshowmap' value='show' onClick='toggleMap(this);'>Show Map</button> ";
|
print "<button type='button' id='hideshowmap' value='show' onClick='toggleMap(this);'>Show Map</button> ";
|
||||||
|
@ -1094,14 +1117,3 @@ EOF
|
||||||
print "</body>\n";
|
print "</body>\n";
|
||||||
print "</html>\n";
|
print "</html>\n";
|
||||||
|
|
||||||
sub DEBUGEXIT()
|
|
||||||
{
|
|
||||||
my ($text) = @_;
|
|
||||||
http_header();
|
|
||||||
html_header("$node setup", 1);
|
|
||||||
print "DEBUG-";
|
|
||||||
print $text;
|
|
||||||
print "</body>";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue