(function($) {
/*

// Tout d'abord récupérer la clé de google ici : http://code.google.com/intl/fr/apis/maps/signup.html (etre connecté a google)
// ! IMPORTANT : a sauvegarder dans le dossier ELEMENT/cle_gmaps.txt

EXEMPLE d'utilisation complet :

<link href="css/gmaps.css" rel="stylesheet" type="text/css" media="all" />
// -> bien definir dans la css les parametres de bulle_html (les codes html)
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=MA_CLE_RECUPEREE" type="text/javascript"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.jmap-r72.js" type="text/javascript"></script>
<script src="js/functions_jmaps.js" type="text/javascript"></script>
<script type="text/javascript">

var jMaps = jQuery.noConflict();
jMaps(document).ready(function(){
	//si vous changez l'icone, vous devez creer les images au format png et indiquer leur valeur dans un tableau :
	var tab_icone = {
		image: '../images/gmaps/marqueur_zone.png',
		shadow: '../images/gmaps/marqueur_zone_shadow.png',
		iconSize: {w:30, h:31},
		shadowSize: {w:62, h:31},
		iconAnchor: {w:20, h:31},
		infoWindowAnchor: {w:5, h:1}
	};

	var bulle_html = ''+
		'<div class="div_bulle" name="div_bulle">'+
		'	TEXTE BULLE'+
		'</div>';

jMaps("#ma_div_conteneur").css({width:'200px',height:'200px'});
jMaps("#ma_div_conteneur").getMap( 10.2457 , -1.2457 , 10 ,'init' , G_NORMAL_MAP);
jMaps("#ma_div_conteneur").addMarker( 10.2457 , -1.2457 , bulle_html , tab_icone , FALSE , FALSE )

});

</script>

*/


$.addIcone = function(tab_icone) {
	if($.empty(tab_icone)){
		return undefined;
	}else {
		icone =  new GIcon(G_DEFAULT_ICON);
		icone.image = tab_icone['image'];
		icone.shadow = tab_icone['shadow'];
		icone.iconSize = new GSize(tab_icone['iconSize']['w'],tab_icone['iconSize']['h']);
		icone.shadowSize = new GSize(tab_icone['shadowSize']['w'],tab_icone['shadowSize']['h']);
		icone.iconAnchor = new GPoint(tab_icone['iconAnchor']['w'],tab_icone['iconAnchor']['h']);
		icone.infoWindowAnchor = new GPoint(tab_icone['infoWindowAnchor']['w'],tab_icone['infoWindowAnchor']['h']);
		return icone;
	}
}


// CREATION CARTE (squelette)
/*
* @param fonction :
* correspond au parametre de type de changement de carte
* @xemple : "init" => création de la carte / "MoveTo" => correspond a un fondu d'une carte a l'autre

* @param type : 
* correspond a au type de carte ajoute
* @exemple :
* - "G_NORMAL_MAP" : Carte normale (plan)
* - "G_SATELLITE_MAP" : Vue satellite (photo aérienne)
* - "G_HYBRID_MAP" : Vue satellite, agrémentée de noms de villes, rues, ...
* - "G_PHYSICAL_MAP" : relief
*/
$.fn.getMap = function(lat,long,zoom,fonction,type){
	return this.each(function() {
		fonction = $.empty(fonction) ? 'init' : fonction;
		
		$(this).jmap(fonction,{
			'mapType':$.empty(type) ? G_NORMAL_MAP : type,
			'mapCenter':[lat,long],
			'mapZoom':zoom
		});
	});
}


// CREATION MARKER dans carte en cours
$.fn.addMarker = function(lat,long,html,icone,drag,rem) {
	return this.each(function() {
		
		$(this).jmap('AddMarker',{
			pointLatLng:[lat,long],
			pointHTML:html,
			pointIsRemovable:$.empty(rem) ? false : rem,
			pointIsDraggable:$.empty(drag) ? false : drag,
			pointIcon: $.addIcone(icone)
		});
	});
}
	
	
})(jQuery);
