/* 
NO BORRE NI CAMBIE NADA DE ESTE ARCHIVO
O TODO DEJARA DE FUNCIONAR
*/
var map;
var geocoder;
var address;

function buscar_gps() {
	var deg_1 = $('lat1').value;
	var min_1 = $('lat2').value;
	var deg_2 = $('lon1').value;
	var min_2 = $('lon2').value;
	var total_1 = (deg_1*1.0) + min_1/60.0;
	var total_2 = (deg_2*1.0) + min_2/60.0;	
	if (total_1 > 0) { total_1 = (total_1 * -1); }
	if (total_2 > 0) { total_2 = (total_2 * -1); }
	point = new GLatLng(total_1, total_2);
	getAddress(map, point);
}
function buscar_standard() {
	var total_1 = $('lat1_s').value;
	var total_2 = $('lon1_s').value;
	if (total_1 > 0) { total_1 = (total_1 * -1); }
	if (total_2 > 0) { total_2 = (total_2 * -1); }
	point = new GLatLng(total_1, total_2);
	getAddress(map, point);
}

function initialize() {
  map = new GMap2(document.getElementById("map_canvas"));
  map.setCenter(new GLatLng(-34.6541116666667, -58.4968583333333), 15);
  map.addControl(new GLargeMapControl3D);
  map.addControl(new GMapTypeControl);
  geocoder = new GClientGeocoder();
}

function getAddress(overlay, latlng) {
  if (latlng != null) {
    address = latlng;
    geocoder.getLocations(latlng, showAddress);
  }
}

function showAddress(response) {
  map.clearOverlays();
  if (!response || response.Status.code != 200) {
    alert("Coordenadas incorrectas. No se encontro la locacion.");
  } else {
    place = response.Placemark[0];
    point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
    marker = new GMarker(point);
	map.setCenter(point, 15);
    map.addOverlay(marker);
	$('mostrar_direccion').innerHTML = place.address;
  }
}