var map; var isFirstQuery; var isZoomingOnFirstQuery=false;; var icon = new GIcon(); var metroId = 425; //19; var properties = new Array(); var propertyIcon = new GIcon(); var propertyOffIcon = new GIcon(); var propertyGbaseIcon = new GIcon(); var propertyOffGbaseIcon = new GIcon(); var directoryName = "bremerton"; var isGetAllHomes = true; function mapLoad() { isFirstQuery = true; GetAllHomes = getQueryVariable("GetAllHomes") if (GetAllHomes=="YES") { isGetAllHomes = true; } if (GetAllHomes=="NO") { isGetAllHomes = false; } map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); propertyIcon.image = "http://www.homesbyowner.com/media/houseicon.png"; propertyIcon.shadow = "http://www.homesbyowner.com/media/houseiconshadow.png"; propertyIcon.iconSize = new GSize(15, 15); propertyIcon.shadowSize = new GSize(20, 20); propertyIcon.iconAnchor = new GPoint(10, 10); propertyIcon.infoWindowAnchor = new GPoint(5, 1); propertyOffIcon.image = "http://www.homesbyowner.com/media/houseofficon.png"; propertyOffIcon.shadow = "http://www.homesbyowner.com/media/houseiconshadow.png"; propertyOffIcon.iconSize = new GSize(15, 15); propertyOffIcon.shadowSize = new GSize(20, 20); propertyOffIcon.iconAnchor = new GPoint(10, 10); propertyOffIcon.infoWindowAnchor = new GPoint(5, 1); propertyGbaseIcon.image = "http://www.homesbyowner.com/media/houseicongbase.png"; propertyGbaseIcon.shadow = "http://www.homesbyowner.com/media/houseiconshadow.png"; propertyGbaseIcon.iconSize = new GSize(15, 15); propertyGbaseIcon.shadowSize = new GSize(20, 20); propertyGbaseIcon.iconAnchor = new GPoint(10, 10); propertyGbaseIcon.infoWindowAnchor = new GPoint(5, 1); propertyOffGbaseIcon.image = "http://www.homesbyowner.com/media/houseofficongbase.png"; propertyOffGbaseIcon.shadow = "http://www.homesbyowner.com/media/houseiconshadow.png"; propertyOffGbaseIcon.iconSize = new GSize(15, 15); propertyOffGbaseIcon.shadowSize = new GSize(20, 20); propertyOffGbaseIcon.iconAnchor = new GPoint(10, 10); propertyOffGbaseIcon.infoWindowAnchor = new GPoint(5, 1); loader = new MLoader(map, document.getElementById("loading"), document.getElementById("loadingText"), document.getElementById("bar"), document.getElementById("fill"), document.getElementById("loadingButton")); GEvent.addListener(map, "zoomend", function() { if (( ! isFirstQuery) || isZoomingOnFirstQuery) { isZoomingOnFirstQuery = false; //we do not want this firing on first query EXCEPT when isZoomingOnFirstQuery is explicitly set. It is set when too many homes are shown on first view. showHomes(); } }); GEvent.addListener(map, "moveend", function() { if (! isFirstQuery) { showHomes(); } }); //document.getElementById("message").innerHTML = "map loaded"; map.addControl(new GOverviewMapControl()); map.addControl(new GMapTypeControl()); var tooltip = document.createElement("div"); map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip); tooltip.style.visibility="hidden"; tooltip.id="tooltip"; map.setCenter(new GLatLng(, ), ); setTimeout("loadFirstHomes()", 500); } function loadFirstHomes() { //look to see if we came via a back button //if the lastmv cookie is equal to the mv request string, it is a back button access of this page, so recenter //alert("query mv is " + getQueryVariable("mv")); if (get_cookie("lastmv") == getQueryVariable("mv")) { //came back via back button returnPosition(); } else { //alert("they are not equal"); document.cookie='lastmv='+getQueryVariable("mv"); map.setCenter(new GLatLng(, ), ); //map.setMapType(G_HYBRID_MAP); } showHomes(); } function toogleGetAllHomes() { myGetAllHomes = document.getElementById("chkGetAllHomes"); if ( myGetAllHomes.checked ) { window.location = "map.asp?GetAllHomes=YES&mv="+getQueryVariable("mv"); } else { window.location = "map.asp?GetAllHomes=NO&mv="+getQueryVariable("mv"); } } function returnPosition() { myZoom=new String(get_cookie('mapcenterzoom')); myCenterLat=new String(get_cookie('mapcenterlat')); myCenterLng=new String(get_cookie('mapcenterlng')); myDirectoryName = new String(get_cookie('directoryname')); //alert('zoom='+myZoom+' lat='+myCenterLat+' long='+myCenterLng); if ( myZoom>0 && Math.abs(myCenterLat)>0 && Math.abs(myCenterLng)>0 && myDirectoryName==directoryName) { myMapType = new String(get_cookie('maptype')); //alert('centering'); map.setCenter(new GLatLng(myCenterLat,myCenterLng),parseInt(myZoom)); //Set the map type (i.e. hybrid, satellite, etc myMapType = new String(get_cookie('maptype')); map.setMapType(map.getMapTypes()[parseInt(myMapType)]); } else { //alert('not centering'); map.setCenter(new GLatLng(, ), ); } } function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i"") {strUrl = strUrl + "&homeid=" + getQueryVariable("homeid")}; //document.getElementById("message").innerHTML = strUrl; GDownloadUrl(strUrl, function(data, responseCode) { //request.open("GET", strUrl, true); //map.clearOverlays(); //request.onreadystatechange = function() { var xmlDoc = GXml.parse(data); //var xmlDoc = request.responseXML; k=0; var errormsg = xmlDoc.documentElement.getElementsByTagName("errormsg") //alert('b4 err ' + isFirstQuery); if (errormsg.length > 0) { if (! isFirstQuery) { houseCount = errormsg[0].getAttribute("total"); maxCount = errormsg[0].getAttribute("maxCount"); busyIndicator.style.display = "none"; errorMsg.style.display = ""; errorMsgText.innerHTML = "

The area you are viewing has " + houseCount + " homes.

For performance and your convenience, we limit map results to a maximum of " + maxCount + " homes.

Please use the ZOOM tool on the left to narrow your search area.

"; enableMovement(); myLoadMessage.innerHTML = "Too many homes to show. Please zoom in!"; myLoadMessage.style.backgroundColor="red"; myLoadMessage.style.opacity=1; //if (ie5) {myLoadMessage.filters.alpha.opacity=100;} } else { //alert('zooming in automajically') isZoomingOnFirstQuery = true; map.zoomIn(); } } else { //hideZips(); //hideCities(); var homelist = xmlDoc.documentElement.getElementsByTagName("home"); //document.getElementById("homelist").innerHTML = "

Homes

" + homelist.length + "!"; for (var i = 0; i < homelist.length; i++) { var direct_url = homelist[i].getAttribute("direct_url"); if (properties[direct_url] == undefined) { k++; var property = new Property(); property.name = homelist[i].getAttribute("address");; property.direct_url = direct_url; property.home_id = homelist[i].getAttribute("home_id"); property.address = homelist[i].getAttribute("address"); property.price = homelist[i].getAttribute("price"); property.beds = homelist[i].getAttribute("beds"); property.baths = homelist[i].getAttribute("baths"); property.city = homelist[i].getAttribute("city"); property.main_photo_id = homelist[i].getAttribute("main_photo_id"); property.main_photo_version = homelist[i].getAttribute("main_photo_version"); property.gbase = homelist[i].getAttribute("gbase"); property.gbase_image = homelist[i].getAttribute("gbase_image"); property.status = homelist[i].getAttribute("status"); property.lng = homelist[i].getAttribute("long"); property.lat = homelist[i].getAttribute("lat"); property.matches = homelist[i].getAttribute("matches"); loader.add(property, property.register); } else { properties[direct_url].show(true); } } busyIndicator.style.display = "none"; //alert('after'+isFirstQuery); if (k > 0) { //isFirstQuery is also set to false when loader finishes in showmaploader.js loader.show("Displaying homes...", true, "homes"); loader.execute(); } else { isFirstQuery = false; //we have successfully received our first query back enableMovement(); } savePosition(); var homes = xmlDoc.getElementsByTagName("homes"); var showing = parseInt(homes[0].getAttribute("count")); var max = parseInt(homes[0].getAttribute("max")); var possible = parseInt(homes[0].getAttribute("gbrecordcount")) + parseInt(homes[0].getAttribute("hbocount")); var gburl = homes[0].getAttribute("gburl"); if (window.console) console.log(unescape(gburl)); //if count = max homes and google base record count is greater, then mention to zoom in for more homes if (showing == max && showing < possible ) myLoadMessage.innerHTML = "Showing " + showing + " homes. Zoom in to view more homes in the area."; else myLoadMessage.innerHTML = "Showing " + showing + " homes."; myLoadMessage.style.backgroundColor="#000000"; //myLoadMessage.style.opacity=.5; //if (ie5) {myLoadMessage.filters.alpha.opacity=50;} if (getQueryVariable("homeid")>"" && isFirstQuery) { //alert('yep'); //var selectedHome = getQueryVariable("homeid"); //GEvent.trigger(properties[selectedHome].marker,'click'); } ////isFirstQuery = false; //we have successfully received our first query back } }) //request.send(null); }