if (GBrowserIsCompatible()) { var map; var mapX1 = 0; var mapY1 = 0; var mapX2 = 0; var mapY2 = 0; var mapXoff = 0; var mapYoff = 0; var mapDrag = 1; var mapDragType = 'reset'; var mapSelectOverlay; var markers = new Array(); var hmarkers = new Array(); var cmarker = 0; var mapzoommin = 8; var mapzoommax = 17; var mapzoomdef = 5; var mapRegionOverlay = new Array(); var mapResetBounds = new GBounds(0,0,0,0); var sliderUpdate = 0; var clickcapInterval = 0; var searchdata; var icon_red = new GIcon(); icon_red.image = "http://realtyproweb.com/map/gfx/icon_red.png"; icon_red.shadow = "http://realtyproweb.com/map/gfx/icon_shadow.png"; icon_red.iconSize = new GSize(11,12); icon_red.shadowSize = new GSize(14,15); icon_red.iconAnchor = new GPoint(5,6); icon_red.infoWindowAnchor = new GPoint(13,0); var icon_blue = new GIcon(); icon_blue.image = "http://realtyproweb.com/map/gfx/icon_blue.png"; icon_blue.shadow = "http://realtyproweb.com/map/gfx/icon_shadow.png"; icon_blue.iconSize = new GSize(11,12); icon_blue.shadowSize = new GSize(14,15); icon_blue.iconAnchor = new GPoint(5,6); icon_blue.infoWindowAnchor = new GPoint(13,0); var icon_multred = new GIcon(); icon_multred.image = "http://realtyproweb.com/map/gfx/icon_multred.png"; icon_multred.shadow = "http://realtyproweb.com/map/gfx/icon_multshadow.png"; icon_multred.iconSize = new GSize(15,12); icon_multred.shadowSize = new GSize(18,15); icon_multred.iconAnchor = new GPoint(7,6); icon_multred.infoWindowAnchor = new GPoint(16,0); var icon_multblue = new GIcon(); icon_multblue.image = "http://realtyproweb.com/map/gfx/icon_multblue.png"; icon_multblue.shadow = "http://realtyproweb.com/map/gfx/icon_multshadow.png"; icon_multblue.iconSize = new GSize(15,12); icon_multblue.shadowSize = new GSize(18,15); icon_multblue.iconAnchor = new GPoint(7,6); icon_multblue.infoWindowAnchor = new GPoint(16,0); var icon_clickcap = new GIcon(); icon_clickcap.image = "http://realtyproweb.com/map/gfx/icon_clickcap.png"; icon_clickcap.shadowSize = new GSize(0,0); icon_clickcap.iconAnchor = new GPoint(0,0); } function initMap(mapdiv,xmldata) { if (GBrowserIsCompatible()) { map = new GMap2(mapdiv); mapReset(); icon_clickcap.iconSize = new GSize(getWidth(mapdiv),getHeight(mapdiv)); cmarker = new GMarker(map.fromDivPixelToLatLng(new GPoint(0,0)),{icon:icon_clickcap,draggable:true,dragCrossMove:true}); GEvent.addListener(cmarker, 'mousedown', mapMouseDown); cmarker.enableDragging(); //map.addOverlay(cmarker); if (xmldata && xmldata.length > 0) { searchdata = dat2array(xmldata); addPoints(); } } } function mapResetClickcap() { if (clickcapInterval) clearInterval(clickcapInterval); if (cmarker) { var bounds = map.getBounds(); var nw = new GLatLng(bounds.getNorthEast().lat(),bounds.getSouthWest().lng()); cmarker.setPoint(nw); } } function mapReset() { //if (mapSelectOverlay) // map.removeOverlay(mapSelectOverlay); map.setCenter(new GLatLng(45.7, -122.5)); map.setUIToDefault(); map.setZoom(0); if (mapResetBounds.minX != 0) mapZoomToBounds( mapResetBounds ); else mapZoomTo(mapzoomdef); } var IE = document.all?true:false; var mx = 0; var my = 0; function trackmouse(e) { var tmx = 0; var tmy = 0; if (e) { tmx = e.x; tmy = e.y; } if (IE) { tmx = window.event.clientX + document.body.scrollLeft; tmy = window.event.clientY + document.body.scrollTop; } else { tmx = e.layerX - 2; tmy = e.layerY - 2; } // catch possible negative values in NS4 if (tmx > -1 && tmy > -1) { mx = tmx; my = tmy; } return true; } if (!IE) document.captureEvents(Event.MOUSEMOVE) document.onmousemove = trackmouse; function mapMouseDown() { mapDragType=='reset'; var bounds = map.getBounds(); var se = new GLatLng(bounds.getSouthWest().lat()*2,bounds.getNorthEast().lng()*2); cmarker.setPoint(se); var point = new GPoint(mx,my); // getObject('mapmousediv').style.visibility = 'visible'; mapX1 = point.x;// - mapXoff; mapY1 = point.y;// - mapYoff; mapX2 = mapX1; mapY2 = mapY1; mapDrag = 1; var dragnote = getObject("dragselectnote"); if (mapDragType=='reset') { dragnote.style.visibility = "hidden"; //if (mapSelectOverlay) // map.removeOverlay(mapSelectOverlay); } else if (mapDragType=='line' || mapDragType=='radius') { var mapdiv = getObject('mapdiv'); var bounds = map.getBounds(); var widthLatLng = bounds.getNorthEast().lng() - bounds.getSouthWest().lng(); var heightLatLng = bounds.getNorthEast().lat() - bounds.getSouthWest().lat(); var widthXY = getWidth(mapdiv); var heightXY = getHeight(mapdiv); var mapX1LL = mapX1 / widthXY * widthLatLng + bounds.getSouthWest().lng(); var mapY1LL = bounds.getNorthEast().lat() - mapY1 / heightXY * heightLatLng; var mapX2LL = mapX2 / widthXY * widthLatLng + bounds.getSouthWest().lng(); var mapY2LL = bounds.getNorthEast().lat() - mapY2 / heightXY * heightLatLng; var noterefX, noterefY; if (mapDragType=='line') { noterefX = mapX2 + getLeft(mapdiv); noterefY = mapY2 + getTop(mapdiv); } else { //if (mapSelectOverlay) //map.removeOverlay(mapSelectOverlay); noterefX = mapX2 + getLeft(mapdiv); noterefY = mapY2 + getTop(mapdiv); } dragnote.style.visibility = "hidden"; setLeft(dragnote, noterefX + 5); setTop(dragnote, noterefY + 5); dragnote.innerHTML = mapDistanceMiles( new GPoint(mapX1LL,mapY1LL), new GPoint(mapX2LL,mapY2LL) )+" miles"; if (document.getBoxObjectFor) { var rect = document.getBoxObjectFor(dragnote); if (rect.x + rect.width + 5 - mapXoff > getWidth(mapdiv)) setLeft(dragnote, noterefX - 5 - (rect.width)); if (rect.y + rect.height + 5 - mapYoff > getHeight(mapdiv)) setTop(dragnote, noterefY - 5 - (rect.height)); } else { var rect = dragnote.getBoundingClientRect(); if (rect.right + 5 - mapXoff > getWidth(mapdiv)) setLeft(dragnote, noterefX - 5 - (rect.right-rect.left)); if (rect.bottom + 5 - mapYoff > getHeight(mapdiv)) setTop(dragnote, noterefY - 5 - (rect.bottom-rect.top)); } } } function mapMouseDrag() { mapDrag = 0; return; var point = new GPoint(mx,my); if (mapDrag > 0) { mapDrag = 2; if (mapSelectOverlay) map.removeOverlay(mapSelectOverlay); mapX2 = point.x; mapY2 = point.y; var mapdiv = getObject("mapdiv"); var dragnote = getObject("dragselectnote"); var bounds = map.getBounds(); var widthLatLng = bounds.getNorthEast().lng() - bounds.getSouthWest().lng(); var heightLatLng = bounds.getNorthEast().lat() - bounds.getSouthWest().lat(); var widthXY = getWidth(mapdiv); var heightXY = getHeight(mapdiv); var mapX1LL = mapX1 / widthXY * widthLatLng + bounds.getSouthWest().lng(); var mapY1LL = bounds.getNorthEast().lat() - mapY1 / heightXY * heightLatLng; var mapX2LL = mapX2 / widthXY * widthLatLng + bounds.getSouthWest().lng(); var mapY2LL = bounds.getNorthEast().lat() - mapY2 / heightXY * heightLatLng; if (mapDragType=='rect') { var points = []; points.push( new GPoint(mapX1LL,mapY1LL) ); points.push( new GPoint(mapX2LL,mapY1LL) ); points.push( new GPoint(mapX2LL,mapY2LL) ); points.push( new GPoint(mapX1LL,mapY2LL) ); points.push( new GPoint(mapX1LL,mapY1LL) ); mapSelectOverlay = new GPolyline(points,"#000055",2); map.addOverlay(mapSelectOverlay); } else if (mapDragType=='line') { var points = []; points.push( new GPoint(mapX1LL,mapY1LL) ); points.push( new GPoint(mapX2LL,mapY2LL) ); mapSelectOverlay = new GPolyline(points,"#000055",2); map.addOverlay(mapSelectOverlay); var noterefX = mapX2 + getLeft(mapdiv); var noterefY = mapY2 + getTop(mapdiv); dragnote.style.visibility = "visible"; dragnote.innerHTML = mapDistanceMiles( new GPoint(mapX1LL,mapY1LL), new GPoint(mapX2LL,mapY2LL) )+" miles"; if (document.getBoxObjectFor) { var rect = document.getBoxObjectFor(dragnote); setTop(dragnote, noterefY - 5 - (rect.height)); if (noterefX + (rect.width) + 5 > getWidth(mapdiv)) setLeft(dragnote, noterefX - 5 - (rect.width)); else setLeft(dragnote, noterefX + 8); if (getTop(dragnote) - 5 < 0) setTop(dragnote, noterefY + 5); } else { var rect = dragnote.getBoundingClientRect(); setTop(dragnote, noterefY - 5 - (rect.bottom-rect.top)); if (noterefX + (rect.right-rect.left) + 5 > getWidth(mapdiv)) setLeft(dragnote, noterefX - 5 - (rect.right-rect.left)); else setLeft(dragnote, noterefX + 8); if (getTop(dragnote) - 5 < 0) setTop(dragnote, noterefY + 5); } } else // radius { var points = []; var radius = mapDistanceKilometers( new GPoint(mapX1LL,mapY1LL), new GPoint(mapX2LL,mapY2LL) ) * 1000; var complexity = 15; var radians = Math.PI / 180; var longitudeOffset = radius / (Math.cos(mapY1LL * radians) * 111325); var latitudeOffset = radius / 111325; for (var i = 0; i < 360; i += complexity) { var point = new GPoint(mapX1LL + (longitudeOffset * Math.cos(i * radians)), mapY1LL + (latitudeOffset * Math.sin(i * radians))); points.push(point); } points.push(points[0]); // close the circle points.push( new GPoint(mapX1LL,mapY1LL) ); mapSelectOverlay = new GPolyline(points,'#000055',2); map.addOverlay(mapSelectOverlay); var noterefX = mapX1; var noterefY = mapY1; dragnote.style.visibility = "visible"; setLeft(dragnote, noterefX + 5); setTop(dragnote, noterefY + 5); dragnote.innerHTML = mapDistanceMiles( new GPoint(mapX1LL,mapY1LL), new GPoint(mapX2LL,mapY2LL) )+" miles"; if (document.getBoxObjectFor) { var rect = document.getBoxObjectFor(dragnote); if (rect.x + rect.width + 5 - mapXoff > getWidth(mapdiv)) setLeft(dragnote, noterefX - 5 - (rect.width)); if (rect.y + rect.height + 5 - mapYoff > getHeight(mapdiv)) setTop(dragnote, noterefY - 5 - (rect.height)); } else { var rect = dragnote.getBoundingClientRect(); if (rect.right + 5 - mapXoff > getWidth(mapdiv)) setLeft(dragnote, noterefX - 5 - (rect.right-rect.left)); if (rect.bottom + 5 - mapYoff > getHeight(mapdiv)) setTop(dragnote, noterefY - 5 - (rect.bottom-rect.top)); } } } else { mapDrag = 0; } } function mapMouseUp() { var point = new GPoint(mx,my); if (mapDrag == 2) { mapDrag = 0; mapX2 = point.x; mapY2 = point.y; var mapdiv = getObject("mapdiv"); var points = []; var bounds = map.getBounds(); var widthLatLng = bounds.getNorthEast().lng() - bounds.getSouthWest().lng(); var heightLatLng = bounds.getNorthEast().lat() - bounds.getSouthWest().lat(); var widthXY = getWidth(mapdiv); var heightXY = getHeight(mapdiv); var mapX1LL = mapX1 / widthXY * widthLatLng + bounds.getSouthWest().lng(); var mapY1LL = bounds.getNorthEast().lat() - mapY1 / heightXY * heightLatLng; var mapX2LL = mapX2 / widthXY * widthLatLng + bounds.getSouthWest().lng(); var mapY2LL = bounds.getNorthEast().lat() - mapY2 / heightXY * heightLatLng; if (mapDragType=='rect') { var newbounds = new GBounds(bounds); newbounds.minX = Math.min(mapX1LL,mapX2LL); newbounds.minY = Math.min(mapY1LL,mapY2LL); newbounds.maxX = Math.max(mapX1LL,mapX2LL); newbounds.maxY = Math.max(mapY1LL,mapY2LL); mapZoomToBounds(newbounds); } else if (mapDragType=='line') { if (mapSelectOverlay) map.removeOverlay(mapSelectOverlay); } else if (mapDragType=='radius') { var newbounds = new GBounds(); newbounds.minX = Math.min(mapX1,mapX2) / widthXY * widthLatLng + bounds.getSouthWest().lng(); newbounds.minY = bounds.getNorthEast().lat() - (Math.min(mapY1,mapY2) / heightXY * heightLatLng); newbounds.maxX = Math.max(mapX1,mapX2) / widthXY * widthLatLng + bounds.getSouthWest().lng(); newbounds.maxY = bounds.getNorthEast().lat() - (Math.max(mapY1,mapY2) / heightXY * heightLatLng); var mapX1LL = mapX1 / widthXY * widthLatLng + bounds.getSouthWest().lng(); var mapY1LL = bounds.getNorthEast().lat() - mapY1 / heightXY * heightLatLng; var mapX2LL = mapX2 / widthXY * widthLatLng + bounds.getSouthWest().lng(); var mapY2LL = bounds.getNorthEast().lat() - mapY2 / heightXY * heightLatLng; var radius = mapDistanceKilometers( new GPoint(mapX1LL,mapY1LL), new GPoint(mapX2LL,mapY2LL) ) * 1000; var complexity = 90; var radians = Math.PI / 180; var longitudeOffset = radius / (Math.cos(mapY1LL * radians) * 111325); var latitudeOffset = radius / 111325; for (var i = 0; i < 360; i += complexity) { var x = mapX1LL + (longitudeOffset * Math.cos(i * radians)); var y = mapY1LL + (latitudeOffset * Math.sin(i * radians)); if ( x < newbounds.minX ) newbounds.minX = x; if ( x > newbounds.maxX ) newbounds.maxX = x; if ( y < newbounds.minY ) newbounds.minY = y; if ( y > newbounds.maxY ) newbounds.maxY = y; } mapZoomToBounds(newbounds); } } //getObject("mapmousediv").style.visibility = "hidden"; getObject("dragselectnote").style.visibility = "hidden"; mapResetClickcap(); } function mapMouseOut() { mapDrag = 0; } function markerPopup(point,html) { var offsetX = 20; var offsetY = 0; var bounds = map.getBounds(); var width = bounds.getNorthEast().lng() - bounds.getSouthWest().lng(); var height = bounds.getNorthEast().lat() - bounds.getSouthWest().lat(); var boxsize = map.getSize(); var boxwidth = boxsize.width; var boxheight = boxsize.height; var pixelpoint = new GPoint(); pixelpoint.x = ((point.x - bounds.getSouthWest().lng())/width) * boxwidth; pixelpoint.y = boxheight - (((point.y - bounds.getSouthWest().lat())/height) * boxheight); var popup = getObject("markerpopup"); popup.innerHTML = html; var popwidth = getWidth(popup); var popheight = getHeight(popup); if ( (popwidth+offsetX+10) > boxwidth-pixelpoint.x ) offsetX = -1 * (popwidth+offsetX); if ( (popheight+10) > boxheight-pixelpoint.y ) offsetY = popheight-(boxheight-pixelpoint.y)+15; var newleft = pixelpoint.x + offsetX; var newtop = pixelpoint.y - offsetY; popup.style.position = "absolute"; setLeft(popup, newleft); setTop(popup, newtop); popup.style.visibility = "visible"; } function createMarker(point, number, icon) { var marker = new GMarker(point,icon); var html = basicInfo(searchdata[number]); GEvent.addListener(marker, 'mouseover', function() { markerPopup(point,html); var icondetail = getObject('detail'+number); icondetail.style.backgroundColor = "#CFD1FF"; scrollDetail(number); }); GEvent.addListener(marker, 'mouseout', function() { var popup = getObject("markerpopup"); popup.style.visibility="hidden"; var icondetail = getObject('detail'+number); icondetail.style.backgroundColor = "#FFFFFF"; }); GEvent.addListener(marker, 'click', function() { window.open(detailLink(searchdata[number]),"rprodetail"+number); }); marker.point = point; return marker; } function addPoints() { if (GBrowserIsCompatible()) { // center is GLatLng(45.7, -122.5) var bounds = new GBounds(-150,0,0,100); var detail = ''; for (var i = 0; i < searchdata.length; i++) { if (searchdata[i][10] != 0 && searchdata[i][11] != 0) { if (searchdata[i][10] < bounds.minX) bounds.minX = searchdata[i][10]; if (searchdata[i][10] > bounds.maxX) bounds.maxX = searchdata[i][10]; if (searchdata[i][11] < bounds.minY) bounds.minY = searchdata[i][11]; if (searchdata[i][11] > bounds.maxY) bounds.maxY = searchdata[i][11]; var point = new GPoint( searchdata[i][10], searchdata[i][11] ); markers[i] = createMarker(point,i,icon_blue); map.addOverlay(markers[i]); hmarkers[i] = createMarker(point,i,icon_red); detail += "
| Saved"; else html += "> Save This"; html += " | ";
if (propdata[9]==1)
html += " |
| | ";
if (propdata[9]==0)
html += "Featured Property "; if (propdata[0]=="res" || propdata[0]=="cnd" || propdata[0]=="mfg") { html += "$"+propdata[2]+ " "+propdata[3]+" Bed, "+propdata[4]+" Bath"+ " "+propdata[5]+" Sq. Ft."; } else if (propdata[0]=="com" || propdata[0]=="bus") { html += "$"+propdata[2]+ " "+propdata[5]+" Sq. Ft."+ " "+propdata[3]+" Acres"; //lot size } else if (propdata[0]=="lnd") { html += "$"+propdata[2]+ " "+propdata[3]+" Acres"; //lot size } else if (propdata[0]=="mlt") { html += "$"+propdata[2]+ " "+propdata[5]+" Units"+ " "+(propdata[3] > 0 ? propdata[3]+" Acres" : ""); // lot size } else if (propdata[0]=="frm") { html += "$"+propdata[2]+ " "+propdata[4]+" Acres"; } var mls = propdata[13]=='2'?'nw':'r'; html += " "+propdata[7]+", "+propdata[8]+ " More Info"; if (propdata[10] != 0 && propdata[11] != 0) { html += " Zoom Map ";
}
html += " |