// ------------------------------resetMap ------------------------------ // function resetMap() { map.setCenter(new GLatLng(38.4038,-96.1804), 2); } //--------------------------------- getMarkers --------------------------// function getMarkers(zoomlvl, bounds) { var swlat = bounds.getSouthWest().lat(); var swlng = bounds.getSouthWest().lng(); var nelat = bounds.getNorthEast().lat(); var nelng = bounds.getNorthEast().lng(); startLoading(); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'getmarkers.php?zoomlvl=' + zoomlvl + '&swlat=' + swlat + '&swlng=' + swlng + '&nelat=' + nelat + '&nelng=' + nelng + ''; document.getElementsByTagName('head')[0].appendChild(script); //map.clearOverlays(); } //----------------------------- createSiteMarker -----------------------------------// function createSiteMarker(id, lat, lng, type) { var point = new GLatLng(lat, lng); var newIcon = new GIcon(); if (type == "state") { //FOR BIG MARKER - used with states //window.alert("st"); newIcon.image = "./images/blue_marker.png" newIcon.shadow = "./images/default_shadow50.png"; newIcon.iconSize = new GSize(20, 34); newIcon.shadowSize = new GSize(37, 34); newIcon.iconAnchor = new GPoint(9, 33); newIcon.shadowAnchor = new GPoint(9, 33); newIcon.infoWindowAnchor = new GPoint(5, 1); } if (type == "city") { // FOR SMALL MARKER //window.alert("city"); newIcon.image = "./images/mm_20_red.png" newIcon.shadow = "./images/mm_20_shadow.png"; newIcon.iconSize = new GSize(12, 20); newIcon.shadowSize = new GSize(22, 20); newIcon.iconAnchor = new GPoint(6, 20); newIcon.shadowAnchor = new GPoint(6, 20); newIcon.infoWindowAnchor = new GPoint(5, 1); } if (type == "apt") { // FOR SMALL MARKER //window.alert("city"); newIcon.image = "./images/mm_20_blue.png" newIcon.shadow = "./images/mm_20_shadow.png"; newIcon.iconSize = new GSize(12, 20); newIcon.shadowSize = new GSize(22, 20); newIcon.iconAnchor = new GPoint(6, 20); newIcon.shadowAnchor = new GPoint(6, 20); newIcon.infoWindowAnchor = new GPoint(5, 1); } var marker = new GMarker(point, newIcon); GEvent.addListener(marker, "click", function() { markerShowInfo(marker, id, type); }); markerlistID.push(id); return marker; } //---------------------------------------------- findMarkerByID-----------------------// function findMarkerByID(id) { for(var i = 0; i < markerlistID.length; i++) { if(markerlistID[i] == id) { return markerlist[i]; } } return null; } // end function findMarkerByID //--------------------------------------- showInfoByID ----------------------------------------------// function showInfoByID(id, type) { var marker = findMarkerByID(id); if (marker != null) { markerShowInfo(marker, id, type); } else { window.alert("uh oh..."); } } // end function showInfoByID //---------------------------------------------- markerShowInfo -----------------------// function markerShowInfo(marker, id, type) { //var index = findIndexByID(id); var infoHtml = ""; var infoFloorplan; var resArray; b_windowhasbeenopened = 1; var url = 'infowindowtext.php?id=' + id + '&info=' + type + ''; var myAjax = new Ajax.Request(url, {method: 'get', onComplete: function(response) { currentMarker = marker; infoHtml = response.responseText; var allArray = infoHtml.split("zzzzzz"); var windowinfo = allArray[0]; var leftinfo = allArray[1]; resArray = windowinfo.split("xxxxxx"); var tabs = new Array(); for(var i = 0; i < resArray.length; i++) { var info = resArray[i]; if (info == "null") { continue; } var infoArray; infoArray = info.split("yyyyyy"); var title = infoArray[0]; var data = infoArray[1]; tabs.push(new GInfoWindowTab(title, data)); } marker.openInfoWindowTabsHtml(tabs); if (leftinfo != "null") { document.getElementById("info").innerHTML = leftinfo; } } }); urchinTracker('/window/' + type + '/' + id + ''); } // end markerShowInfo //----------------------- setupLeftSide -------------------------------// function setupLeftSide() { var url = 'leftside.php'; var myAjax = new Ajax.Request(url, {method: 'get', onComplete: function(response) { document.getElementById("info").innerHTML = response.responseText; } }); } // end setupLeftSide //------------------------ filterPrices ---------------------------------// function filterPrices(minp, maxp) { //alert("n: " + minp + " x: " + maxp + ""); markerSet.clearFilters(); //filter1 = new PAttributeFilter("Type of Business", ["Restaurant"]); //map.removeOverlaySet(markerSet); pricefilter = new PAttributeFilter('aveprice', [minp, maxp], PAttributeFilter.RANGE); markerSet.addFilter(pricefilter); //var filter2 = new PAttributeFilter('maxprice', [minp, maxp], PAttributeFilter.RANGE); //markerSet.addFilter(filter2); //markerSet.setDisplayFilters([filter1,filter2]); //map.addOverlaySet(markerSet); markerSet.addFilter(bedfilter); //widget = new PWidget(map, document.getElementById("widget"), P_WIDGET_OVERLAY_ID); } //------------------------ filterBeds---------------------------------// function filterBeds(beds) { //alert("n: " + beds + ""); var curFilters = markerSet.getFilters(); markerSet.clearFilters(); //filter1 = new PAttributeFilter("Type of Business", ["Restaurant"]); //map.removeOverlaySet(markerSet); bedfilter = new PAttributeFilter('maxbeds', [beds, 100], PAttributeFilter.RANGE); markerSet.addFilter(bedfilter); //var filter2 = new PAttributeFilter('maxprice', [minp, maxp], PAttributeFilter.RANGE); //markerSet.addFilter(filter2); //markerSet.setDisplayFilters([filter1,filter2]); //map.addOverlaySet(markerSet); //restoreFilters(markerSet, curFilters); markerSet.addFilter(pricefilter); //widget = new PWidget(map, document.getElementById("widget"), P_WIDGET_OVERLAY_ID); } //-------------------------- retstoreFilters ----------------------------// function restoreFilters(set, filters) { for(var i = 0; i < filters.length; i++) { set.addFilter(filters[i]); } } // end restoreFilters //-------------------------- searchrad ----------------------------// function searchrad(radius) { var lat = map.getCenter().lat(); var lng = map.getCenter().lng(); var url = 'radialsearch.php?radius=' + radius + '&lat=' + lat + '&lng=' + lng + '';; var myAjax = new Ajax.Request(url, {method: 'get', onComplete: function(response) { document.getElementById("radsearchresults").innerHTML = response.responseText; } }); } //------------------------ addNewAddr ---------------------// function addNewAddr() { // Geocode address, center, add marker and open info window var address = document.getElementById("newaddr").value; var title = document.getElementById("newtitle").value; if (geocoder) { geocoder.getLatLng( address, function(point) { if (!point) alert("Address \"" + address + "\" not found"); else { map.setCenter(point, 11); // FOR BIG MARKER var newIcon = new GIcon(); newIcon.image = "./images/default_marker.png" newIcon.shadow = "./images/default_shadow50.png"; newIcon.iconSize = new GSize(20, 34); newIcon.shadowSize = new GSize(37, 34); newIcon.iconAnchor = new GPoint(9, 33); newIcon.shadowAnchor = new GPoint(9, 33); newIcon.infoWindowAnchor = new GPoint(5, 1); var marker = new GMarker(point, newIcon); map.addOverlay(marker); customlist.push(marker); var lat = marker.getPoint().lat(); var lng = marker.getPoint().lng(); var label = "" + title + "
" + address + ""; label += "

Draw radius | "; label += "1mi | "; label += "2mi | "; label += "5mi | "; label += "10mi | "; marker.openInfoWindowHtml(label); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(label); }); return marker; } } ); } } // end function addNewAddr //---------------------------------- addRadius --------------------------------// function addRadius(lat, lng, radius) { //var lat = marker.getPoint().lat(); //var lng = marker.getPoint().lng(); var radring; radring = drawCircle(lat, lng, '#ff0000', radius); map.addOverlay(radring); radiallist.push(radring); //radialSet.addOverlay(radring); } // end function addRadius //---------------------------------------------- drawCircle -----------------------// function drawCircle(lat,lng,color,radius) { //window.alert(lat + ' ' + lng + ' ' + color + ' ' + radius); var Cradius = radius; // mile radius var Ccolor = color; // color blue var Cwidth = 4; // width pixels var d2r = Math.PI/180; // degrees to radians var r2d = 180/Math.PI; // radians to degrees var Clat = (Cradius/3963)*r2d; // using 3963 as earth's radius var Clng = Clat/Math.cos(lat*d2r); var Cx, Cy; var Cpoints = new Array(); for (var i=0; i < 41; i++) { var theta = Math.PI * (i/20); Cx = lng + (Clng * Math.cos(theta)); Cy = lat + (Clat * Math.sin(theta)); Cpoints.push(new GLatLng(Cy,Cx)); // changed form GPoint }; return new GPolyline(Cpoints,Ccolor,Cwidth); } // ------------------------removeMyMarkers ----------------------------// function removeMyMarkers() { //map.removeOverlaySet(customSet); for(var i = 0; i < customlist.length; i++) { map.removeOverlay(customlist[i]); } customlist.length = 0; } // ---------------------------removeRadials ---------------------------- // function removeRadials() { //map.removeOverlaySet(radialSet); for(var i = 0; i < radiallist.length; i++) { map.removeOverlay(radiallist[i]); } radiallist.length = 0; } //----------------------- getStateChange -----------------------------// function getStateChange(oldzoom, newzoom) { // gmap 0-17 // state = 0-4 // city = 5-7 // apts = 8+ //alert("o " + oldzoom + " n " + newzoom); if (oldzoom <= 6 && newzoom >= 7 && newzoom <= 9) { return "city"; // going from state to city } else if (oldzoom >= 10 && newzoom >= 7 && newzoom <= 9) { return "city"; // going from apts to city } else if (oldzoom <= 9 && newzoom >= 10) { /* setup left side for apt filtering */ //setupLeftSide(); return "apts"; // going from city/state to apts } else if (oldzoom > 6 && newzoom <= 6) { return "state"; //going from city/apts to state } else { return "nochange"; } } //--------------------- updatebounds ------------------------------// function updatebounds() { curbounds = map.getBounds(); cursw = curbounds.getSouthWest(); curne = curbounds.getNorthEast(); } //-------------------- checkbounds --------------------------------// function checkbounds() { // if (cursw.lat() < maxsw.lat()) {window.alert("outside of bounds 1"); } // if (cursw.lng() < maxsw.lng()) {window.alert("outside of bounds 2"); } // if (curne.lat() > maxne.lat()) {window.alert("outside of bounds 3 " + curne.lat() + " > " + maxne.lat()); } // if (curne.lng() > maxne.lng()) {window.alert("outside of bounds 4 " + curne.lng() + " > " + maxne.lng()); } if (cursw.lat() < maxsw.lat() || cursw.lng() < maxsw.lng() || curne.lat() > maxne.lat() || curne.lng() > maxne.lng() ) { if ((curzoomlvl > 6)) { //window.alert("outside of bounds"); //map.clearOverlaySets(); //gmaps map.clearOverlays(); markerlist.length = 0; markerlistID.length = 0; getMarkers(curzoomlvl, curbounds); } // end if } // end if } // end function //----------------updateLocLink------------------------------// function updateLocLink() { var lat = map.getCenter().lat(); var lng = map.getCenter().lng(); var zoom = map.getZoom(); document.getElementById("loclink").href="http://www.therentmap.com/?startlat=" + lat + "&startlng=" + lng + "&startzoom=" + zoom + ""; } // end function updateLocLink // ---------------------- startLoading() ----------------// function startLoading() { document.getElementById("loading").innerHTML = "

Loading...
"; } //--------------------- endLoading() -------------------// function endLoading() { document.getElementById("loading").innerHTML = ""; } //------------------------------------------- centerPlace -------------------------------- // function centerPlace(type) { var zip = document.getElementById("findzip").value; var city = document.getElementById("findcity").value; var state = document.getElementById("findstate").value; if(type == 'city') { var place = "" + city + ", " + state; } else { var place = "" + zip + ""; } // Find place and zoom to bounds if (geocoder && place.replace(/^\s+|\s+$/g,"") != "") { geocoder.getLocations( place, function(response) { if (!response || response.Status.code != 200) alert("Place \"" + place + "\" not found"); else { place = response.Placemark[0]; //alert("len: " + response.Placemark.length + " lat: " + place.Point.coordinates[1]); var lat = place.Point.coordinates[1]; var lng = place.Point.coordinates[0]; point = new GLatLng(lat, lng); //marker = new GMarker(point); //map.addOverlay(marker); map.setCenter(point, 10); var radius = drawCircle(lat, lng, '#000000', 5); //map.addOverlay(radius); map.openInfoWindowHtml(point, place.address); // loop through to try to match state //for(var i=0; i"; addMarkerWindow(title, places[i].getBounds(), places[i].getVertices()); return; } //} // end loop // Info window contents var html = document.createElement("div"); html.style.fontSize = "11px"; var title = document.createElement("div"); title.innerHTML = places[0].getLabel() + getState(places[0]) + " (" + places[0].getType().getName() + ")"; html.appendChild(title); // Add marker and open info window addMarkerWindow(html, places[0].getBounds(), places[0].getVertices()); } } ); } } // ------------------------------------- getState ------------------------------- // function getState(place) { var state = ""; if (place.getState() && place.getType() != PPlaceType.CBSA && place.getType() != PPlaceType.STATE) state = ", " + place.getState(); return state; } // ----------------------------------- markPlaceBoundaries -------------- // function addMarkerWindow(html, bounds, polygons) { //map.setCenterBounds(bounds); map.setCenter(bounds.getCenter(), 7); //var marker = new GMarker(bounds.getCenter()); map.removeOverlay(searchResultMarker); // remove old polygons removeSearchPolygons(); var newIcon = new GIcon(); newIcon.image = "./images/blue_marker.png" newIcon.shadow = "./images/default_shadow50.png"; newIcon.iconSize = new GSize(20, 34); newIcon.shadowSize = new GSize(37, 34); // newIcon.iconAnchor = new GPoint(9, 33); newIcon.iconAnchor = new GPoint(9, 33); // newIcon.shadowAnchor = new GPoint(6, 20); newIcon.shadowAnchor = new GPoint(9, 33); newIcon.infoWindowAnchor = new GPoint(9, 1); searchResultMarker = new GMarker(bounds.getCenter(), newIcon); //map.clearOverlays(); // map.addOverlay(searchResultMarker); // searchResultMarker.openInfoWindow(html); map.openInfoWindowHtml(bounds.getCenter(), html); if (polygons) { for (var i=0; i