﻿function cargar_mapa()
{
	if (GBrowserIsCompatible())
	{
		//Creacion del mapa
		var mapa = new GMap2(document.getElementById("map"));

		mapa.setCenter(new GLatLng(37.17515,-4.596153), 15);

		//Controles de zoom y tipos de vista
		mapa.addControl(new GLargeMapControl());
		mapa.addControl(new GMapTypeControl());
		mapa.setMapType(G_HYBRID_MAP);

		//Icono y sus caracteristicas para las marcas
		var icono_marca = new GIcon();

		icono_marca.image = "img/casa.png";
		icono_marca.shadow = "img/sombra.png";
		icono_marca.iconSize = new GSize(16, 16);
		icono_marca.shadowSize = new GSize(16, 16);
		icono_marca.iconAnchor = new GPoint(0, 0);
		icono_marca.infoWindowAnchor = new GPoint(2, 2);
		icono_marca.infoShadowAnchor = new GPoint(16, 16);

		//Funcion para insertar una marca en el mapa
		function crear_marca(localizacion)
		{
			//Configuramos la marca
			markerOptions = { icon:icono_marca };
			var marca = new GMarker(localizacion, markerOptions);

			GEvent.addListener(marca, "click",
			function()
			{
				var nombre_sitio = '<strong>Jardines del Cortijuelo</strong>';
				var datos_ubicacion = '<strong>Carretera de Alameda MA-6415 Km 3,5</strong>-<strong>Antequera</strong> (M&aacute;laga)<br />GPS: +37&deg; 10\' 30.54&quot;, -4&deg; 35\' 46.15&quot;';
				var output = "<div id='bocadillo'>"+ nombre_sitio +"<br />"+ datos_ubicacion + "<\/div>";
				marca.openInfoWindowHtml(output);

			}
			);

			return marca;
		}

		var posicion = new GLatLng(37.17515,-4.596153);
		mapa.addOverlay(crear_marca(posicion));
	}
}
