var drawListener,markerCluster,drawMarkers,drawBounds,oldZoom,oldBounds,marker_list=[],mapPin="",map=null,poly=null,storedLongitude="",storedLatitude="",open_info_window=null,mapCenterLat="",mapCenterLng="",mapNorthEast="",mapNorthWest="",mapSouthEast="",mapSouthWest="",boundsChanged=!1,hitCount=0,watchDog=0,x_info_offset=-0,y_info_offset=-180,debounceTime=250,drawingMode=!1;function getUrlParameterObject(e=""){""==e&&(e=window.location.search.substring(1));var t,a,s=e.split("&");for(returnObject={},a=0;ae.apply(this,s),t)}}function markerExistsByLatLng(e,t,a=-1){for(l=new google.maps.LatLng(e,t),y=0;y-1&&(m.setMap(null),indexesToRemove.push(gf));for(gf=0;gf0&&(s=Object.assign({drawMode:!0},s),s=Object.assign({drawMarkers:JSON.stringify(drawMarkers)},s)),url=mapping_ajax_object.ajax_url,jQuery.get(url,s,function(e){if(""!=e){if(dataArray=e,document.getElementById("search-listing-mapper").innerHTML=dataArray.listings,document.getElementById("number-listings-found").innerHTML=dataArray.count,siteURL=dataArray.siteURL,""!=dataArray.map){for(latlngs=dataArray.latlngs;marker_list.length;)marker_list.pop().setMap(null);for(marker_list=[],markerCluster.clearMarkers(),x=0;x0&&(disableDrawMode(),null!=drawBounds&&map.fitBounds(drawBounds))}document.getElementById("number-listings-progress").style.display="none",manageFeaturedTags()},"json")}function getMapBounds(e){if(null==poly){if(progressDiv=document.getElementById("number-listings-progress"),!progressDiv)return;var t=e.getBounds(),a=t.getNorthEast(),s=t.getSouthWest();if(1==boundsChanged)return;if(progressDiv.style.display="inherit",mapNorthEast!=a&&(boundsChanged=!0),mapSouthWest!=s&&(boundsChanged=!0),1==boundsChanged){if(open_info_window&&open_info_window.close(),0==hitCount)return hitCount++,setTimeout(function(){boundsChanged=!1},250),void(document.getElementById("number-listings-progress").style.display="none");doAjax(a,s),setTimeout(function(){boundsChanged=!1},250),jQuery(".pagination").hide()}}}function getInfoBoxContentString(e){var t="";return showMarkerWithPrice(e)&&(t="ct-marker-svg-price"),"contactpage"==e.contactpage?""!=e.thumb?'

'+e.street+'

Driving Directions

':'
':"commercial"==e.commercial||"industrial"==e.industrial||"retail"==e.retail?'

'+e.title+'

'+e.city+", "+e.state+" "+e.zip+'

'+e.size+'

'+e.fullPrice+"

":"land"==e.land?'

'+e.title+'

'+e.city+", "+e.state+" "+e.zip+'

'+e.fullPrice+"

":'

'+e.title+'

'+e.city+", "+e.state+" "+e.zip+'

'+e.bed+' '+e.bath+' '+e.size+'

'+e.fullPrice+"

"}function init_canvas_projection(e){function t(){}t.prototype=new google.maps.OverlayView,t.prototype.constructor=t,t.prototype.onAdd=function(){},t.prototype.draw=function(){},t.prototype.onRemove=function(){},canvasProjectionOverlay=new t,canvasProjectionOverlay.setMap(e)}function convert_offset(e,t,a){var s=canvasProjectionOverlay.getProjection(),r=s.fromLatLngToContainerPixel(e);return r.x=r.x+t,r.y=r.y+a,s.fromContainerPixelToLatLng(r)}function getMapPin(e){return e.ctStatus=e.ctStatus.trim(),"svg"==mapping_ajax_object.listing_marker_type?(svgSize=mapping_ajax_object.ct_listing_marker_svg_size,svgWidth=2*svgSize,svgHeight=2*svgSize,enableMarkerPrice=mapping_ajax_object.ct_enable_marker_price,priceZoomLevel=parseInt(mapping_ajax_object.search_marker_price_zoom_level),svgVersion="?ver=1.0.7",null==e.mapZoom&&(e.mapZoom=map.getZoom()),showMarkerWithPrice(e)?(svgWidth=40,svgHeight=60,labelOriginY=22,e.priceDisplay="true",svgURL=e.siteURL+"/images/svgs/map-marker-price.svg","for-sale"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-for-sale.svg"),"active"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-for-sale.svg"),"for-rent"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-for-rent-rental.svg"),"rental"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-for-rent-rental.svg"),"reo-bank-owned"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-reo-bank-owned.svg"),"short-sale"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-reduced-short-sale.svg"),"leased"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-leased-rented.svg"),"rented"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-leased-rented.svg"),"reduced"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-reduced-short-sale.svg"),"sold"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-sold.svg"),"pending"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-pending.svg"),"open-house"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-open-house.svg"),"available"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-available.svg"),"new-addition"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-new-addition.svg"),"new-listing"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-new-addition.svg"),"special-offer"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-price-for-sale.svg")):(labelOriginY=10,e.priceDisplay="false",svgWidth=3*svgSize,svgHeight=3*svgSize,svgURL=e.siteURL+"/images/svgs/map-marker.svg","for-sale"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-for-sale.svg"),"active"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-for-sale.svg"),"for-rent"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-for-rent-rental.svg"),"rental"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-for-rent-rental.svg"),"reo-bank-owned"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-reo-bank-owned.svg"),"short-sale"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-reduced-short-sale.svg"),"leased"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-leased-rented.svg"),"rented"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-leased-rented.svg"),"reduced"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-reduced-short-sale.svg"),"sold"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-sold.svg"),"pending"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-pending.svg"),"open-house"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-open-house.svg"),"available"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-available.svg"),"new-addition"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-new-addition.svg"),"new-listing"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-new-addition.svg"),"special-offer"==e.ctStatus&&(svgURL=e.siteURL+"/images/svgs/map-marker-for-sale.svg")),svgURL=svgURL+"#"+e.listingID+svgVersion,{url:svgURL,size:new google.maps.Size(svgWidth,svgHeight),scaledSize:new google.maps.Size(svgWidth,svgHeight),labelOrigin:new google.maps.Point(20,labelOriginY)}):"commercial"==e.commercial?{url:e.siteURL+"/images/map-pin-com.png#"+e.listingID,size:new google.maps.Size(40,46),scaledSize:new google.maps.Size(40,46)}:"land"==e.land||"lot"==e.land?{url:e.siteURL+"/images/map-pin-land.png#"+e.listingID,size:new google.maps.Size(40,46),scaledSize:new google.maps.Size(40,46)}:{url:e.siteURL+"/images/map-pin-res.png#"+e.listingID,size:new google.maps.Size(40,46),scaledSize:new google.maps.Size(40,46)}}function cancelDrawing(){jQuery("#map-wrap .drawInstructionBar").remove(),jQuery("#ct-map-navigation, #compare-panel").show(),jQuery("#map .gm-style > div > div > div > div > img").show(),jQuery("#map > div > div > div:nth-child(1) > div:nth-child(1) > div:nth-child(4)").show(),jQuery("#map > div > div > div:nth-child(1) > div:nth-child(3)").css("opacity","1"),drawBounds=null}function drawFreeHand (){poly=new google.maps.Polyline({map:map,clickable:!1});var e=google.maps.event.addListener(map,"mousemove",function(e){poly.getPath().push(e.latLng)}),t=google.maps.event.addListenerOnce(map,"mouseup",function(a){google.maps.event.removeListener(e),google.maps.event.removeListener(t);var s=poly.getPath();poly.setMap(null),poly=new google.maps.Polygon({map:map,path:s,strokeOpacity:.3,fillOpacity:.3,strokeColor:"#8e9092",strokeWeight:1}),google.maps.event.clearListeners(map.getDiv(),"mousedown"),getMarkersInsideDraw(a,poly),drawMarkers.length>0?(oldZoom=map.getZoom(),oldBounds=map.getBounds(),jQuery("#number-listings-progress").css("display","block"),jQuery("#map > div > div > div:nth-child(1) > div:nth-child(3)").css("opacity","0"),doAjax("","",1),jQuery("#map-wrap .drawInstructionBar").remove(),jQuery("#ct-map-navigation, #compare-panel").show()):(cancelDrawing(),disableDrawMode())})}function disableDrawMode(){map.setOptions({draggable:!0,draggableCursor:"grab",zoomControl:!0,scrollwheel:!0,disableDoubleClickZoom:!0}),jQuery("#map .gm-style > div > div > div > div > img").show(),jQuery("#map > div > div > div:nth-child(1) > div:nth-child(1) > div:nth-child(4)").show(),jQuery("#map > div > div > div:nth-child(1) > div:nth-child(3)").css("opacity","1"),drawingMode=!1}function enableDrawMode(){jQuery("#map .gm-style > div > div > div > div > img").hide(),jQuery("#map > div > div > div:nth-child(1) > div:nth-child(1) > div:nth-child(4)").hide(),jQuery("#map > div > div > div:nth-child(1) > div:nth-child(3)").css("opacity","0"),drawingMode=!0,map.setOptions({draggable:!1,draggableCursor:"crosshair",zoomControl:!1,scrollwheel:!1,disableDoubleClickZoom:!1,clickableIcons:!1})}function getMarkersInsideDraw(e,t){drawMarkers=[],drawBounds=new google.maps.LatLngBounds;for(var a=0;a").html(ne).text(),ne=ne.replace("+"," "),sw=getUrlParameter("sw",t),sw=jQuery("
").html(sw).text(),sw=sw.replace("+"," "),paged=getUrlParameter("paged",t),doAjax(ne,sw,paged),jQuery("html, body").animate({scrollTop:0},"slow")),null!=poly&&(jQuery("#number-listings-progress").css("display","block"),e.preventDefault(),paged=parseInt(jQuery(this).html()),doAjax("","",paged),jQuery("html, body").animate({scrollTop:0},"slow")))}),jQuery(document).on("mouseenter",".side-results .listing",function(e){var t=jQuery(this).attr("data-listing-id");if(open_info_window&&(open_info_window.close(),jQuery('img[src="'+open_info_window.closeBoxURL_+'"]').click()),null!=t)for(var a=0;a0?tempMarker.find(".markerClass").first().addClass("ct-active-marker"):tempMarker.append('
'),marker_list[a].infobox)){var s=new google.maps.LatLng(map.getBounds().getNorthEast().lat(),map.getBounds().getSouthWest().lng()),r=new google.maps.LatLng(map.getBounds().getSouthWest().lat(),map.getBounds().getNorthEast().lng()),i=map.getBounds().getSouthWest().distanceFrom(marker_list[a].getPosition()),o=map.getBounds().getNorthEast().distanceFrom(marker_list[a].getPosition()),n=s.distanceFrom(marker_list[a].getPosition()),l=r.distanceFrom(marker_list[a].getPosition());switch(Math.min(i,o,n,l)){case l:ibOffset=new google.maps.Size(-300,150);break;case o:ibOffset=new google.maps.Size(-300,250);break;case n:ibOffset=new google.maps.Size(50,300);break;case i:ibOffset=new google.maps.Size(50,100)}marker_list[a].infobox.setOptions({pixelOffset:ibOffset}),marker_list[a].infobox.open(map,marker_list[a]),open_info_window=marker_list[a].infobox}}),jQuery(document).on("mouseleave",".side-results .listing, .listing-search-results .listing",function(e){var t=jQuery(this).attr("data-listing-id");if(null!=t)for(var a=0;a1){var i=parseFloat(e.latlong.split(",")[0]),o=parseFloat(e.latlong.split(",")[1]),n=new google.maps.LatLng(i,o);-1==markerExistsByLatLng(i,o)&&a(n,e,t)}else s.geocode({address:r},function(s,r){if(r==google.maps.GeocoderStatus.OK){var i=s[0].geometry.location;-1==markerExistsByLatLng(i.lat(),i.lng())&&a(i,e,t)}})}return window.onload=function(){var a=document.getElementById("ct-gmap-next"),s=document.getElementById("ct-gmap-prev");null!=document.getElementById("ct-gmap-draw")&&document.getElementById("ct-gmap-draw").addEventListener("click",function(){return null!=poly?(poly.setMap(null),poly=null,e.map.fitBounds(oldBounds),e.map.setZoom(oldZoom),google.maps.event.trigger(e.map,"zoom_changed"),cancelDrawing(),disableDrawMode(),jQuery(".draw-mode").find("span").html(""),jQuery(".draw-mode").removeClass("draw-mode"),drawMarkers=[],!1):(jQuery("#ct-map-navigation, #compare-panel").hide(),jQuery("#map-wrap").append('
Click and drag to draw your search.Cancel
'),jQuery(this).addClass("draw-mode"),jQuery(this).find("span").html("Clear"),enableDrawMode(),drawListener=google.maps.event.addDomListener(map.getDiv(),"mousedown",function(e){drawingMode?drawFreeHand ():disableDrawMode()}),!1)}),null!=a&&document.getElementById("ct-gmap-next").addEventListener("click",function(){!function(){for(++t>marker_list.length&&(t=1);!1===marker_list[t-1].visible;)++t>marker_list.length&&(t=1);google.maps.event.trigger(marker_list[t-1],"click")}()}),null!=s&&document.getElementById("ct-gmap-prev").addEventListener("click",function(){!function(){for(--t<1&&(t=marker_list.length);!1===marker_list[t-1].visible;)--t>marker_list.length&&(t=1);google.maps.event.trigger(marker_list[t-1],"click")}()})},e.init_property_map=function(t,a,r){var o=ctMapGlobal.mapType,n=ctMapGlobal.mapStyle;ctMapGlobal.mapCustomStyles;if("custom"==n)if(null!=a&&""!=a.mapcenter)var l={zoom:10,center:new google.maps.LatLng(a.mapcenter),mapTypeId:google.maps.MapTypeId[o],disableDefaultUI:!1,scrollwheel:!1,streetViewControl:!1,styles:[{featureType:"water",stylers:[{visibility:"on"},{color:"#acbcc9"}]},{featureType:"landscape",stylers:[{color:"#f2e5d4"}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#c5c6c6"}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#e4d7c6"}]},{featureType:"road.local",elementType:"geometry",stylers:[{color:"#fbfaf7"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#c5dac6"}]},{featureType:"administrative",stylers:[{visibility:"on"},{lightness:33}]},{featureType:"road"},{featureType:"poi.park",elementType:"labels",stylers:[{visibility:"on"},{lightness:20}]},{},{featureType:"road",stylers:[{lightness:20}]}]};else l={mapTypeId:google.maps.MapTypeId[o],disableDefaultUI:!1,scrollwheel:!1,streetViewControl:!1,styles:[{featureType:"water",stylers:[{visibility:"on"},{color:"#acbcc9"}]},{featureType:"landscape",stylers:[{color:"#f2e5d4"}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#c5c6c6"}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#e4d7c6"}]},{featureType:"road.local",elementType:"geometry",stylers:[{color:"#fbfaf7"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#c5dac6"}]},{featureType:"administrative",stylers:[{visibility:"on"},{lightness:33}]},{featureType:"road"},{featureType:"poi.park",elementType:"labels",stylers:[{visibility:"on"},{lightness:20}]},{},{featureType:"road",stylers:[{lightness:20}]}]};else l={zoom:10,center:new google.maps.LatLng(a.mapcenter),mapTypeId:google.maps.MapTypeId[o],disableDefaultUI:!1,scrollwheel:!1,streetViewControl:!0};lat=getUrlParameter("lat",""),lng=getUrlParameter("lng",""),skipBounds=!1,lat&&lng&&(l.center={lat:parseFloat(lat),lng:parseFloat(lng)},skipBounds=!0);var g={ignoreHidden:!0,maxZoom:mapping_ajax_object.search_cluster_zoom_level,styles:[{textColor:"#ffffff",url:r+"/images/cluster-icon.png",height:48,width:48}]};if(e.map=new google.maps.Map(document.getElementById("map"),l),map=e.map,e.bounds=new google.maps.LatLngBounds,init_canvas_projection(e.map),null!=a){var c=google.maps.event.addListener(e.map,"idle",function(){if(t&&t.length)for(mapZoom=1,i=0;i{skipBounds=!1,getMapBounds(e.map)},debounceTime)),google.maps.event.addListener(e.map,"zoom_changed",debounce(()=>{skipBounds=!1,getMapBounds(e.map)},debounceTime))});google.maps.event.addListenerOnce(map,"tilesloaded",function(){})}},e}();