﻿// STREETVIEW SAINT PIERRE //

   // Map & Pano delcarations
	google.load("maps", "2");
    var map4;
    var myPano4;   
    var panoClient4;
	
    var currentLatLng4 = new GLatLng(45.830795,1.260842);
	var imoLatLng4 = new GLatLng(45.830795,1.260842);
	var prepaLatLng4 = new GLatLng(45.83081,1.262278);
	var monopLatLng4 = new GLatLng(45.831260,1.259423);
    var currentYaw4 = 0;
	var imgSrc4 = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/images/residence.png";
	var setCenter4 = new GLatLng(45.83081,1.262278);
   // Field of view marker and icon declarations
    var fovMarker4; 
    var fovIcon4 = new GIcon(G_DEFAULT_ICON);
    var iconSize4 = 150; 
    
    var imoMarker4; //marker pour icone imobilier
    var imoIcon4 = new GIcon(G_DEFAULT_ICON);
	
	var PrepMarker;
	var prepaIcon = new GIcon(G_DEFAULT_ICON);
	
	var monopMarker;
	var monopIcon = new GIcon(G_DEFAULT_ICON);
	
   function initialized4(chosen) {
	panoClient4 = new GStreetviewClient(); 	     
	map4 = new GMap2(document.getElementById("street4"));
	map4.addControl(new GLargeMapControl3D);
	map4.addControl (new GScaleControl);
	//map4.setCenter(currentLatLng4, 17);
	map4.setCenter(currentLatLng4, 16);
	myPano4 = new GStreetviewPanorama(document.getElementById("view4"));
	myPano4.setLocationAndPOV(currentLatLng4, {yaw:currentYaw4, pitch:-30});
			
	fovIcon4.image = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/demoicon.php?yaw=180";		
	fovIcon4.iconSize = new GSize(iconSize4, iconSize4);
	fovIcon4.iconAnchor = new GPoint(iconSize4/2, iconSize4/2); //anchor in the middle
	fovIcon4.shadow = null;
	fovMarker4 = new GMarker(currentLatLng4, {icon: fovIcon4, clickable: false})
	GEvent.addListener(myPano4, "initialized", handleInitialized4);
	GEvent.addListener(myPano4, "yawchanged", handleYawChange4);
	
	/*icone immo*/
	imoIcon4.image = imgSrc4;
	imoIcon4.shadow = null;
	imoIcon4.iconSize = new google.maps.Size(20,20);
	imoMarker4 = new GMarker(imoLatLng4, {icon: imoIcon4, clickable: false})

	/**icone prepa **/
	prepaIcon.image = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/images/prepa.png";
	prepaIcon.shadow = null;
	prepaIcon.iconSize = new google.maps.Size(20,20);
	prepaMarker = new GMarker(prepaLatLng4, {icon: prepaIcon, clickable: false})
	
	/**icone monoprix **/
	monopIcon.image = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/images/commerces.png";
	monopIcon.shadow = null;
	monopIcon.iconSize = new google.maps.Size(20,20);
	monopMarker = new GMarker(monopLatLng4, {icon: monopIcon, clickable: false})

	return;
}
function handleInitialized4(location) {
	currentLatLng4 = location.latlng;	
	placeFovMarker4();
	return;	
}
function handleYawChange4(yaw){
	currentYaw4 = Math.round(yaw);
	placeFovMarker4();
	return;
} 
function placeFovMarker4(){
	map4.removeOverlay(fovMarker4);
	/* 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.
	*/
fovIcon4.image = "http://www.limoges-locations.fr/wp-content/themes/limoges-locations/demoicon.php?yaw="+currentYaw4+"&rand="+Math.random();	
	fovMarker4 = new GMarker(currentLatLng4, {icon: fovIcon4, clickable: false});
	fovIcon4.shadow = null;
	map4.addOverlay(fovMarker4);
	map4.addOverlay(imoMarker4);
	map4.addOverlay(prepaMarker);
	map4.addOverlay(monopMarker);
	map4.setCenter(currentLatLng4);

	return;
}
google.setOnLoadCallback(initialized4);
