//<![CDATA[
var map = null;
var geocoder = null;
/* définition d'une classe d'icône */
var icon = new GIcon();
//icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.image = "medias/commons/ic_gm.png";
icon.iconSize = new GSize(32, 32);
icon.shadowSize = new GSize(16, 16);
icon.iconAnchor = new GPoint(0, 32);
icon.infoWindowAnchor = new GPoint(0, 0);

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("carte"));
		map.setCenter(new GLatLng(3,3), 13);
		geocoder = new GClientGeocoder();
		map.addControl(new GLargeMapControl());
	}
}

function afficheAdresse(adresse) {
	if (geocoder) {
		geocoder.getLatLng(
		adresse,
		function(point) {
			if (!point) {
				alert(adresse + " inconnue");
			} else {
				map.setCenter(point, 13);
				var repere = new GMarker(point);
				map.addOverlay(repere);
				repere.openInfoWindowHtml(adresse);
				alert(point);
			}
			}
		);
	}
}
function affichePointFicheMembre(a,b,infos){
		point= new GLatLng (a,b);
		repere = new GMarker(point, icon);
		map.addOverlay(repere);
		map.setCenter(point, 13);
		/*alert(a+" "+b);*/
		repere.openInfoWindowHtml(infos);

}
function ajouterInformations(reponse){
	//map.clearOverlays();
	if (!reponse || reponse.Status.code!=200){
		$('reponse').setHTML('Your address cannot be gelocalized. Please check it again.');
		$('carte').setStyle('display','none');
		$('reponse').setStyle('display','block');
	}else{
		entete = reponse.name;
		lieu = reponse.Placemark[0];
		point= new GLatLng (lieu.Point.coordinates[1],lieu.Point.coordinates[0]);
		
		repere = new GMarker(point, icon);
		map.addOverlay(repere);
		repere.openInfoWindowHtml(entete);
		$('confirm').setStyle('display','block');
	}
}
function afficheRepere(n){
	geocoder.getLocations(n, ajouterInformations);
}
//]]>
