﻿// STREETVIEW CHARLES MICHELS  //

   // Map & Pano delcarations
	google.load("maps", "2");
    var map3;
    var myPano3;   
    var panoClient3;
    var currentLatLng_cmich = new GLatLng(45.829035,1.26022);
	var imoLatLng_cmich = new GLatLng(45.829005,1.26032);
    var currentYaw_cmich = 0;
	var imgSrc3 = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/images/residence.png";
   
   // Field of view marker and icon declarations
    var fovMarker3; 
    var fovIcon3 = new GIcon(G_DEFAULT_ICON);
    var iconSize3 = 150; 
    
    var imoMarker3; //marker pour icone imobilier
    var imoIcon3 = new GIcon(G_DEFAULT_ICON);    	
	
   function initialized3(chosen) {
	panoClient3 = new GStreetviewClient(); 	     
	map3 = new GMap2(document.getElementById("street3"));
	//map.addControl(new GSmallMapControl());
	map3.addControl(new GLargeMapControl3D);
	map3.addControl (new GScaleControl);
	map3.setCenter(currentLatLng_cmich, 17);
	myPano3 = new GStreetviewPanorama(document.getElementById("view3"));
	myPano3.setLocationAndPOV(currentLatLng_cmich, {yaw:currentYaw_cmich, pitch:-20});
			
	fovIcon3.image = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/demoicon.php?yaw=180";		
	fovIcon3.iconSize = new GSize(iconSize3, iconSize3);
	fovIcon3.iconAnchor = new GPoint(iconSize3/2, iconSize3/2); //anchor in the middle
	fovIcon3.shadow = null;
	fovMarker3 = new GMarker(currentLatLng_cmich, {icon: fovIcon3, clickable: false})		
	GEvent.addListener(myPano3, "initialized", handleInitialized3); 
	GEvent.addListener(myPano3, "yawchanged", handleYawChange3);
	
	/*icone immo*/
	imoIcon3.image = imgSrc3;
	imoIcon3.shadow = null;
	imoIcon3.iconSize = new google.maps.Size(20,20);
	imoMarker3 = new GMarker(imoLatLng_cmich, {icon: imoIcon3, clickable: false})		
	return;
}
function handleInitialized3(location) {
	currentLatLng_cmich = location.latlng;	
	placeFovMarker3();
	return;	
}
function handleYawChange3(yaw){
	currentYaw_cmich = Math.round(yaw);
	placeFovMarker3();
	return;
} 
function placeFovMarker3(){
	map3.removeOverlay(fovMarker3);
	/* The following line really only needs to be in handleYawChange(), but doing so creates a flicker of the marker 
	* when using Firefox.  It may have something to do with the lag between when the initialized event is triggered
	* and when the Street View image is actually finished loading. Although less than optimal, I've found that 
	* reloading the image for each placement avoids the problem.
	*/
fovIcon3.image = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/demoicon.php?yaw="+currentYaw_cmich+"&rand="+Math.random();	
	fovMarker3 = new GMarker(currentLatLng_cmich, {icon: fovIcon3, clickable: false});
	map3.addOverlay(fovMarker3);
	map3.addOverlay(imoMarker3);
	map3.setCenter(currentLatLng_cmich);
	return;
}
google.setOnLoadCallback(initialized3);
