var map = null;
var geocoder = null;
var punto = null;
//var mapainiciado = false;

function initMap() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		//punto = new GLatLng(41.348374, 2.129757);
		//map.setCenter(punto, 13);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		geocoder = new GClientGeocoder();
		//mapainiciado = true;
	}
}

function addMarker(latitud,longitud,info){
	initMap();
	var point = new GLatLng(latitud,longitud)
	var icon = new GIcon();
	icon.shadow = "/recursos/imgs/shadow50.png";
	icon.iconSize = new GSize(20, 34);
	icon.shadowSize = new GSize(37, 34);
	icon.iconAnchor = point;
	icon.infoWindowAnchor = point;
	icon.infoShadowAnchor = point;
	icon.image = "/recursos/imgs/marker-red.png";
	map.addOverlay(createMarker(point, icon, info));
	map.setCenter(point,13);
	
}
function createMarker(point, icono, html) {
		var marker = new GMarker(point, {icon:icono});
		GEvent.addListener(marker, "click", function () {
			marker.openInfoWindowHtml(html);
		});
	return marker;
}
