function InfoBox(n){n=n||{};google.maps.OverlayView.apply(this,arguments);this.content_=n.content||"";this.disableAutoPan_=n.disableAutoPan||!1;this.maxWidth_=n.maxWidth||0;this.pixelOffset_=n.pixelOffset||new google.maps.Size(0,0);this.position_=n.position||new google.maps.LatLng(0,0);this.zIndex_=n.zIndex||null;this.boxClass_=n.boxClass||"infoBox";this.boxStyle_=n.boxStyle||{};this.closeBoxMargin_=n.closeBoxMargin||"2px";this.closeBoxURL_=n.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif";n.closeBoxURL===""&&(this.closeBoxURL_="");this.infoBoxClearance_=n.infoBoxClearance||new google.maps.Size(1,1);typeof n.visible=="undefined"&&(n.visible=typeof n.isHidden=="undefined"?!0:!n.isHidden);this.isHidden_=!n.visible;this.alignBottom_=n.alignBottom||!1;this.pane_=n.pane||"floatPane";this.enableEventPropagation_=n.enableEventPropagation||!1;this.div_=null;this.closeListener_=null;this.moveListener_=null;this.contextListener_=null;this.eventListeners_=null;this.fixedWidthSet_=null}function ClusterIcon(n,t){n.getMarkerClusterer().extend(ClusterIcon,google.maps.OverlayView);this.cluster_=n;this.className_=n.getMarkerClusterer().getClusterClass();this.styles_=t;this.center_=null;this.div_=null;this.sums_=null;this.visible_=!1;this.setMap(n.getMap())}function Cluster(n){this.markerClusterer_=n;this.map_=n.getMap();this.gridSize_=n.getGridSize();this.minClusterSize_=n.getMinimumClusterSize();this.averageCenter_=n.getAverageCenter();this.printable_=n.getPrintable();this.markers_=[];this.center_=null;this.bounds_=null;this.clusterIcon_=new ClusterIcon(this,n.getStyles())}function MarkerClusterer(n,t,i){this.extend(MarkerClusterer,google.maps.OverlayView);t=t||[];i=i||{};this.markers_=[];this.clusters_=[];this.listeners_=[];this.activeMap_=null;this.ready_=!1;this.gridSize_=i.gridSize||60;this.minClusterSize_=i.minimumClusterSize||2;this.maxZoom_=i.maxZoom||null;this.styles_=i.styles||[];this.title_=i.title||"";this.zoomOnClick_=!0;i.zoomOnClick!==undefined&&(this.zoomOnClick_=i.zoomOnClick);this.averageCenter_=!1;i.averageCenter!==undefined&&(this.averageCenter_=i.averageCenter);this.ignoreHidden_=!1;i.ignoreHidden!==undefined&&(this.ignoreHidden_=i.ignoreHidden);this.printable_=!1;i.printable!==undefined&&(this.printable_=i.printable);this.imagePath_=i.imagePath||MarkerClusterer.IMAGE_PATH;this.imageExtension_=i.imageExtension||MarkerClusterer.IMAGE_EXTENSION;this.imageSizes_=i.imageSizes||MarkerClusterer.IMAGE_SIZES;this.calculator_=i.calculator||MarkerClusterer.CALCULATOR;this.batchSize_=i.batchSize||MarkerClusterer.BATCH_SIZE;this.batchSizeIE_=i.batchSizeIE||MarkerClusterer.BATCH_SIZE_IE;this.clusterClass_=i.clusterClass||"cluster";navigator.userAgent.toLowerCase().indexOf("msie")!==-1&&(this.batchSize_=this.batchSizeIE_);this.setupStyles_();this.addMarkers(t,!0);this.setMap(n)}function ControlRLLegend(n){var i,t,r;return this.options=$.extend({position:google.maps.ControlPosition.TOP_LEFT,template:"#RL-legend"},n),typeof this.options.template=="string"&&this.options.template[0]==="#"&&(this.options.template=Handlebars.compile($(this.options.template).html())),i=this.options.template(this.options),t=$(n.container).prop("index",1).html(i),this.options.helpBox&&(r=new ControlHelpBox(n),t.append(r)),n.map.controls[n.position].push(t[0]),this}function ControlRLToolbox(n){var t,i;return this.options=$.extend({uid:Date.now()*Math.random()*1e5,position:google.maps.ControlPosition.TOP_LEFT,title:"Show Me",template:Handlebars.compile($("#RL-toolbox").text()),menu:{}},n),this.bounds=[],this.show=function(n){var r=new google.maps.LatLngBounds,t,i;if(n.layer.setMap(this.options.map),n.markers){for(t=0;t<n.markers.length;t++)n.markers[t].setZIndex(google.maps.Marker.MAX_ZINDEX+1),n.markers[t].setVisible(!0),r.extend(n.markers[t].position);this.bounds.push(r);i=new google.maps.LatLngBounds;this.bounds.forEach(function(n){i.union(n)});this.options.map.fitBounds(i)}},this.hide=function(n,t){if(n.layer.setMap(null),n.markers)for(var i=0;i<n.markers.length;i++)n.markers[i].setVisible(!1),t&&t.marker===n.markers[i]&&t.close()},this.render=function(){var n=this,t=this._container=$(this.options.template(this.options));t.dblclick(function(n){n.preventDefault()});t.on("click",".group-label",function(t){t.stopPropagation();var r=!1,f=$(this).parents("[data-group]").attr("data-group"),e=n.options.menu[f],i=e[$(this).parents("[data-layer-name]").attr("data-layer-name")],u=$(t.currentTarget).parents(".group").find(".group-collapse");$(this).find("i").toggleClass("animate");i&&!i.notoggle&&(r=$(this).find("span.toggle:first").toggleClass("on off").is(".off"));$(u).find(".children").children().length>0&&$(u).collapse("toggle");i&&i.layer&&!i.notoggle&&(r?n.hide(i):n.show(i))});t.on("click",".tab-content li",function(t,i){var u;t.stopPropagation();var f=$(this).find(".toggle"),o=$(f).is(".off"),s=$(f).toggleClass("on off").parents("[data-layer-name]").attr("data-layer-name");i&&($(f).removeClass("on").addClass("off"),o=!1);for(var h=$(f).parents("[data-group]").attr("data-group"),c=n.options.menu[h],e=s.split("/"),r=c[e.shift()];r;){if(e.length===0)break;r=r.items&&r.items[e.shift()]}r&&r.layer&&(o?($(t.currentTarget).parent().siblings().find(".children .toggle").removeClass("off").addClass("on"),n.show(r)):(u=$(this).parents(".masterplan").masterplan("instance"),u=u?u.currentPopup:null,n.hide(r,u)),n.options.afterToggle&&n.options.afterToggle(r))});return t},t=this.render(n.map).prop("index",1),this.options.helpBox&&(i=new ControlHelpBox(n),t.append(i)),n.map.controls[n.position].push(t[0]),this.update=function(n){var i=$(this.options.template(this.options)).find(".content-wrapper"),t;$(this._container).find(".content-wrapper").replaceWith(i);$.each(this._container.find(".group"),function(){$(this).find(".children").children().length===0&&$(this).find("i").hide()});n&&(n.activateFirstTab&&(t=$(this._container).find(".tab-pane:first"),t.find(".group .group-label").trigger("click"),n.activateChildren&&t.find(".group li").filter(n.activateChildren).trigger("click")),n.showInterestPoints&&(t=$(this._container).find(".tab-pane:nth-of-type(2)"),t.find(".group .group-label").trigger("click")),n.mapBounds&&this.options.map.fitBounds(n.mapBounds))},this.showForSaleMarkers=function(n){var i,r,t,u;if(!n)if(i=$(this._container).parents(".masterplan").masterplan("instance"),i&&i._propertyMarkers)n=i._propertyMarkers.getMarkers();else return;for(r=new google.maps.LatLngBounds,t=0;t<n.length;t++)n[t].setZIndex(google.maps.Marker.MAX_ZINDEX+1),n[t].setVisible(!0),r.extend(n[t].position);this.bounds.push(r);u=new google.maps.LatLngBounds;this.bounds.forEach(function(n){u.union(n)});this.options.map.fitBounds(u)},this}function ControlFullScreen(n){if(screenfull.enabled){this.options=$.extend({position:google.maps.ControlPosition.TOP_LEFT,template:'<div class="full-screen-control"><i class="fa fa-expand"><\/i><span>Fullscreen<\/span><\/div>',enter:function(){},exit:function(){}},n);var t=this,i=$(n.container).prop("index",1).html(this.options.template).on("click",function(){screenfull.isFullscreen?t.options.exit(n.map,t):t.options.enter(n.map,t);screenfull.toggle(n.map.getDiv())});n.map.controls[n.position].push(i[0])}return this}function ControlZoom(n){var t,i,r;return screenfull.enabled&&(this.options=$.extend({position:google.maps.ControlPosition.TOP_LEFT,template:'<div class="zoom-control"><div class="ctrl zoomin"><i class="fa fa-plus"><\/i><\/div><div class="ctrl zoomout"><i class="fa fa-minus"><\/i><\/div><\/div>',enter:function(){},exit:function(){}},n),t=this,i=$(this.options.container).prop("index",1).html(this.options.template).on("click",".ctrl",function(){var n=t.options.map.getZoom();$(this).hasClass("zoomin")?t.options.map.setZoom(n+1):t.options.map.setZoom(n-1)}),google.maps.event.addListener(t.options.map,"zoom_changed",function(){var n=t.options.map.getZoom();t.options.map.maxZoom==n?i.find(".zoomin").addClass("disable"):i.find(".zoomin").removeClass("disable");t.options.map.minZoom==n?i.find(".zoomout").addClass("disable"):i.find(".zoomout").removeClass("disable")}),this.options.helpBox&&(r=new ControlHelpBox(n),i.append(r)),n.map.controls[n.position].push(i[0])),this}function ControlResetMap(n){var r,t,i;return this.options=$.extend({position:google.maps.ControlPosition.TOP_LEFT,template:'<div class="reset-control"><div class="ctrl">Reset View<\/div><\/div>',enter:function(){},exit:function(){}},n),r=this,t=$(n.container).prop("index",1).html(this.options.template).on("click",".ctrl",function(){var r=$(this).parents(".masterplan"),t,i;r.length!=0&&(t=r.masterplan("mapInstance"),t&&(i=t.Overview(),google.maps.event.trigger(t,"resize"),t.setCenter(n.mapInitialCenter),t.setZoom(n.mapInitialZoom),i&&(google.maps.event.trigger(i,"resize"),i.setCenter(n.mapInitialCenter))))}),this.options.helpBox&&(i=new ControlHelpBox(n),t.append(i)),n.map.controls[n.position].push(t[0]),this}function ControlHelpBox(n){this.options=$.extend({position:google.maps.ControlPosition.TOP_LEFT,template:"#masterplan-helpBox-template"},n);typeof this.options.template=="string"&&this.options.template[0]==="#"&&(this.options.template=Handlebars.compile($(this.options.template).text()));this.render=function(){if(!this.options.helpText&&!this.options.helpHeading)return $("");var n=this._container=$(this.options.template(this.options));n.on("click",function(t){t.stopPropagation();n.hide()});return n};return this.render(this.options.map).prop("index",1)}InfoBox.prototype=new google.maps.OverlayView;InfoBox.prototype.createInfoBoxDiv_=function(){var n,t,i,u=this,r=function(n){n.cancelBubble=!0;n.stopPropagation&&n.stopPropagation()},f=function(n){n.returnValue=!1;n.preventDefault&&n.preventDefault();u.enableEventPropagation_||r(n)};if(!this.div_){if(this.div_=document.createElement("div"),this.setBoxStyle_(),typeof this.content_.nodeType=="undefined"?this.div_.innerHTML=this.getCloseBoxImg_()+this.content_:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(this.content_)),this.getPanes()[this.pane_].appendChild(this.div_),this.addClickHandler_(),this.div_.style.width?this.fixedWidthSet_=!0:this.maxWidth_!==0&&this.div_.offsetWidth>this.maxWidth_?(this.div_.style.width=this.maxWidth_,this.div_.style.overflow="auto",this.fixedWidthSet_=!0):(i=this.getBoxWidths_(),this.div_.style.width=this.div_.offsetWidth-i.left-i.right+"px",this.fixedWidthSet_=!1),this.panBox_(this.disableAutoPan_),!this.enableEventPropagation_){for(this.eventListeners_=[],t=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove"],n=0;n<t.length;n++)this.eventListeners_.push(google.maps.event.addDomListener(this.div_,t[n],r));this.eventListeners_.push(google.maps.event.addDomListener(this.div_,"mouseover",function(){this.style.cursor="default"}))}this.contextListener_=google.maps.event.addDomListener(this.div_,"contextmenu",f);google.maps.event.trigger(this,"domready")}};InfoBox.prototype.getCloseBoxImg_=function(){var n="";return this.closeBoxURL_!==""&&(n="<img",n+=" src='"+this.closeBoxURL_+"'",n+=" align=right",n+=" style='",n+=" position: relative;",n+=" cursor: pointer;",n+=" margin: "+this.closeBoxMargin_+";",n+="'>"),n};InfoBox.prototype.addClickHandler_=function(){var n;this.closeBoxURL_!==""?(n=this.div_.firstChild,this.closeListener_=google.maps.event.addDomListener(n,"click",this.getCloseClickHandler_())):this.closeListener_=null};InfoBox.prototype.getCloseClickHandler_=function(){var n=this;return function(t){t.cancelBubble=!0;t.stopPropagation&&t.stopPropagation();google.maps.event.trigger(n,"closeclick");n.close()}};InfoBox.prototype.panBox_=function(n){var i,y,e=0,f=0,p;if(!n&&(i=this.getMap(),i instanceof google.maps.Map)){i.getBounds().contains(this.position_)||i.setCenter(this.position_);y=i.getBounds();var l=i.getDiv(),a=l.offsetWidth,o=l.offsetHeight,s=this.pixelOffset_.width,r=this.pixelOffset_.height,v=this.div_.offsetWidth,h=this.div_.offsetHeight,c=this.infoBoxClearance_.width,u=this.infoBoxClearance_.height,t=this.getProjection().fromLatLngToContainerPixel(this.position_);t.x<-s+c?e=t.x+s-c:t.x+v+s+c>a&&(e=t.x+v+s+c-a);this.alignBottom_?t.y<-r+u+h?f=t.y+r-u-h:t.y+r+u>o&&(f=t.y+r+u-o):t.y<-r+u?f=t.y+r-u:t.y+h+r+u>o&&(f=t.y+h+r+u-o);e===0&&f===0||(p=i.getCenter(),i.panBy(e,f))}};InfoBox.prototype.setBoxStyle_=function(){var n,t;if(this.div_){this.div_.className=this.boxClass_;this.div_.style.cssText="";t=this.boxStyle_;for(n in t)t.hasOwnProperty(n)&&(this.div_.style[n]=t[n]);this.div_.style.WebkitTransform="translateZ(0)";typeof this.div_.style.opacity!="undefined"&&this.div_.style.opacity!==""&&(this.div_.style.MsFilter='"progid:DXImageTransform.Microsoft.Alpha(Opacity='+this.div_.style.opacity*100+')"',this.div_.style.filter="alpha(opacity="+this.div_.style.opacity*100+")");this.div_.style.position="absolute";this.div_.style.visibility="hidden";this.zIndex_!==null&&(this.div_.style.zIndex=this.zIndex_)}};InfoBox.prototype.getBoxWidths_=function(){var i,n={top:0,bottom:0,left:0,right:0},t=this.div_;return document.defaultView&&document.defaultView.getComputedStyle?(i=t.ownerDocument.defaultView.getComputedStyle(t,""),i&&(n.top=parseInt(i.borderTopWidth,10)||0,n.bottom=parseInt(i.borderBottomWidth,10)||0,n.left=parseInt(i.borderLeftWidth,10)||0,n.right=parseInt(i.borderRightWidth,10)||0)):document.documentElement.currentStyle&&t.currentStyle&&(n.top=parseInt(t.currentStyle.borderTopWidth,10)||0,n.bottom=parseInt(t.currentStyle.borderBottomWidth,10)||0,n.left=parseInt(t.currentStyle.borderLeftWidth,10)||0,n.right=parseInt(t.currentStyle.borderRightWidth,10)||0),n};InfoBox.prototype.onRemove=function(){this.div_&&(this.div_.parentNode.removeChild(this.div_),this.div_=null)};InfoBox.prototype.draw=function(){this.createInfoBoxDiv_();var n=this.getProjection().fromLatLngToDivPixel(this.position_);this.div_.style.left=n.x+this.pixelOffset_.width+"px";this.alignBottom_?this.div_.style.bottom=-(n.y+this.pixelOffset_.height)+"px":this.div_.style.top=n.y+this.pixelOffset_.height+"px";this.div_.style.visibility=this.isHidden_?"hidden":"visible"};InfoBox.prototype.setOptions=function(n){typeof n.boxClass!="undefined"&&(this.boxClass_=n.boxClass,this.setBoxStyle_());typeof n.boxStyle!="undefined"&&(this.boxStyle_=n.boxStyle,this.setBoxStyle_());typeof n.content!="undefined"&&this.setContent(n.content);typeof n.disableAutoPan!="undefined"&&(this.disableAutoPan_=n.disableAutoPan);typeof n.maxWidth!="undefined"&&(this.maxWidth_=n.maxWidth);typeof n.pixelOffset!="undefined"&&(this.pixelOffset_=n.pixelOffset);typeof n.alignBottom!="undefined"&&(this.alignBottom_=n.alignBottom);typeof n.position!="undefined"&&this.setPosition(n.position);typeof n.zIndex!="undefined"&&this.setZIndex(n.zIndex);typeof n.closeBoxMargin!="undefined"&&(this.closeBoxMargin_=n.closeBoxMargin);typeof n.closeBoxURL!="undefined"&&(this.closeBoxURL_=n.closeBoxURL);typeof n.infoBoxClearance!="undefined"&&(this.infoBoxClearance_=n.infoBoxClearance);typeof n.isHidden!="undefined"&&(this.isHidden_=n.isHidden);typeof n.visible!="undefined"&&(this.isHidden_=!n.visible);typeof n.enableEventPropagation!="undefined"&&(this.enableEventPropagation_=n.enableEventPropagation);this.div_&&this.draw()};InfoBox.prototype.setContent=function(n){this.content_=n;this.div_&&(this.closeListener_&&(google.maps.event.removeListener(this.closeListener_),this.closeListener_=null),this.fixedWidthSet_||(this.div_.style.width=""),typeof n.nodeType=="undefined"?this.div_.innerHTML=this.getCloseBoxImg_()+n:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(n)),this.fixedWidthSet_||(this.div_.style.width=this.div_.offsetWidth+"px",typeof n.nodeType=="undefined"?this.div_.innerHTML=this.getCloseBoxImg_()+n:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(n))),this.addClickHandler_());google.maps.event.trigger(this,"content_changed")};InfoBox.prototype.setPosition=function(n){this.position_=n;this.div_&&this.draw();google.maps.event.trigger(this,"position_changed")};InfoBox.prototype.setZIndex=function(n){this.zIndex_=n;this.div_&&(this.div_.style.zIndex=n);google.maps.event.trigger(this,"zindex_changed")};InfoBox.prototype.setVisible=function(n){this.isHidden_=!n;this.div_&&(this.div_.style.visibility=this.isHidden_?"hidden":"visible")};InfoBox.prototype.getContent=function(){return this.content_};InfoBox.prototype.getPosition=function(){return this.position_};InfoBox.prototype.getZIndex=function(){return this.zIndex_};InfoBox.prototype.getVisible=function(){return typeof this.getMap()=="undefined"||this.getMap()===null?!1:!this.isHidden_};InfoBox.prototype.show=function(){this.isHidden_=!1;this.div_&&(this.div_.style.visibility="visible")};InfoBox.prototype.hide=function(){this.isHidden_=!0;this.div_&&(this.div_.style.visibility="hidden")};InfoBox.prototype.open=function(n,t){var i=this;t&&(this.position_=t.getPosition(),this.moveListener_=google.maps.event.addListener(t,"position_changed",function(){i.setPosition(this.getPosition())}));this.setMap(n);this.div_&&this.panBox_()};InfoBox.prototype.close=function(){var n;if(this.closeListener_&&(google.maps.event.removeListener(this.closeListener_),this.closeListener_=null),this.eventListeners_){for(n=0;n<this.eventListeners_.length;n++)google.maps.event.removeListener(this.eventListeners_[n]);this.eventListeners_=null}this.moveListener_&&(google.maps.event.removeListener(this.moveListener_),this.moveListener_=null);this.contextListener_&&(google.maps.event.removeListener(this.contextListener_),this.contextListener_=null);this.setMap(null)};ClusterIcon.prototype.onAdd=function(){var n=this,t,i;this.div_=document.createElement("div");this.div_.className=this.className_;this.visible_&&this.show();this.getPanes().overlayMouseTarget.appendChild(this.div_);google.maps.event.addListener(this.getMap(),"bounds_changed",function(){i=t});google.maps.event.addDomListener(this.div_,"mousedown",function(){t=!0;i=!1});google.maps.event.addDomListener(this.div_,"click",function(r){if(t=!1,!i){var e,f,u=n.cluster_.getMarkerClusterer();google.maps.event.trigger(u,"click",n.cluster_);google.maps.event.trigger(u,"clusterclick",n.cluster_);u.getZoomOnClick()&&(f=u.getMaxZoom(),e=n.cluster_.getBounds(),u.getMap().fitBounds(e),setTimeout(function(){u.getMap().fitBounds(e);f!==null&&u.getMap().getZoom()>f&&u.getMap().setZoom(f+1)},100));r.cancelBubble=!0;r.stopPropagation&&r.stopPropagation()}});google.maps.event.addDomListener(this.div_,"mouseover",function(){var t=n.cluster_.getMarkerClusterer();google.maps.event.trigger(t,"mouseover",n.cluster_)});google.maps.event.addDomListener(this.div_,"mouseout",function(){var t=n.cluster_.getMarkerClusterer();google.maps.event.trigger(t,"mouseout",n.cluster_)})};ClusterIcon.prototype.onRemove=function(){this.div_&&this.div_.parentNode&&(this.hide(),google.maps.event.clearInstanceListeners(this.div_),this.div_.parentNode.removeChild(this.div_),this.div_=null)};ClusterIcon.prototype.draw=function(){if(this.visible_){var n=this.getPosFromLatLng_(this.center_);this.div_.style.top=n.y+"px";this.div_.style.left=n.x+"px"}};ClusterIcon.prototype.hide=function(){this.div_&&(this.div_.style.display="none");this.visible_=!1};ClusterIcon.prototype.show=function(){if(this.div_){var n=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(n);this.div_.innerHTML=this.cluster_.printable_?"<img src='"+this.url_+"'><div style='position: absolute; top: 0px; left: 0px; width: "+this.width_+"px;'>"+this.sums_.text+"<\/div>":this.sums_.text;this.div_.title=typeof this.sums_.title=="undefined"||this.sums_.title===""?this.cluster_.getMarkerClusterer().getTitle():this.sums_.title;this.div_.style.display=""}this.visible_=!0};ClusterIcon.prototype.useStyle=function(n){var i,t;this.sums_=n;i=Math.max(0,n.index-1);i=Math.min(this.styles_.length-1,i);t=this.styles_[i];this.url_=t.url;this.height_=t.height;this.width_=t.width;this.anchor_=t.anchor;this.anchorIcon_=t.anchorIcon||[parseInt(this.height_/2,10),parseInt(this.width_/2,10)];this.textColor_=t.textColor||"black";this.textSize_=t.textSize||11;this.textDecoration_=t.textDecoration||"none";this.fontWeight_=t.fontWeight||"bold";this.fontStyle_=t.fontStyle||"normal";this.fontFamily_=t.fontFamily||"Arial,sans-serif";this.backgroundPosition_=t.backgroundPosition||"0 0"};ClusterIcon.prototype.setCenter=function(n){this.center_=n};ClusterIcon.prototype.createCss=function(n){var t=[];return this.cluster_.printable_||(t.push("background-image:url("+this.url_+");"),t.push("background-position:"+this.backgroundPosition_+";")),typeof this.anchor_=="object"?(typeof this.anchor_[0]=="number"&&this.anchor_[0]>0&&this.anchor_[0]<this.height_?t.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;"):t.push("height:"+this.height_+"px; line-height:"+this.height_+"px;"),typeof this.anchor_[1]=="number"&&this.anchor_[1]>0&&this.anchor_[1]<this.width_?t.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;"):t.push("width:"+this.width_+"px; text-align:center;")):t.push("height:"+this.height_+"px; line-height:"+this.height_+"px; width:"+this.width_+"px; text-align:center;"),t.push("cursor:pointer; top:"+n.y+"px; left:"+n.x+"px; color:"+this.textColor_+"; position:absolute; font-size:"+this.textSize_+"px; font-family:"+this.fontFamily_+"; font-weight:"+this.fontWeight_+"; font-style:"+this.fontStyle_+"; text-decoration:"+this.textDecoration_+";"),t.join("")};ClusterIcon.prototype.getPosFromLatLng_=function(n){var t=this.getProjection().fromLatLngToDivPixel(n);return t.x-=this.anchorIcon_[1],t.y-=this.anchorIcon_[0],t};Cluster.prototype.getSize=function(){return this.markers_.length};Cluster.prototype.getMarkers=function(){return this.markers_};Cluster.prototype.getCenter=function(){return this.center_};Cluster.prototype.getMap=function(){return this.map_};Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_};Cluster.prototype.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center_,this.center_),i=this.getMarkers(),n=0;n<i.length;n++)t.extend(i[n].getPosition());return t};Cluster.prototype.remove=function(){this.clusterIcon_.setMap(null);this.markers_=[];delete this.markers_};Cluster.prototype.addMarker=function(n){var t,i,u;if(this.isMarkerAlreadyAdded_(n))return!1;if(this.center_){if(this.averageCenter_){var r=this.markers_.length+1,f=(this.center_.lat()*(r-1)+n.getPosition().lat())/r,e=(this.center_.lng()*(r-1)+n.getPosition().lng())/r;this.center_=new google.maps.LatLng(f,e);this.calculateBounds_()}}else this.center_=n.getPosition(),this.calculateBounds_();if(n.isAdded=!0,this.markers_.push(n),i=this.markers_.length,u=this.markerClusterer_.getMaxZoom(),u!==null&&this.map_.getZoom()>u)n.getMap()!==this.map_&&n.setMap(this.map_);else if(i<this.minClusterSize_)n.getMap()!==this.map_&&n.setMap(this.map_);else if(i===this.minClusterSize_)for(t=0;t<i;t++)this.markers_[t].setMap(null);else n.setMap(null);return this.updateIcon_(),!0};Cluster.prototype.isMarkerInClusterBounds=function(n){return this.bounds_.contains(n.getPosition())};Cluster.prototype.calculateBounds_=function(){var n=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(n)};Cluster.prototype.updateIcon_=function(){var r=this.markers_.length,n=this.markerClusterer_.getMaxZoom(),t,i;if(n!==null&&this.map_.getZoom()>n){this.clusterIcon_.hide();return}if(r<this.minClusterSize_){this.clusterIcon_.hide();return}t=this.markerClusterer_.getStyles().length;i=this.markerClusterer_.getCalculator()(this.markers_,t);this.clusterIcon_.setCenter(this.center_);this.clusterIcon_.useStyle(i);this.clusterIcon_.show()};Cluster.prototype.isMarkerAlreadyAdded_=function(n){var t;if(this.markers_.indexOf)return this.markers_.indexOf(n)!==-1;for(t=0;t<this.markers_.length;t++)if(n===this.markers_[t])return!0;return!1};MarkerClusterer.prototype.onAdd=function(){var n=this;this.activeMap_=this.getMap();this.ready_=!0;this.repaint();this.listeners_=[google.maps.event.addListener(this.getMap(),"zoom_changed",function(){n.resetViewport_(!1);(this.getZoom()===(this.get("minZoom")||0)||this.getZoom()===this.get("maxZoom"))&&google.maps.event.trigger(this,"idle")}),google.maps.event.addListener(this.getMap(),"idle",function(){n.redraw_()})]};MarkerClusterer.prototype.onRemove=function(){for(var n=0;n<this.markers_.length;n++)this.markers_[n].setMap(this.activeMap_);for(n=0;n<this.clusters_.length;n++)this.clusters_[n].remove();for(this.clusters_=[],n=0;n<this.listeners_.length;n++)google.maps.event.removeListener(this.listeners_[n]);this.listeners_=[];this.activeMap_=null;this.ready_=!1};MarkerClusterer.prototype.draw=function(){};MarkerClusterer.prototype.setupStyles_=function(){var n,t;if(!(this.styles_.length>0))for(n=0;n<this.imageSizes_.length;n++)t=this.imageSizes_[n],this.styles_.push({url:this.imagePath_+(n+1)+"."+this.imageExtension_,height:t,width:t})};MarkerClusterer.prototype.fitMapToMarkers=function(){for(var t=this.getMarkers(),i=new google.maps.LatLngBounds,n=0;n<t.length;n++)i.extend(t[n].getPosition());this.getMap().fitBounds(i)};MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_};MarkerClusterer.prototype.setGridSize=function(n){this.gridSize_=n};MarkerClusterer.prototype.getMinimumClusterSize=function(){return this.minClusterSize_};MarkerClusterer.prototype.setMinimumClusterSize=function(n){this.minClusterSize_=n};MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_};MarkerClusterer.prototype.setMaxZoom=function(n){this.maxZoom_=n};MarkerClusterer.prototype.getStyles=function(){return this.styles_};MarkerClusterer.prototype.setStyles=function(n){this.styles_=n};MarkerClusterer.prototype.getTitle=function(){return this.title_};MarkerClusterer.prototype.setTitle=function(n){this.title_=n};MarkerClusterer.prototype.getZoomOnClick=function(){return this.zoomOnClick_};MarkerClusterer.prototype.setZoomOnClick=function(n){this.zoomOnClick_=n};MarkerClusterer.prototype.getAverageCenter=function(){return this.averageCenter_};MarkerClusterer.prototype.setAverageCenter=function(n){this.averageCenter_=n};MarkerClusterer.prototype.getIgnoreHidden=function(){return this.ignoreHidden_};MarkerClusterer.prototype.setIgnoreHidden=function(n){this.ignoreHidden_=n};MarkerClusterer.prototype.getImageExtension=function(){return this.imageExtension_};MarkerClusterer.prototype.setImageExtension=function(n){this.imageExtension_=n};MarkerClusterer.prototype.getImagePath=function(){return this.imagePath_};MarkerClusterer.prototype.setImagePath=function(n){this.imagePath_=n};MarkerClusterer.prototype.getImageSizes=function(){return this.imageSizes_};MarkerClusterer.prototype.setImageSizes=function(n){this.imageSizes_=n};MarkerClusterer.prototype.getCalculator=function(){return this.calculator_};MarkerClusterer.prototype.setCalculator=function(n){this.calculator_=n};MarkerClusterer.prototype.getPrintable=function(){return this.printable_};MarkerClusterer.prototype.setPrintable=function(n){this.printable_=n};MarkerClusterer.prototype.getBatchSizeIE=function(){return this.batchSizeIE_};MarkerClusterer.prototype.setBatchSizeIE=function(n){this.batchSizeIE_=n};MarkerClusterer.prototype.getClusterClass=function(){return this.clusterClass_};MarkerClusterer.prototype.setClusterClass=function(n){this.clusterClass_=n};MarkerClusterer.prototype.getMarkers=function(){return this.markers_};MarkerClusterer.prototype.getTotalMarkers=function(){return this.markers_.length};MarkerClusterer.prototype.getClusters=function(){return this.clusters_};MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length};MarkerClusterer.prototype.addMarker=function(n,t){this.pushMarkerTo_(n);t||this.redraw_()};MarkerClusterer.prototype.addMarkers=function(n,t){for(var i=0;i<n.length;i++)this.pushMarkerTo_(n[i]);t||this.redraw_()};MarkerClusterer.prototype.pushMarkerTo_=function(n){if(n.getDraggable()){var t=this;google.maps.event.addListener(n,"dragend",function(){t.ready_&&(this.isAdded=!1,t.repaint())})}n.isAdded=!1;this.markers_.push(n)};MarkerClusterer.prototype.removeMarker=function(n,t){var i=this.removeMarker_(n);return!t&&i&&this.repaint(),i};MarkerClusterer.prototype.removeMarkers=function(n,t){for(var u,r=!1,i=0;i<n.length;i++)u=this.removeMarker_(n[i]),r=r||u;return!t&&r&&this.repaint(),r};MarkerClusterer.prototype.removeMarker_=function(n){var t,i=-1;if(this.markers_.indexOf)i=this.markers_.indexOf(n);else for(t=0;t<this.markers_.length;t++)if(n===this.markers_[t]){i=t;break}return i===-1?!1:(n.setMap(null),this.markers_.splice(i,1),!0)};MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport_(!0);this.markers_=[]};MarkerClusterer.prototype.repaint=function(){var n=this.clusters_.slice();this.clusters_=[];this.resetViewport_(!1);this.redraw_();setTimeout(function(){for(var t=0;t<n.length;t++)n[t].remove()},0)};MarkerClusterer.prototype.getExtendedBounds=function(n){var t=this.getProjection(),e=new google.maps.LatLng(n.getNorthEast().lat(),n.getNorthEast().lng()),o=new google.maps.LatLng(n.getSouthWest().lat(),n.getSouthWest().lng()),r=t.fromLatLngToDivPixel(e),i,u,f;return r.x+=this.gridSize_,r.y-=this.gridSize_,i=t.fromLatLngToDivPixel(o),i.x-=this.gridSize_,i.y+=this.gridSize_,u=t.fromDivPixelToLatLng(r),f=t.fromDivPixelToLatLng(i),n.extend(u),n.extend(f),n};MarkerClusterer.prototype.redraw_=function(){this.createClusters_(0)};MarkerClusterer.prototype.resetViewport_=function(n){for(var i,t=0;t<this.clusters_.length;t++)this.clusters_[t].remove();for(this.clusters_=[],t=0;t<this.markers_.length;t++)i=this.markers_[t],i.isAdded=!1,n&&i.setMap(null)};MarkerClusterer.prototype.distanceBetweenPoints_=function(n,t){var i=(t.lat()-n.lat())*Math.PI/180,r=(t.lng()-n.lng())*Math.PI/180,u=Math.sin(i/2)*Math.sin(i/2)+Math.cos(n.lat()*Math.PI/180)*Math.cos(t.lat()*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2),f=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u));return 6371*f};MarkerClusterer.prototype.isMarkerInBounds_=function(n,t){return t.contains(n.getPosition())};MarkerClusterer.prototype.addToClosestCluster_=function(n){for(var u,t,f,e=4e4,r=null,i=0;i<this.clusters_.length;i++)t=this.clusters_[i],f=t.getCenter(),f&&(u=this.distanceBetweenPoints_(f,n.getPosition()),u<e&&(e=u,r=t));r&&r.isMarkerInClusterBounds(n)?r.addMarker(n):(t=new Cluster(this),t.addMarker(n),this.clusters_.push(t))};MarkerClusterer.prototype.createClusters_=function(n){var i,t,u,e=this,f,r;if(this.ready_){for(n===0&&(google.maps.event.trigger(this,"clusteringbegin",this),typeof this.timerRefStatic!="undefined"&&(clearTimeout(this.timerRefStatic),delete this.timerRefStatic)),u=this.getMap().getZoom()>3?new google.maps.LatLngBounds(this.getMap().getBounds().getSouthWest(),this.getMap().getBounds().getNorthEast()):new google.maps.LatLngBounds(new google.maps.LatLng(85.020707717434718,-178.48388434375),new google.maps.LatLng(-85.081364443845445,178.00048865625)),f=this.getExtendedBounds(u),r=Math.min(n+this.batchSize_,this.markers_.length),i=n;i<r;i++)t=this.markers_[i],!t.isAdded&&this.isMarkerInBounds_(t,f)&&(!this.ignoreHidden_||this.ignoreHidden_&&t.getVisible())&&this.addToClosestCluster_(t);r<this.markers_.length?this.timerRefStatic=setTimeout(function(){e.createClusters_(r)},0):(delete this.timerRefStatic,google.maps.event.trigger(this,"clusteringend",this))}};MarkerClusterer.prototype.extend=function(n,t){return function(n){for(var t in n.prototype)this.prototype[t]=n.prototype[t];return this}.apply(n,[t])};MarkerClusterer.CALCULATOR=function(n,t){for(var i=0,u=n.length.toString(),r=u;r!==0;)r=parseInt(r/10,10),i++;return i=Math.min(i,t),{text:u,index:i,title:""}};MarkerClusterer.BATCH_SIZE=2e3;MarkerClusterer.BATCH_SIZE_IE=500;MarkerClusterer.IMAGE_PATH="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m";MarkerClusterer.IMAGE_EXTENSION="png";MarkerClusterer.IMAGE_SIZES=[53,56,66,78,90];google.maps.Map.prototype.Overview=function(n){function r(n){this.setMap(n)}function f(){return map.sub_map}var t,u,i;return(r.prototype=new google.maps.OverlayView,t={zoom_difference:3,rectangle:!0,rectangle_border_width:2,rectangle_color:"00f",rectangle_opacity:.3,box_width:150,box_height:150},n&&$.extend(t,n),u={zoom:this.zoom-t.zoom_difference,center:this.getCenter(),mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControl:!1,navigationControl:!1,scaleControl:!1,streetViewControl:!1,scrollwheel:!1,disableDoubleClickZoom:!0},map=this,map.sub_map=this.sub_map,map.rectangle=this.rectangle,i=map.getDiv(),r.prototype.draw=function(){var n=this.div_,h=this,r,f,s,e,o;n||(n=$("<div>",{"class":"overview-container",css:{width:t.box_width+"px",height:t.box_height+"px"}}),r=$("<div>",{"class":"overview-children"}),f=$("<div>",{"class":"overview-arrow"}),this.div_=n,$(i).append(n),$(n).append(r),$(i).append(f),map.sub_map||(map.sub_map=new google.maps.Map(r.get(0),u),s=new google.maps.Marker({position:t.center,map:map.sub_map,title:""})),t.rectangle&&!map.rectangle&&(map.rectangle=new google.maps.Rectangle({bounds:map.getBounds(),fillColor:"#"+t.rectangle_color,fillOpacity:t.rectangle_opacity,strokeColor:"#"+t.rectangle_color,strokeWeight:t.rectangle_border_width,strokeOpacity:t.rectangle_opacity<.7?t.rectangle_opacity+.3:1}),map.rectangle.setMap(map.sub_map)),$(f).click(function(){$(".overview-container").toggleClass("closed")}),map.addListener("bounds_changed",function(){this.rectangle&&(this.getZoom()>t.zoom_difference?(this.rectangle.getMap()||this.rectangle.setMap(this.sub_map),this.rectangle.setBounds(this.getBounds())):this.rectangle.setMap(null))}),map.addListener("zoom_changed",function(){zoom=this.getZoom();zoom>t.zoom_difference&&this.sub_map.setZoom(this.zoom-t.zoom_difference)}),map.addListener("drag",function(){this.sub_map.setCenter(this.getCenter())}),map.sub_map.addListener("drag",function(){map.setCenter(this.getCenter())}),map.sub_map.addListener("dblclick",function(){this.setZoom(map.getZoom()-t.zoom_difference);this.setCenter(map.getCenter())}),t.helpBox&&(e={map:map,position:google.maps.ControlPosition.RIGHT_BOTTOM},$.extend(e,t),o=new ControlHelpBox(e),n.append(o)))},!n)?f():new r(map)},function(n){n.widget("RL.masterplan",{options:{useRemainingSpace:!1,isDebug:!1,disableGoogleLinks:!1,preventPinch:!1,mapNamespace:null,showOverviewControl:!1,showAllHelpBoxes:!1,defaults:{map:{center:[0,0],zoom:16,base:{$type:"Google"},zoomChange:15},menu:{Layers:{},"Interest Points":{}},overview:{rectangle_color:"f00",rectangle_border_width:2,img_width:15,img_height:15}},layers:[],marker:{visible:!1,optimized:!1,icon:{url:"/RL/api/RLmap/GetMarkerIcon",size:new google.maps.Size(40,52),scaledSize:new google.maps.Size(40,52),anchor:new google.maps.Point(20,52)}},activeMenu:"Layers",cluster:{gridSize:100,minimumClusterSize:2,maxZoom:18,styles:[{fontFamily:"Circular-Book",height:36,width:36,textSize:16,textColor:"white"},{fontFamily:"Circular-Book",height:48,width:48,textSize:18,textColor:"white"}],calculator:function(n){var t=n.length.toString();return{text:t,index:t>=10?2:1,title:""}},ignoreHidden:!0}},mapInstance:function(){return this._map},_create:function(){if(this._superApply(arguments),this._map=null,this._mapEl=this.element.find(".map-container"),this._executeConfigActions(),this._toolboxConfig={menu:this.options.menu,position:google.maps.ControlPosition.TOP_RIGHT,helpBox:this.options.showAllHelpBoxes},this.options.showAllHelpBoxes&&n.extend(this._toolboxConfig,this.options.toolBoxHelper),this.options.activeMenu)for(var t in this.options.menu)this.options.activeMenu===t&&(this._toolboxConfig.menu[t].active=!0);this._layers={};this._buildMap(this.options)},_executeConfigActions:function(){if(this.options.disableGoogleLinks)this.element.on("tap click",'a[href*="google.com"]',function(n){return n.preventDefault(),n.stopPropagation(),!1});if(this.options.preventPinch)this.element.on("touchstart",function(n){n.touches.length>=2&&(n.preventDefault(),n.stopPropagation())});if(this.options.useRemainingSpace)var t=n("body").height()-n(this.element).height(),i=n(window).height()-t},_formatBuildType:function(n){var t=n.replace(/-([a-z])/g,function(n){return n[1].toUpperCase()});return t.charAt(0).toUpperCase()+t.substring(1)},_buildType:function(n,t){return new n(t[0],t[1],t[2],t[3])},_build:function(n,t){for(var f=n.$type,e=n.$arguments||[],u=f.split("."),r=this._formatBuildType(u.shift()),i=t?t[r]:(this.options.mapNamespace||google.maps)[r];i;){if(u.length===0)break;r=this._formatBuildType(u.shift());i=i[r]}if(!i)throw new Error("No type found: "+f);return this._buildType(i,e)},_styles:{},_getStyleFromClass:function(t,i){var u,f,e,o,r;if(this._styles[t])return this._styles[t];i=i||{fill:"fillColor"};u=n('<div class="_GET_STYLE">').append(n("<div>").addClass(t)).hide().appendTo(this.element);f=u.children().css(Object.keys(i));this._styles[t]={};for(e in f)o={},r=f[e],r.indexOf("px")>=0&&(r=parseFloat(r)),o[i[e]]=r,n.extend(this._styles[t],o);return u.remove(),this._styles[t]},_addGroup:function(t,i,r,u,f,e){var o=this;u.toGeoJson(function(s){t=o._toolboxConfig.menu[t];var l={label:r,feature:s},c=s.properties,h=o._build({$type:"data"});h.setStyle(function(t){var r=t.getProperty("cssName"),u=o._getStyleFromClass(r,{fill:"fillColor","stroke-width":"strokeWeight","border-color":"strokeColor"}),i=n.extend(u,{className:t.getProperty("cssName"),clickable:!1});return o.options.isDebug&&(i.strokeWeight=1,i.strokeColor="red"),i});f?(t[f]?h.add(u):t[f]=n.extend({items:{},layer:h},c),t[f].layer.add(h),t[f].items[i]=n.extend({layer:h},c,l)):t[i]?(n.extend(t[i],c,l),t[i].layer.add(u)):(h.add(u),t[i]=n.extend({items:{},layer:h},c,l));s.properties.notoggle&&h.setMap(o._map);e&&e(h,u)})},_getGroup:function(n,t){var t=this._toolboxConfig.menu[t],i;for(n=n.split("/"),i=t[n.shift()];i;){if(n.length===0)break;i=i.items&&i.items[n.shift()]}return i},_addMarkerToGroup:function(n,t,i){var r=this._getGroup(t,n);r&&(r.markers||(r.markers=[]),r.markers.push(i))},_zoomChanged:function(t,i,r,u){var f=this;zoomLevel=f._map.getZoom();n.each(f._markers.markers_,function(){var n=this.getIcon();zoomLevel<t.zoomChange&&n.secondaryUrl?(n.url=n.secondaryUrl,n.size=f.options.marker.icon.size,n.scaledSize=f.options.marker.icon.scaledSize,n.anchor=f.options.marker.icon.anchor,this.setIcon(n),this.setClickable(!0)):zoomLevel>=t.zoomChange&&n.primaryUrl&&(n.url=n.primaryUrl,n.size=new google.maps.Size(this.width,this.height),n.scaledSize=new google.maps.Size(this.origWidth,this.origHeight),n.anchor=new google.maps.Point(this.origWidth/2,this.origHeight/2),this.setIcon(n),this.setClickable(!1),f.currentPopup&&f.currentPopup.close())});r=Math.max(r,0);u=u?u:100;zoomLevel<=r||zoomLevel>u?i.setMap(null):i.setMap(f._map)},_setupZoomLevels:function(n,t,i,r){var u=this;i=Math.max(i,0);r=r?r:100;(n.zoomChange>=r||n.zoomChange<=i)&&(n.zoomChange=n.zoom);u._map.addListener("zoom_changed",function(){u._zoomChanged(n,t,i,r)});u._zoomChanged(n,t,i,r)},_rgbToHex:function(n){return(n||"").replace(/\brgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/g,function(n,t,i,r){return"#"+("0"+Number(t).toString(16)).substr(-2)+("0"+Number(i).toString(16)).substr(-2)+("0"+Number(r).toString(16)).substr(-2)})},_addFeature:function(t,i){for(var c,w,l,a,h,v,k=this,y=0;y<t.length;y++){var r=t[y],g=r.getProperty("notoggle"),f=r.getProperty("grouping"),o=r.getProperty("group"),nt=r.getProperty("popup"),d=r.getProperty("minZoom"),tt=r.getProperty("maxZoom"),p;if(f&&!o&&(w=o?o+"/"+f.name:f.name,c=f.label,c=="Residential"&&(r.setProperty("minZoom",16),d=16),p=this._addGroup(i,w,c,r,null)),o)if(f)c=f.label,w=o+"/"+f.name,p=this._addGroup(i,f.name,c,r,o);else{if(l=r.getGeometry().get(),l.lat()===0)continue;var e=r.getProperty("cssName"),u=r.getProperty("image"),it=function(t){var r=n(window).width()>1920,u=n(window).width()>2600,i;return u?(i=[null,.5,.7,1,1.5],i[t===i.length?i.length-1:t]):r?(i=[null,.5,.7,1,1.5],i[t===i.length?i.length-1:t]):(i=[null,.2,.8,1],i[t===i.length?i.length-1:t])},s,h,b;u&&u.url?(e&&(a=k._getStyleFromClass(e,{fill:"fill"}),h=e.match(/marker-([\S]+)/),h&&(b=this.options.marker.icon.url+"?icon="+h[1]+"&colour="+encodeURIComponent(this._rgbToHex(a.fill)))),v=n.extend(!0,{position:l,clickable:!1,optimized:!1,zIndex:0},this.options.marker,{icon:{url:u.url,primaryUrl:u.url,secondaryUrl:b?b:"",size:new google.maps.Size(u.width,u.height),scaledSize:new google.maps.Size(u.width,u.height),origin:new google.maps.Point(0,0),anchor:new google.maps.Point(u.width/2,u.height/2)},height:u.height,width:u.width,origHeight:u.height,origWidth:u.width}),s=new google.maps.Marker(v),e&&h&&this._markerClick(s,{cssName:e,popup:r.getProperty("popup")})):(a=k._getStyleFromClass(e,{fill:"fill"}),h=e.match(/marker-([\S]+)/),h&&(v=n.extend(!0,{position:l,zIndex:1},this.options.marker,{icon:{url:this.options.marker.icon.url+"?icon="+h[1]+"&colour="+encodeURIComponent(this._rgbToHex(a.fill))}}),s=new google.maps.Marker(v),this._markerClick(s,{cssName:e,popup:r.getProperty("popup")})));s&&(this._markers.addMarker(s,!0),p=this._addMarkerToGroup(i,o,s))}}this._markers.repaint()},_markerClick:function(n,t){var i=this;n.addListener("click",function(r){var u=t._popup,f=t.popup;if(f){if(i.currentPopup){if(u===i.currentPopup){i.currentPopup.close();i.currentPopup=null;return}i.currentPopup.close()}if(u){i.currentPopup=u;i.currentPopup.open(i._map);return}i.currentPopup=i._build({$type:"info-box",$arguments:[{content:'<span class="popup-marker">'+f+"<\/span>",position:r.latLng,pixelOffset:new google.maps.Size(30,-42),closeBoxURL:"",boxClass:t.cssName+" popup-label",maxWidth:120},r.feature]},window);i.currentPopup.marker=n;t._popup=i.currentPopup;i.currentPopup.open(i._map)}})},_buildToolbox:function(){var t=this._toolboxConfig,i=document.createElement("div"),r;return i.className="control-RL-toolbox",r=this,n.extend(t,{map:this._map,container:i,afterToggle:function(){r._markers.repaint()}}),this._toolbox=new ControlRLToolbox(t),this._toolbox},_buildMap:function(t){var i=this,l=n.extend({},this.options.defaults.map,t.map,this.options.map),f=n.extend([],this.options.defaults.base,t.base),y=n.extend([],this.options.defaults.overview,t.overview),o,e,a,p,r,v,s,h,c,u;if(this._map=this._build({$type:"map",$arguments:[this._mapEl[0],l]}),this.options.map.controls)for(r=0;r<this.options.map.controls.length;r++)o=document.createElement("div"),o.className=this.options.map.controls[r].$type,e={},a=this.options.map.controls[r].$arguments||[],n.each(a,function(t,i){n.extend(e,i)}),n.extend(e,{container:o,map:this._map}),p=this._build({$type:this.options.map.controls[r].$type,$arguments:[e]},window);for(r=0;r<f.length;r++)n.extend(f[r].$arguments[0],{map:this._map}),v=this._build(f[r]),this._map.overlayMapTypes.push(v),s=f[r].$arguments[0],this.options.map.zoom===0&&(this._tileBounds?this._tileBounds.extend(s.bounds):this._tileBounds=s.bounds);if(this.options.disableMarkers||(this._markers=new MarkerClusterer(this._map,[],this.options.cluster),this._propertyMarkers=new MarkerClusterer(i._map,[],i.options.cluster)),this.options.menu&&(h=0,c=0,n.each(this.options.menu,function(n,t){t.url&&h++}),n.each(this.options.menu,function(t,r){if(r.url){var u=new google.maps.Data({map:null,featureFactory:function(){}});u.loadGeoJson(r.url,null,function(u){c++;i._addFeature(u,t);delete r.url;i._toolbox.update({mapBounds:i.options.map.mapBounds,activateFirstTab:i.options.map.activateFirstTab,activateChildren:i.options.map.activateChildren,showInterestPoints:i.options.map.showInterestPoints});c==h&&setTimeout(function(){n(i.element).find(".reset-control .ctrl").click()},100)})}}),this.options.disableToolbox||i._buildToolbox(),this.options.showOverviewControl&&i._map.Overview(y)),this.options.propertyBoundary){i=this;u=this._build({$type:"data"});i._setupZoomLevels(l,u,16);u.setStyle(function(t){var r=i._getStyleFromClass("plot "+t.getProperty("info").Status.replace(" ","-").toLowerCase());return n.extend(r,{strokeWeight:2,strokeOpacity:.7,strokeColor:"#ffffff",fillOpacity:1,zIndex:1})});u.addListener("click",function(t){var r=t.feature.getProperty("info"),u,f;if(i.options.isTabletop||(u=RL.localStorage.checkforItem(r.AgentPointId,RL.propertiesToCompare),f="unchecked",u&&(f="check"),r.iconClass=f),i.popup&&i.popup.close(),i.popup=i._build({$type:"info-window",$arguments:[{content:i.options.isTabletop?Handlebars.compile(n("#property-card-map-tabletop").text())(r):Handlebars.compile(n("#property-card-map").text())(r),position:t.latLng},t.feature]}),t.feature.setProperty("_popup",i.popup),i.popup.open(i._map),!i.options.isTabletop){var e=n(i.element).find(".action-bar .compare"),o=RL.localStorage.getItem(RL.propertiesToCompare),u=RL.localStorage.checkforItem(n(e).attr("data-property-id"),RL.propertiesToCompare);!u&&o&&o.length===RL.propertiesToCompare.maxnumber?(n(e).find(".full").show(),n(e).find(".available,.glyphicon").hide(),i.popup.capacity=!0):i.popup.capacity=!1}});n(i.element).on("click",".action-bar .compare",function(){if(!i.popup.capacity){var r=RL.localStorage.checkforItem(n(this).attr("data-property-id"),RL.propertiesToCompare),t=n(i.element).find(".action-bar .compare");r?(n(this).find(".glyphicon").removeClass("glyphicon-check").addClass("glyphicon-unchecked"),n.RL.propertyCompare.remove(n(this).attr("data-property-id")),n(t).removeClass("glyphicon-check").addClass("glyphicon-unchecked")):(n(this).find(".glyphicon").removeClass("glyphicon-unchecked").addClass("glyphicon-check"),n.RL.propertyCompare.add(this),n(t).removeClass("glyphicon-unchecked").addClass("glyphicon-check"))}});u.addListener("mouseover",function(n){u.revertStyle();u.overrideStyle(n.feature,{strokeOpacity:1})});u.addListener("mouseout",function(){u.revertStyle()});n.ajax(this.options.propertyBoundary).done(function(t){var o={type:"FeatureCollection",features:[]},e,r,a;if(t.results!==null){for(e=0;e<t.results.length;e++)if(r=t.results[e],r.BoundaryData)try{var s=[JSON.parse(r.BoundaryData)],v={type:"Feature",geometry:{type:"Polygon",coordinates:s},properties:{info:r}},h=i._findMidpoint(s);r.Latitude=h.lat;r.Longitude=h.long;o.features.push(v);var c="marker-For_Sale_Properties",f,y=i._getStyleFromClass(c,{fill:"fill"}),l=c.match(/marker-([\S]+)/);l&&(a=n.extend(!0,{position:{lat:r.Latitude,lng:r.Longitude},zIndex:1},i.options.marker,{icon:{url:i.options.marker.icon.url+"?icon="+l[1]+"&colour="+encodeURIComponent(i._rgbToHex(y.fill))},info:r}),f=new google.maps.Marker(a),f.addListener("click",function(t){var r=this.info;r.Latitude&&r.Longitude&&(i._map.panTo({lat:r.Latitude,lng:r.Longitude}),i._map.setZoom(i.options.map.maxZoom));i.popup&&i.popup.close();i.popup=i._build({$type:"info-window",$arguments:[{content:i.options.isTabletop?Handlebars.compile(n("#property-card-map-tabletop").text())(r):Handlebars.compile(n("#property-card-map").text())(r),position:{lat:r.Latitude,lng:r.Longitude},pixelOffset:new google.maps.Size(0,-52)},t]});i.popup.open(i._map)}));f&&(i.options.map.activateChildren&&i.options.map.activateChildren.indexOf("ForSaleToggle")>-1&&f.setVisible(!0),i._propertyMarkers.addMarker(f,!0));i._propertyMarkers.repaint();i._toolbox._container.on("click",".tab-content li.ForSaleToggle",function(t){n(t.target).hasClass("off")?n.each(i._propertyMarkers.getMarkers(),function(n,t){t.setVisible(!1)}):n(t.target).hasClass("on")&&i._toolbox.showForSaleMarkers(i._propertyMarkers.getMarkers());i.popup&&i.popup.close()})}catch(p){console.error(p)}u.addGeoJson(o)}})}},_findMidpoint:function(n){for(var o,s,t=n[0],r=t[0][0],f=t[0][0],u=t[0][1],e=t[0][1],i=1;i<t.length;i++)t[i][0]<r?r=t[i][0]:t[i][0]>f&&(f=t[i][0]),t[i][1]<u?u=t[i][1]:t[i][1]>e&&(e=t[i][1]);return o=(f-r)/2+r,s=(e-u)/2+u,{lat:s,long:o}}})}(jQuery)