﻿// STREETVIEW 17 MALIGNE  //

   // Map & Pano delcarations
	google.load("maps", "2");
    var map2;
    var myPano2;   
    var panoClient2;
    var currentLatLng2 = new GLatLng(45.828141,1.26138);
	var imoLatLng2 = new GLatLng(45.827841,1.26178);
    var currentYaw2 = 120;
	var imgSrc2 = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/images/residence.png";
   
   // Field of view marker and icon declarations
    var fovMarker2; 
    var fovIcon2 = new GIcon(G_DEFAULT_ICON);
    var iconSize2 = 150; 
    
    var imoMarker2; //marker pour icone imobilier
    var imoIcon2 = new GIcon(G_DEFAULT_ICON);    	
	
   function initialized2(chosen) {
	panoClient2 = new GStreetviewClient(); 
	     
	map2 = new GMap2(document.getElementById("street2"));
	map2.addControl(new GLargeMapControl3D);
	map2.addControl (new GScaleControl);
	map2.setCenter(currentLatLng2, 17);
	myPano2 = new GStreetviewPanorama(document.getElementById("view2"));
	myPano2.setLocationAndPOV(currentLatLng2, {yaw:currentYaw2, pitch:0});
			
	fovIcon2.image = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/demoicon.php?yaw=180";		
	fovIcon2.iconSize = new GSize(iconSize2, iconSize2);
	fovIcon2.iconAnchor = new GPoint(iconSize2/2, iconSize2/2); //anchor in the middle
	fovIcon2.shadow = null;
	fovMarker2 = new GMarker(currentLatLng2, {icon: fovIcon2, clickable: false})		
	GEvent.addListener(myPano2, "initialized", handleInitialized2); 
	GEvent.addListener(myPano2, "yawchanged", handleYawChange2);
	
	/*icone immo*/
	imoIcon2.image = imgSrc2;
	imoIcon2.shadow = null;
	imoIcon2.iconSize = new google.maps.Size(20,20);
	imoMarker2 = new GMarker(imoLatLng2, {icon: imoIcon2, clickable: false})		
	return;
}
function handleInitialized2(location) {
	currentLatLng2 = location.latlng;	
	placeFovMarker2();
	return;	
}
function handleYawChange2(yaw){
	currentYaw2 = Math.round(yaw);
	placeFovMarker2();
	return;
} 
function placeFovMarker2(){
	map2.removeOverlay(fovMarker2);
	/* 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.
	*/
fovIcon2.image = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/demoicon.php?yaw="+currentYaw2+"&rand="+Math.random();	
	fovMarker2 = new GMarker(currentLatLng2, {icon: fovIcon2, clickable: false});
	map2.addOverlay(fovMarker2);
	map2.addOverlay(imoMarker2);
	map2.setCenter(currentLatLng2);
	return;
}
google.setOnLoadCallback(initialized2);
