|
@@ -15,7 +15,19 @@
|
|
|
q: $(this).val()
|
|
|
}
|
|
|
}).done(function (data) {
|
|
|
- googleSearchDirectionAndShowMaps(data.results[0].address);
|
|
|
+ var extradata = null;
|
|
|
+ if (data.results[0].location) {
|
|
|
+ extradata = JSON.parse(data.results[0].location.extraData);
|
|
|
+ if (extradata.lat == undefined || extradata.lng == undefined) {
|
|
|
+ extradata = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (extradata === null) {
|
|
|
+ googleSearchDirectionAndShowMaps(data.results[0].address);
|
|
|
+ } else {
|
|
|
+ $('input[class="search-input"]').val(data.results[0].address);
|
|
|
+ drawMap(extradata.lat, extradata.lng);
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
});
|
|
@@ -25,16 +37,14 @@
|
|
|
* @param address Contiene la direccion.
|
|
|
*/
|
|
|
function googleSearchDirectionAndShowMaps(address) {
|
|
|
- $('input[class="search-input"]').val(address + ", Gálvez, Santa Fe, Argentina");
|
|
|
+ $('input[class="search-input"]').val(address);
|
|
|
$.ajax({
|
|
|
- url: "http://maps.googleapis.com/maps/api/geocode/json?address='" + address + ", Gálvez, Santa Fe, Argentina'",
|
|
|
+ url: "http://maps.googleapis.com/maps/api/geocode/json?address='" + address + "'",
|
|
|
type: "POST"
|
|
|
}).done(function (res) {
|
|
|
if (res != undefined) {
|
|
|
if (res.status == google.maps.GeocoderStatus.OK) {
|
|
|
- loc = new L.latLng(res.results[0].geometry.location.lat, res.results[0].geometry.location.lng);
|
|
|
- drawMarker();
|
|
|
- setDataValue();
|
|
|
+ drawMap(res.results[0].geometry.location.lat, res.results[0].geometry.location.lng);
|
|
|
} else {
|
|
|
alert(res.status);
|
|
|
}
|
|
@@ -48,6 +58,17 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Funcion que dibuja el mapa.
|
|
|
+ * @param lat
|
|
|
+ * @param lng
|
|
|
+ */
|
|
|
+ function drawMap(lat, lng) {
|
|
|
+ loc = new L.latLng(lat, lng);
|
|
|
+ drawMarker();
|
|
|
+ setDataValue();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Busca y calcula la distancia a los nap y la cantidad de puertos libres.
|
|
|
*/
|