$(document).ready(function(){ //Start script when ready if (document.getElementById("map_canvas")) {//Checks to see that the page element exists and to prevent conflict with other maps //Default map center location 40.992336, -74.051971), 9 var defaultLat = 40.992336; var defaultLon = -74.051971; var markers = new Array(); markers[0] = new Array(new GMarker(new GLatLng(41.0086, -73.9389)), "$499,000", "Northvale, NJ
$499,000
More Info..."); markers[1] = new Array(new GMarker(new GLatLng(41.0086, -73.9389)), "$470,000", "Northvale, NJ
$470,000
More Info..."); markers[2] = new Array(new GMarker(new GLatLng(41.0086, -73.9389)), "$510,000", "Northvale, NJ
$510,000
More Info..."); markers[3] = new Array(new GMarker(new GLatLng(41.0086, -73.9389)), "$899,000", "Northvale, NJ
$899,000
More Info..."); markers[4] = new Array(new GMarker(new GLatLng(41.0086, -73.9389)), "$645,000", "Northvale, NJ
$645,000
More Info..."); markers[5] = new Array(new GMarker(new GLatLng(40.9511, -73.9308)), "$3,975,000", "Alpine, NJ
$3,975,000
More Info..."); markers[6] = new Array(new GMarker(new GLatLng(41.0086, -73.9389)), "$799,000", "Northvale, NJ
$799,000
More Info..."); markers[7] = new Array(new GMarker(new GLatLng(41.0086, -73.9389)), "$460,000", "Northvale, NJ
$460,000
More Info..."); markers[8] = new Array(new GMarker(new GLatLng(40.9238, -73.9989)), "$675,000", "Bergenfield, NJ
$675,000
More Info..."); markers[9] = new Array(new GMarker(new GLatLng(41.0086, -73.9389)), "$745,000", "Northvale, NJ
$745,000
More Info..."); markers[10] = new Array(new GMarker(new GLatLng(41.0086, -73.9389)), "$575,000", "Northvale, NJ
$575,000
More Info..."); var map = new google.maps.Map2($("#map_canvas").get(0));//Initialise google maps map.setCenter(new GLatLng(defaultLat, defaultLon), 12);//Set location to the default and zoom level to 8 map.disableDoubleClickZoom();//Disable zooming //This section works fine but does not animate on load /* $(markers).each(function(i,marker){ map.addOverlay(marker[0]); $("
  • ") .html(markers[i][1])//Use list item label from array .click(function(){ displayPoint(marker[0], i); setActive(this);//Show active state if ($('#map_message').is(':hidden')) {//Allow toggling of active state setActive(); } }) .appendTo("#map_list"); GEvent.addListener(marker[0], "click", function(){ displayPoint(marker[0], i); setActive(i);//Show active location if ($('#map_message').is(':hidden')) {//Allow toggling of active state setActive(); } }); }); */ $.each(markers,function(i,marker){ var delayTime = ((i * 3000) / (0.5 * markers.length));//Delay time decreases as number of markers increases setTimeout(function(){ map.addOverlay(marker[0]); $("
  • ") .html(markers[i][1])//Use list item label from array .click(function(){ displayPoint(marker[0], i); setActive(this);//Show active state }) .appendTo("#map_list"); GEvent.addListener(marker[0], "click", function(){ displayPoint(marker[0], i); setActive(i);//Show active location }); displayPoint(marker[0], i); setActive(i);//Show active location if (i == (markers.length - 1)) {//If last item in array setTimeout(function(){//Remove active class and fade marker after delay $("#map_message").fadeOut(); //setActive(); }, 3500); } }, delayTime); }); $("#map_list").css("opacity","0.2").animate({opacity: 1}, 1100);//Fade in menu $("#map_message").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE)); function displayPoint(marker, index){ if ($('#map_message').is(':hidden')) {//Allow toggling of markers $('#map_message').fadeIn(); } else{//Remove all .active classes and hide markers $('#map_message').hide(); $(".active").removeClass(); } //$("#map_message").hide();//Default behaviour, doesn't allow toggling var moveEnd = GEvent.addListener(map, "moveend", function(){ var markerOffset = map.fromLatLngToDivPixel(marker.getLatLng()); $("#map_message") .html(markers[index][2])//Use information from array .fadeIn() .css({ top:markerOffset.y, left:markerOffset.x }); GEvent.removeListener(moveEnd); }); map.panTo(marker.getLatLng()); } function setActive(el){ $(".active").removeClass();//Remove all .active classes $("#map_list").find('li').eq(el).addClass('active');//Find list element equal to index number and set active $(el).addClass('active');//Set active if list element clicked directly } }//End if map_canvas exists }); //End onReady