
var Carte = {
		  map: null
}; 

Carte.redirection = function(leMarker){
	window.location.href = '/urbain/' + villes[leMarker][0];
}
Carte.marker = new Array();
 
Carte.init = function() {
	var latlng = new google.maps.LatLng(46.759,1.738);
    var myOptions = {
      zoom: 6,
      center: latlng,
      scrollwheel: false,
     
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    Carte.map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
    var image = new google.maps.MarkerImage('/icones/urbain.png',
    	      // This marker is 20 pixels wide by 32 pixels tall.
    	      new google.maps.Size(23, 23),
    	      // The origin for this image is 0,0.
    	      new google.maps.Point(0,0),
    	      // The anchor for this image is the base of the flagpole at 0,32.
    	      new google.maps.Point(11, 11));

    
    for(i=0;i<villes.length;i++){
    	latlng = new google.maps.LatLng(villes[i][1],villes[i][2]);
    	Carte.marker[i] = new google.maps.Marker({
    	        map: Carte.map,
    	        position: latlng,
    	        icon:image,
    	        draggable: false,
    	        title:villes[i][3],
    	        index: i    	     
    	});
    	
    	google.maps.event.addListener(Carte.marker[i], 'click', function() {
    		
    	    Carte.redirection(this.index);
    	});
    }
    
}
    


var villes = [
              ['aix_en_provence',43.524,5.454,'Aix-En-Provence'],
              ['amiens',49.8939183,2.2942436,'Amiens'],
              ['avignon',43.9486126,4.8059666,'Avignon'],
              ['besancon',47.2412254,6.0255656,'Besançon'],
              ['bordeaux',44.8373682,-0.5761440,'Bordeaux'],
              ['caen',49.1847122,-0.3601488,'Caen'],
              ['cergypontoise',49.0485219,2.0342372,'Cergy-Pontoise'],
              ['chalonsursaone',46.7842185,4.8529482,'Chalon-Sur-Saône'],
              ['dijon',47.3272130,5.0439875,'Dijon'],
              ['larochelle',46.1581013,-1.1536397,'La Rochelle'],
              ['lyon',45.7672990,4.8343287,'Lyon'],
              ['marseille',43.2976116,5.3810421,'Marseille'],
              ['montpellier',43.6081760,3.8794455,'Montpellier'],
              ['mulhouse',47.7494919,7.3397806,'Mulhouse'],
              ['nancy',48.684161,6.194572,'Nancy'],
              ['nantes',47.2168424,-1.5567445,'Nantes'],
              ['nice',43.7034273,7.2662656,'Nice'],
              ['orleans',47.9013866,1.9039759,'Orléans'],
              ['paris',48.8566667,2.3509871,'Paris'],
              ['perpignan',42.7015739,2.8941503,'Perpignan'],
              ['plaine_commune',48.9148234,2.3812071,'Plaine Commune'],
              ['rennes',48.1117611,-1.6802654,'Rennes'],
              ['rouen',49.4423668,1.0984924,'Rouen'],
              ['toulouse',43.6043630,1.4429513,'Toulouse'],
              ['vannes',47.6549032,-2.7595206,'Vannes']
];

$(document).ready(function(){
	Carte.init();
});

