//Construction de l'image des points
var baseIcon = new GIcon();
baseIcon.image = "/img/map/map.png";
baseIcon.iconSize = new GSize(60, 60);
baseIcon.iconAnchor = new GPoint(30, 30);
baseIcon.infoWindowAnchor = new GPoint(30, 30);

function load() {
	if (!GBrowserIsCompatible()) {
		return false;
	}
    var map = new GMap2(document.getElementById("map"));
	//map.disableDragging();
    //map.addControl(new GSmallMapControl());
    //map.addControl(new GMapTypeControl());
	map.setCenter(new GLatLng(46.98774725646565, -1.3458251953125), 8);
    // Creates a marker at the given point with the given number label
    function createMarker(point, txt, url, index) {
        // Construction du texte
		var url = '/plan-maison-construction/plan-maison-construction-'+url+'.html';
        var texte = '<div class="txt_map"><img src="/img/logo.gif" alt="Maison Valtéa" />' +
					'<div>Pour visualiser nos annonces de terrains sur la zone géographique de <strong><big>' +
					'<a href="'+url+'">' + txt + '</a></big></strong><br /> <a href="'+url+'">cliquez ici</a></div></div>';
        var icon = new GIcon(baseIcon);

        // Création du marker avec le point et l'icone
        var marker = new GMarker(point, icon);
        marker.url = url;
        // Fonction de gestion du click sur le point
        GEvent.addListener(marker, "click", function(txt) {
            //marker.openInfoWindowHtml(texte);
			location.href = this.url;
        });
        return marker;
    }
	var correction_lat = 0.15;
	for (var i = 0; i < ville.length; i++) {
		var point = new GLatLng(ville[i][1]+correction_lat, ville[i][2]);
		map.addOverlay(createMarker(point, ville[i][0], ville[i][3], i));
	}
}

var ville = new Array(
				new Array('Les Herbiers',46.869580496513265,-1.017608642578125, 'les-herbiers'),
				new Array('Parthenay',46.64755071082884,-0.24993896484375, 'parthenay'),
				new Array('Ancenis',47.37370965616847,-1.1817169189453125, 'ancenis'),
				new Array('Châteauneuf-sur-Sarthe',47.68341892265674,-0.484771728515625, 'ch%E2teauneuf-sur-sarthe'),
				new Array('Segré',47.686192456758505,-0.8734130859375, 'segr%E9'),
				new Array('Cholet',47.060299719543764,-0.88165283203125, 'cholet'),
				new Array('Angers',47.47034215501909,-0.5431365966796875, 'angers'),
				new Array('Luçon',46.458200503067076,-1.1693572998046875, 'lu%E7on'),
				new Array('Fontenay-le-Comte',46.464822363804686,-0.8013153076171875, 'fontenay-le-comte'),
				new Array('Montaigu',46.9755675083387,-1.318359375, 'montaigu'),
				new Array('Niort',46.32417161725691,-0.462799072265625, 'niort'),
				new Array('Chateaubriant',47.715767644882284,-1.3794708251953125, 'chateaubriant'),
				new Array('Bressuire',46.83671012836047,-0.493011474609375, 'bressuire'),
				new Array('Thouars',46.98118927533914,-0.2135467529296875, 'thouars'),
				new Array('La Roche sur Yon',46.67394106549699,-1.43096923828125, 'la-roche-sur-yon'),
				new Array('Nantes',47.21490427494709,-1.5525054931640625, 'nantes'),
				new Array('St Nazaire',47.278763162321695,-2.2185516357421875, 'st-nazaire'),
				new Array('Redon',47.65475043477393,-2.0853424072265625, 'redon'),
				new Array('Les Sables d\'Olonne',46.497919586990044,-1.7694854736328125, 'les-sables-d%27olonne')
			);

