Added reverse geocoding for location save
rodzic
b75357834f
commit
46153c7bec
|
@ -125,13 +125,13 @@ var hlTimeout = 5000; // high latency
|
||||||
<form name="location_save_form" id="location_save_form">
|
<form name="location_save_form" id="location_save_form">
|
||||||
<table name="req_table" id="req_table">
|
<table name="req_table" id="req_table">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Latitude: </td><td><input type="text" name="req_lat" id="req_lat" size="10"></td>
|
<td>Latitude: </td><td><input type="text" name="req_lat" id="req_lat" size="15"></td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td>Longitude: </td><td><input type="text" name="req_lon" id="req_lon" size="10"></td>
|
<td>Longitude: </td><td><input type="text" name="req_lon" id="req_lon" size="15"></td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td>Altitude: </td><td><input type="text" name="req_alt" id="req_alt" size="10"></td>
|
<td>Altitude: </td><td><input type="text" name="req_alt" id="req_alt" size="15"></td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td>Site Name: </td><td><input type="text" name="req_name" id="req_name" size="10"></td>
|
<td>Site Name: </td><td><input type="text" name="req_name" id="req_name" size="15"></td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td></td><td><input type="button" value="Save" name="submit" id="req_sub_btn"></td>
|
<td></td><td><input type="button" value="Save" name="submit" id="req_sub_btn"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -612,6 +612,10 @@ function setupEventHandlers() {
|
||||||
var req_name = $("#req_name").val();
|
var req_name = $("#req_name").val();
|
||||||
var cookie_name = "cusf_predictor";
|
var cookie_name = "cusf_predictor";
|
||||||
var locations_limit = 5;
|
var locations_limit = 5;
|
||||||
|
var name_limit = 20;
|
||||||
|
|
||||||
|
// Check the length of the name
|
||||||
|
if ( req_name.length > name_limit ) req_name = req_name.substr(0, name_limit);
|
||||||
|
|
||||||
// Now let's init the cookie
|
// Now let's init the cookie
|
||||||
$.Jookie.Initialise(cookie_name, 99999999);
|
$.Jookie.Initialise(cookie_name, 99999999);
|
||||||
|
@ -715,11 +719,15 @@ function setupEventHandlers() {
|
||||||
$("#location_save_local").fadeOut();
|
$("#location_save_local").fadeOut();
|
||||||
});
|
});
|
||||||
$("#req_open").click(function() {
|
$("#req_open").click(function() {
|
||||||
$("#req_lat").val($("#lat").val());
|
var lat = $("#lat").val();
|
||||||
$("#req_lon").val($("#lon").val());
|
var lon = $("#lon").val();
|
||||||
|
$("#req_lat").val(lat);
|
||||||
|
$("#req_lon").val(lon);
|
||||||
$("#req_alt").val($("#initial_alt").val());
|
$("#req_alt").val($("#initial_alt").val());
|
||||||
// this is bad, use a geocoder to guess it
|
// this is bad, use a geocoder to guess it
|
||||||
$("#req_name").val("Unnamed");
|
$("#req_name").val("Unnamed");
|
||||||
|
appendDebug("Trying to reverse geo-code the launch point");
|
||||||
|
rvGeocode(lat, lon, "req_name");
|
||||||
$("#location_save").fadeIn();
|
$("#location_save").fadeIn();
|
||||||
});
|
});
|
||||||
$(".tipsyLink").tipsy({fade: true});
|
$(".tipsyLink").tipsy({fade: true});
|
||||||
|
@ -728,6 +736,23 @@ function setupEventHandlers() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rvGeocode(lat, lon, fillField) {
|
||||||
|
var geocoder = new google.maps.Geocoder();
|
||||||
|
var latlng = new google.maps.LatLng(parseFloat(lat), parseFloat(lon));
|
||||||
|
var coded = "Unnamed";
|
||||||
|
geocoder.geocode({'latLng': latlng}, function(results, status) {
|
||||||
|
if ( status == google.maps.GeocoderStatus.OK ) {
|
||||||
|
// Successfully got rv-geocode information
|
||||||
|
appendDebug("Got a good response from the geocode server");
|
||||||
|
coded = results[1].address_components[1].short_name;
|
||||||
|
} else {
|
||||||
|
appendDebug("The rv-geocode failed: " + status);
|
||||||
|
}
|
||||||
|
// Now write the value to the field
|
||||||
|
$("#"+fillField+"").val(coded);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function constructCookieLocationsTable(cookie_name) {
|
function constructCookieLocationsTable(cookie_name) {
|
||||||
var t = "";
|
var t = "";
|
||||||
t += "<table border='0'>";
|
t += "<table border='0'>";
|
||||||
|
|
Ładowanie…
Reference in New Issue