var map;

function MapTypeToLetter(mapType){
		switch(mapType){
			case G_NORMAL_MAP:return'M';
			case G_SATELLITE_MAP:return'S';
			case G_HYBRID_MAP:return'H';
		}
}

function Inicio() {          
	if (GBrowserIsCompatible()) {
		//Creamos el mapa con sus controles
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
	 	  
		//Creamos el icono
		var icon = new GIcon();
		icon.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
        icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(12, 20);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);
	  
		function createMarker(point, texto) {
               var marker = new GMarker(point, icon, false);
			   
			   if (texto != ''){
			       GEvent.addListener(marker, 'mouseover', function(){marker.openInfoWindowHtml(texto);});
			   }
               return marker;
		}

		//Posicion inicial
		var punto_inicial = new GLatLng(1, 1);
		map.setCenter(punto_inicial, 10);
		   	
		var punto_inicial = new GLatLng(28.545925723233477,-15.787353515625);
		map.setCenter(punto_inicial, 7);
      
		map.setMapType(G_HYBRID_MAP);
		map.enableDoubleClickZoom();
		
		geocoder = new GClientGeocoder();
	}
}


//Mostramos la calle localizada en el mapa
function showAddress(calle) {
	if (geocoder) {
        geocoder.getLatLng(
          calle,
          function(point) {
			$('#capa_cargando').hide('fast');
            if (!point) {
              alert("La calle no ha sido encontrada.");
            } else {
			  map.clearOverlays();
              map.setCenter(point, 17);
              var marker = new GMarker(point);
              map.addOverlay(marker);
			  
			  var trozos = calle.split(",");
              marker.openInfoWindowHtml('<strong>' + trozos[0] + '</strong><br />' + trozos[1] + '<br />');
            }
          }
        );
	}
}

// /////////////////////////////////////////////////////////////////////////////////////

