//UTF-8 à jamais

/*
http://code.google.com/intl/fr/apis/maps/documentation/javascript/overlays.html
http://code.google.com/intl/fr/apis/maps/documentation/javascript/reference.html
*/

var ggmap=null;
var ggmap_OverlayView=null;
var ggmap_bulle_timeout=null;


//var ggmap_infowindow=null;

	
	var ggmap_marker_1_1=null;
					

	
	var ggmap_marker_2_1=null;
					

	
	var ggmap_marker_3_1=null;
					


var ggmap_polygon_0=null;

function ggmap_load()
{
	//--------------------
	//initialiser la carte
	//--------------------			
  var myOptions={
		//zoom:6,center:new google.maps.LatLng(45.6361269,4.424057),
		mapTypeId:google.maps.MapTypeId.TERRAIN,//ROADMAP/SATELLITE/HYBRID/TERRAIN
		panControl:false,//fleches de déplacement

		zoomControl:false,//masquer zoom
		//zoomControl:true,zoomControlOptions:{style:google.maps.ZoomControlStyle.SMALL},//zoom +/-
		//zoomControl:true,zoomControlOptions:{style:google.maps.ZoomControlStyle.LARGE},//zoom +[...................]-

		mapTypeControl:false,//masquer plan/satellite/...
		//mapTypeControl:true,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.HORIZONTAL_BAR},//plan/satellite/... (boutons)
		//mapTypeControl:true,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU},//plan/satellite/... (menu déroulant)

		scaleControl:false,//échelle
		streetViewControl:false,//StreetView
	};
	
  ggmap=new google.maps.Map(document.getElementById('ggmap_carte'),myOptions);

	ggmap_OverlayView=new google.maps.OverlayView();
	ggmap_OverlayView.draw=function()
	{
		if(!this.ready)
		{
			this.ready=true;
			google.maps.event.trigger(this,'ready');
		}
	};
	ggmap_OverlayView.setMap(ggmap);

	
		var bounds=new google.maps.LatLngBounds();
		bounds.extend(new google.maps.LatLng(46.0111063,4.815672));
		bounds.extend(new google.maps.LatLng(45.786601,4.4846179));
		ggmap.fitBounds(bounds);
	
	//--------------------

	

	//----------------------
	//placer les POIs
	//----------------------

	

	var ma_map=null;
	
		
		var ggmap_icon_1=new google.maps.MarkerImage('picto/ggmap-villefranche.png',new google.maps.Size(99,33),new google.maps.Point(0,0),new google.maps.Point(99/2,33/2));
		
		var ggmap_icon_2=new google.maps.MarkerImage('picto/ggmap-lyon.png',new google.maps.Size(76,33),new google.maps.Point(0,0),new google.maps.Point(76/2,33/2));
		
		var ggmap_icon_3=new google.maps.MarkerImage('picto/ggmap-anse.png',new google.maps.Size(76,33),new google.maps.Point(0,0),new google.maps.Point(76/2,33/2));
		
		ma_map=ggmap;
	

	
	
		
		ggmap_marker_1_1=new google.maps.Marker({position:new google.maps.LatLng(45.991513,4.71883),map:ma_map,icon:ggmap_icon_1});
	  google.maps.event.addListener(ggmap_marker_1_1,'mouseover',function()
		{
			ggmap_affiche_bulle(this.getPosition(),'<strong>villefranche</strong><br />');
		});
/*
		
			
		
*/		
		
		
		
	  google.maps.event.addListener(ggmap_marker_1_1,'mouseout',ggmap_cache_bulle);	
						
	
	
	
		
		ggmap_marker_2_1=new google.maps.Marker({position:new google.maps.LatLng(45.766601,4.835672),map:ma_map,icon:ggmap_icon_2});
	  google.maps.event.addListener(ggmap_marker_2_1,'mouseover',function()
		{
			ggmap_affiche_bulle(this.getPosition(),'<strong>lyon</strong><br />');
		});
/*
		
			
		
*/		
		
		
		
	  google.maps.event.addListener(ggmap_marker_2_1,'mouseout',ggmap_cache_bulle);	
						
	
	
	
		
		ggmap_marker_3_1=new google.maps.Marker({position:new google.maps.LatLng(45.939094,4.718943),map:ma_map,icon:ggmap_icon_3});
	  google.maps.event.addListener(ggmap_marker_3_1,'mouseover',function()
		{
			ggmap_affiche_bulle(this.getPosition(),'<strong>anse</strong><br />');
		});
/*
		
			
		
*/		
		
		
		
	  google.maps.event.addListener(ggmap_marker_3_1,'mouseout',ggmap_cache_bulle);	
						
	
	

	
	
		
		ggmap_polygon_0=new google.maps.Polyline({
			path:[new google.maps.LatLng(45.9687406,4.7551118),new google.maps.LatLng(45.9726778,4.7430955),new google.maps.LatLng(45.960746,4.7298776),new google.maps.LatLng(45.9737515,4.6503984),new google.maps.LatLng(45.9887816,4.6503984),new google.maps.LatLng(45.9941485,4.671856),new google.maps.LatLng(46.0159685,4.6605264),new google.maps.LatLng(46.0157301,4.6140062),new google.maps.LatLng(46.0311063,4.5899736),new google.maps.LatLng(46.0283055,4.5261155),new google.maps.LatLng(46.0190607,4.5275476),new google.maps.LatLng(46.0118549,4.5401618),new google.maps.LatLng(46.0023767,4.5424234),new google.maps.LatLng(46.0007073,4.4971048),new google.maps.LatLng(45.9869329,4.4646179),new google.maps.LatLng(45.9648667,4.4850836),new google.maps.LatLng(45.9345467,4.4831573),new google.maps.LatLng(45.9223679,4.4922553),new google.maps.LatLng(45.9171135,4.4922553),new google.maps.LatLng(45.9087029,4.5066363),new google.maps.LatLng(45.9031892,4.5297204),new google.maps.LatLng(45.8804635,4.5356383),new google.maps.LatLng(45.8673417,4.5475568),new google.maps.LatLng(45.8481974,4.5597427),new google.maps.LatLng(45.8432601,4.580146),new google.maps.LatLng(45.8378785,4.598857),new google.maps.LatLng(45.8256785,4.6005737),new google.maps.LatLng(45.822329,4.6060668),new google.maps.LatLng(45.8339318,4.6197997),new google.maps.LatLng(45.8374925,4.6237758),new google.maps.LatLng(45.8377794,4.627553),new google.maps.LatLng(45.841893,4.6358429),new google.maps.LatLng(45.8468603,4.6372919),new google.maps.LatLng(45.8477747,4.6411198),new google.maps.LatLng(45.8503077,4.6488063),new google.maps.LatLng(45.8565392,4.6551139),new google.maps.LatLng(45.8556492,4.6605888),new google.maps.LatLng(45.854978,4.6678649),new google.maps.LatLng(45.8409165,4.682776),new google.maps.LatLng(45.8379582,4.7052931),new google.maps.LatLng(45.8529455,4.7324096),new google.maps.LatLng(45.8448146,4.7329246),new google.maps.LatLng(45.8381177,4.7391044),new google.maps.LatLng(45.8425426,4.7554122),new google.maps.LatLng(45.8554725,4.7744391),new google.maps.LatLng(45.8709277,4.789938),new google.maps.LatLng(45.8924029,4.7902215),new google.maps.LatLng(45.9030196,4.8074256),new google.maps.LatLng(45.9077976,4.8118888),new google.maps.LatLng(45.9159192,4.8125755),new google.maps.LatLng(45.9227262,4.8089706),new google.maps.LatLng(45.9239203,4.8002158),new google.maps.LatLng(45.9232038,4.794036),new google.maps.LatLng(45.926189,4.7887145),new google.maps.LatLng(45.9370538,4.7809898),new google.maps.LatLng(45.9403964,4.7710334),new google.maps.LatLng(45.9359794,4.7598754),new google.maps.LatLng(45.9382476,4.7485458),new google.maps.LatLng(45.9400383,4.7356712),new google.maps.LatLng(45.9472003,4.7294914),new google.maps.LatLng(45.9542421,4.7368728),new google.maps.LatLng(45.9611636,4.7483741),new google.maps.LatLng(45.9687406,4.7551118)],
			strokeColor:'#F87E00',//couleur contour
			strokeOpacity:100,//opacité contour
			strokeWeight:3//epaisseur contour
		});
		
		
/*
		
			
		
*/		
		
		  google.maps.event.addListener(ggmap_polygon_0,'mousemove',function(MouseEvent)
			{
//jerome : ne pas afficher de bulle sur le contour du territoire (carte comment venir chez nous)				ggmap_affiche_bulle(MouseEvent.latLng,'<strong></strong><br />');
			});
		

		
		
		
		
	  google.maps.event.addListener(ggmap_polygon_0,'mouseout',ggmap_cache_bulle);
	  ggmap_polygon_0.setMap(ggmap);
	
		
	//----------------------

	
}
function ggmap_click_carte(MouseEvent)
{
	if(document.getElementById('liste_editable_edit_coordonnees')!=null)//on a bien une liste éditable en cours d'édition qui contient une rubrique coordonnées
	{
		ggmap_placer_marker_temp(MouseEvent.latLng.lat(),MouseEvent.latLng.lng());
	}
}
function ggmap_affiche_bulle(point,html,decal)
{
	ggmap_cache_pas_bulle();
	if(typeof(decal)=='undefined')
		decal=15;
	var bulle=document.getElementById('ggmap_bulle');
	if(!bulle)
	{
		var bulle=document.createElement('div');
		bulle.id='ggmap_bulle';
		bulle.style.display='none';
		document.getElementById('ggmap_carte').appendChild(bulle);
	}
	var bulle=document.getElementById('ggmap_bulle');
	if(!bulle)
		return;
	bulle.onmouseover=ggmap_cache_pas_bulle;
	bulle.onmouseout=ggmap_cache_bulle;
	bulle.innerHTML=html;
	bulle.style.display='block';
	var bulle_w=bulle.clientWidth;
	var bulle_h=bulle.clientHeight;
	var carte_w=document.getElementById('ggmap_carte').clientWidth;
	var carte_h=document.getElementById('ggmap_carte').clientHeight;

	var DivPixel=ggmap_OverlayView.getProjection().fromLatLngToContainerPixel(point);

	var bulle_top=(DivPixel.y-bulle_h-decal);
	if(bulle_top<0)
		bulle_top=(DivPixel.y+decal);
	if(bulle_top>carte_h-bulle_h-2)
		bulle_top=carte_h-bulle_h-2;
	var bulle_left=(DivPixel.x-(bulle_w/2));
	if(bulle_left<0)
		bulle_left=0;
	if(bulle_left>carte_w-bulle_w-2)
		bulle_left=carte_w-bulle_w-2;
	bulle.style.top=bulle_top+'px';
	bulle.style.left=bulle_left+'px';
}
function ggmap_cache_bulle()
{
	clearTimeout(ggmap_bulle_timeout);
	ggmap_bulle_timeout=setTimeout('ggmap_cache_bulle_maintenant()',500);
}
function ggmap_cache_pas_bulle()
{
	clearTimeout(ggmap_bulle_timeout);
}
function ggmap_cache_bulle_maintenant()
{
	var bulle=document.getElementById('ggmap_bulle');
	if(bulle)
	{
		bulle.onmouseout=null;
		bulle.onmouseover=null;
		bulle.style.display='none';
		bulle.innerHTML='';
	}
}



function ggmap_affiche_poi_type(id,affiche)
{
	
	if(id==1)
	{
		if(affiche)
		{
			
			ggmap_marker_1_1.setMap(ggmap);
							
		}
		else
		{
			
			ggmap_marker_1_1.setMap(null);
							
		}
	}
	
	if(id==2)
	{
		if(affiche)
		{
			
			ggmap_marker_2_1.setMap(ggmap);
							
		}
		else
		{
			
			ggmap_marker_2_1.setMap(null);
							
		}
	}
	
	if(id==3)
	{
		if(affiche)
		{
			
			ggmap_marker_3_1.setMap(ggmap);
							
		}
		else
		{
			
			ggmap_marker_3_1.setMap(null);
							
		}
	}
	
	
	if(id==0)
	{
		if(affiche)
			ggmap_polygon_0.setMap(ggmap);
		else
			ggmap_polygon_0.setMap(null);
	}
	
}




