silverstripe-webpack/app/client/dist/js/app_Site.Controllers.MapElementController.js
2021-08-19 00:10:45 +02:00

1 line
30 KiB
JavaScript

!function(){"use strict";var e="ajax-load",t="load-ready",r="map-loaded",o="map-api-loaded",s="map-marker-click",n="map-popup-close",i=function extendStatics(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function __extends(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}var a=function __assign(){return(a=Object.assign||function __assign(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};var l=function OverlayViewSafe(){!function extend(e,t){for(var r in t.prototype)e.prototype[r]=t.prototype[r]}(OverlayViewSafe,google.maps.OverlayView)};function toCssText(e){return Object.keys(e).reduce((function(t,r){return e[r]&&t.push(r+":"+e[r]),t}),[]).join(";")}function coercePixels(e){return e?e+"px":void 0}var u=function(e){function ClusterIcon(t,r){var o=e.call(this)||this;return o.cluster_=t,o.styles_=r,o.center_=null,o.div_=null,o.sums_=null,o.visible_=!1,o.style=null,o.setMap(t.getMap()),o}return __extends(ClusterIcon,e),ClusterIcon.prototype.onAdd=function(){var e,t,r=this,o=this.cluster_.getMarkerClusterer(),s=google.maps.version.split("."),n=s[0],i=s[1],a=100*parseInt(n,10)+parseInt(i,10);this.div_=document.createElement("div"),this.visible_&&this.show(),this.getPanes().overlayMouseTarget.appendChild(this.div_),this.boundsChangedListener_=google.maps.event.addListener(this.getMap(),"bounds_changed",(function(){t=e})),google.maps.event.addDomListener(this.div_,"mousedown",(function(){e=!0,t=!1})),google.maps.event.addDomListener(this.div_,"contextmenu",(function(){google.maps.event.trigger(o,"contextmenu",r.cluster_)})),a>=332&&google.maps.event.addDomListener(this.div_,"touchstart",(function(e){e.stopPropagation()})),google.maps.event.addDomListener(this.div_,"click",(function(s){if(e=!1,!t){if(google.maps.event.trigger(o,"click",r.cluster_),google.maps.event.trigger(o,"clusterclick",r.cluster_),o.getZoomOnClick()){var n=o.getMaxZoom(),i=r.cluster_.getBounds();o.getMap().fitBounds(i),setTimeout((function(){o.getMap().fitBounds(i),null!==n&&o.getMap().getZoom()>n&&o.getMap().setZoom(n+1)}),100)}s.cancelBubble=!0,s.stopPropagation&&s.stopPropagation()}})),google.maps.event.addDomListener(this.div_,"mouseover",(function(){google.maps.event.trigger(o,"mouseover",r.cluster_)})),google.maps.event.addDomListener(this.div_,"mouseout",(function(){google.maps.event.trigger(o,"mouseout",r.cluster_)}))},ClusterIcon.prototype.onRemove=function(){this.div_&&this.div_.parentNode&&(this.hide(),google.maps.event.removeListener(this.boundsChangedListener_),google.maps.event.clearInstanceListeners(this.div_),this.div_.parentNode.removeChild(this.div_),this.div_=null)},ClusterIcon.prototype.draw=function(){if(this.visible_){var e=this.getPosFromLatLng_(this.center_);this.div_.style.top=e.y+"px",this.div_.style.left=e.x+"px"}},ClusterIcon.prototype.hide=function(){this.div_&&(this.div_.style.display="none"),this.visible_=!1},ClusterIcon.prototype.show=function(){this.div_&&(this.div_.className=this.className_,this.div_.style.cssText=this.createCss_(this.getPosFromLatLng_(this.center_)),this.div_.innerHTML=(this.style.url?this.getImageElementHtml():"")+this.getLabelDivHtml(),"undefined"===typeof this.sums_.title||""===this.sums_.title?this.div_.title=this.cluster_.getMarkerClusterer().getTitle():this.div_.title=this.sums_.title,this.div_.style.display=""),this.visible_=!0},ClusterIcon.prototype.getLabelDivHtml=function(){return'\n<div aria-label="'+this.cluster_.getMarkerClusterer().ariaLabelFn(this.sums_.text)+'" style="'+toCssText({position:"absolute",top:coercePixels(this.anchorText_[0]),left:coercePixels(this.anchorText_[1]),color:this.style.textColor,"font-size":coercePixels(this.style.textSize),"font-family":this.style.fontFamily,"font-weight":this.style.fontWeight,"font-style":this.style.fontStyle,"text-decoration":this.style.textDecoration,"text-align":"center",width:coercePixels(this.style.width),"line-height":coercePixels(this.style.textLineHeight)})+'" tabindex="0">\n <span aria-hidden="true">'+this.sums_.text+"</span>\n</div>\n"},ClusterIcon.prototype.getImageElementHtml=function(){var e=(this.style.backgroundPosition||"0 0").split(" "),t=parseInt(e[0].replace(/^\s+|\s+$/g,""),10),r=parseInt(e[1].replace(/^\s+|\s+$/g,""),10),o={};if(this.cluster_.getMarkerClusterer().getEnableRetinaIcons())o={width:coercePixels(this.style.width),height:coercePixels(this.style.height)};else{var s=[-1*r,-1*t+this.style.width,-1*r+this.style.height,-1*t];o={clip:"rect("+s[0]+"px, "+s[1]+"px, "+s[2]+"px, "+s[3]+"px)"}}var n=this.sums_.url?{width:"100%",height:"100%"}:{},i=toCssText(a(a({position:"absolute",top:coercePixels(r),left:coercePixels(t)},o),n));return'<img alt="'+this.sums_.text+'" aria-hidden="true" src="'+this.style.url+'" style="'+i+'"/>'},ClusterIcon.prototype.useStyle=function(e){this.sums_=e;var t=Math.max(0,e.index-1);t=Math.min(this.styles_.length-1,t),this.style=this.sums_.url?a(a({},this.styles_[t]),{url:this.sums_.url}):this.styles_[t],this.anchorText_=this.style.anchorText||[0,0],this.anchorIcon_=this.style.anchorIcon||[Math.floor(this.style.height/2),Math.floor(this.style.width/2)],this.className_=this.cluster_.getMarkerClusterer().getClusterClass()+" "+(this.style.className||"cluster-"+t)},ClusterIcon.prototype.setCenter=function(e){this.center_=e},ClusterIcon.prototype.createCss_=function(e){return toCssText({"z-index":""+this.cluster_.getMarkerClusterer().getZIndex(),top:coercePixels(e.y),left:coercePixels(e.x),width:coercePixels(this.style.width),height:coercePixels(this.style.height),cursor:"pointer",position:"absolute","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-o-user-select":"none","user-select":"none"})},ClusterIcon.prototype.getPosFromLatLng_=function(e){var t=this.getProjection().fromLatLngToDivPixel(e);return t.x=Math.floor(t.x-this.anchorIcon_[1]),t.y=Math.floor(t.y-this.anchorIcon_[0]),t},ClusterIcon}(l),c=function(){function Cluster(e){this.markerClusterer_=e,this.map_=this.markerClusterer_.getMap(),this.minClusterSize_=this.markerClusterer_.getMinimumClusterSize(),this.averageCenter_=this.markerClusterer_.getAverageCenter(),this.markers_=[],this.center_=null,this.bounds_=null,this.clusterIcon_=new u(this,this.markerClusterer_.getStyles())}return 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 e=new google.maps.LatLngBounds(this.center_,this.center_),t=this.getMarkers(),r=0;r<t.length;r++)e.extend(t[r].getPosition());return e},Cluster.prototype.remove=function(){this.clusterIcon_.setMap(null),this.markers_=[],delete this.markers_},Cluster.prototype.addMarker=function(e){if(this.isMarkerAlreadyAdded_(e))return!1;if(this.center_){if(this.averageCenter_){var t=this.markers_.length+1,r=(this.center_.lat()*(t-1)+e.getPosition().lat())/t,o=(this.center_.lng()*(t-1)+e.getPosition().lng())/t;this.center_=new google.maps.LatLng(r,o),this.calculateBounds_()}}else this.center_=e.getPosition(),this.calculateBounds_();e.isAdded=!0,this.markers_.push(e);var s=this.markers_.length,n=this.markerClusterer_.getMaxZoom();if(null!==n&&this.map_.getZoom()>n)e.getMap()!==this.map_&&e.setMap(this.map_);else if(s<this.minClusterSize_)e.getMap()!==this.map_&&e.setMap(this.map_);else if(s===this.minClusterSize_)for(var i=0;i<s;i++)this.markers_[i].setMap(null);else e.setMap(null);return!0},Cluster.prototype.isMarkerInClusterBounds=function(e){return this.bounds_.contains(e.getPosition())},Cluster.prototype.calculateBounds_=function(){var e=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(e)},Cluster.prototype.updateIcon=function(){var e=this.markers_.length,t=this.markerClusterer_.getMaxZoom();if(null!==t&&this.map_.getZoom()>t)this.clusterIcon_.hide();else if(e<this.minClusterSize_)this.clusterIcon_.hide();else{var r=this.markerClusterer_.getStyles().length,o=this.markerClusterer_.getCalculator()(this.markers_,r);this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.useStyle(o),this.clusterIcon_.show()}},Cluster.prototype.isMarkerAlreadyAdded_=function(e){if(this.markers_.indexOf)return-1!==this.markers_.indexOf(e);for(var t=0;t<this.markers_.length;t++)if(e===this.markers_[t])return!0;return!1},Cluster}(),p=function getOption(e,t,r){return void 0!==e[t]?e[t]:r},h=function(e){function MarkerClusterer(t,r,o){void 0===r&&(r=[]),void 0===o&&(o={});var s=e.call(this)||this;return s.options=o,s.markers_=[],s.clusters_=[],s.listeners_=[],s.activeMap_=null,s.ready_=!1,s.ariaLabelFn=s.options.ariaLabelFn||function(){return""},s.zIndex_=s.options.zIndex||Number(google.maps.Marker.MAX_ZINDEX)+1,s.gridSize_=s.options.gridSize||60,s.minClusterSize_=s.options.minimumClusterSize||2,s.maxZoom_=s.options.maxZoom||null,s.styles_=s.options.styles||[],s.title_=s.options.title||"",s.zoomOnClick_=p(s.options,"zoomOnClick",!0),s.averageCenter_=p(s.options,"averageCenter",!1),s.ignoreHidden_=p(s.options,"ignoreHidden",!1),s.enableRetinaIcons_=p(s.options,"enableRetinaIcons",!1),s.imagePath_=s.options.imagePath||MarkerClusterer.IMAGE_PATH,s.imageExtension_=s.options.imageExtension||MarkerClusterer.IMAGE_EXTENSION,s.imageSizes_=s.options.imageSizes||MarkerClusterer.IMAGE_SIZES,s.calculator_=s.options.calculator||MarkerClusterer.CALCULATOR,s.batchSize_=s.options.batchSize||MarkerClusterer.BATCH_SIZE,s.batchSizeIE_=s.options.batchSizeIE||MarkerClusterer.BATCH_SIZE_IE,s.clusterClass_=s.options.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(s.batchSize_=s.batchSizeIE_),s.setupStyles_(),s.addMarkers(r,!0),s.setMap(t),s}return __extends(MarkerClusterer,e),MarkerClusterer.prototype.onAdd=function(){var e=this;this.activeMap_=this.getMap(),this.ready_=!0,this.repaint(),this.prevZoom_=this.getMap().getZoom(),this.listeners_=[google.maps.event.addListener(this.getMap(),"zoom_changed",(function(){var t=e.getMap(),r=t.minZoom||0,o=Math.min(t.maxZoom||100,t.mapTypes[t.getMapTypeId()].maxZoom),s=Math.min(Math.max(e.getMap().getZoom(),r),o);e.prevZoom_!=s&&(e.prevZoom_=s,e.resetViewport_(!1))})),google.maps.event.addListener(this.getMap(),"idle",(function(){e.redraw_()}))]},MarkerClusterer.prototype.onRemove=function(){for(var e=0;e<this.markers_.length;e++)this.markers_[e].getMap()!==this.activeMap_&&this.markers_[e].setMap(this.activeMap_);for(e=0;e<this.clusters_.length;e++)this.clusters_[e].remove();this.clusters_=[];for(e=0;e<this.listeners_.length;e++)google.maps.event.removeListener(this.listeners_[e]);this.listeners_=[],this.activeMap_=null,this.ready_=!1},MarkerClusterer.prototype.draw=function(){},MarkerClusterer.prototype.setupStyles_=function(){if(!(this.styles_.length>0))for(var e=0;e<this.imageSizes_.length;e++){var t=this.imageSizes_[e];this.styles_.push(MarkerClusterer.withDefaultStyle({url:this.imagePath_+(e+1)+"."+this.imageExtension_,height:t,width:t}))}},MarkerClusterer.prototype.fitMapToMarkers=function(e){for(var t=this.getMarkers(),r=new google.maps.LatLngBounds,o=0;o<t.length;o++)!t[o].getVisible()&&this.getIgnoreHidden()||r.extend(t[o].getPosition());this.getMap().fitBounds(r,e)},MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_},MarkerClusterer.prototype.setGridSize=function(e){this.gridSize_=e},MarkerClusterer.prototype.getMinimumClusterSize=function(){return this.minClusterSize_},MarkerClusterer.prototype.setMinimumClusterSize=function(e){this.minClusterSize_=e},MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_},MarkerClusterer.prototype.setMaxZoom=function(e){this.maxZoom_=e},MarkerClusterer.prototype.getZIndex=function(){return this.zIndex_},MarkerClusterer.prototype.setZIndex=function(e){this.zIndex_=e},MarkerClusterer.prototype.getStyles=function(){return this.styles_},MarkerClusterer.prototype.setStyles=function(e){this.styles_=e},MarkerClusterer.prototype.getTitle=function(){return this.title_},MarkerClusterer.prototype.setTitle=function(e){this.title_=e},MarkerClusterer.prototype.getZoomOnClick=function(){return this.zoomOnClick_},MarkerClusterer.prototype.setZoomOnClick=function(e){this.zoomOnClick_=e},MarkerClusterer.prototype.getAverageCenter=function(){return this.averageCenter_},MarkerClusterer.prototype.setAverageCenter=function(e){this.averageCenter_=e},MarkerClusterer.prototype.getIgnoreHidden=function(){return this.ignoreHidden_},MarkerClusterer.prototype.setIgnoreHidden=function(e){this.ignoreHidden_=e},MarkerClusterer.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons_},MarkerClusterer.prototype.setEnableRetinaIcons=function(e){this.enableRetinaIcons_=e},MarkerClusterer.prototype.getImageExtension=function(){return this.imageExtension_},MarkerClusterer.prototype.setImageExtension=function(e){this.imageExtension_=e},MarkerClusterer.prototype.getImagePath=function(){return this.imagePath_},MarkerClusterer.prototype.setImagePath=function(e){this.imagePath_=e},MarkerClusterer.prototype.getImageSizes=function(){return this.imageSizes_},MarkerClusterer.prototype.setImageSizes=function(e){this.imageSizes_=e},MarkerClusterer.prototype.getCalculator=function(){return this.calculator_},MarkerClusterer.prototype.setCalculator=function(e){this.calculator_=e},MarkerClusterer.prototype.getBatchSizeIE=function(){return this.batchSizeIE_},MarkerClusterer.prototype.setBatchSizeIE=function(e){this.batchSizeIE_=e},MarkerClusterer.prototype.getClusterClass=function(){return this.clusterClass_},MarkerClusterer.prototype.setClusterClass=function(e){this.clusterClass_=e},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(e,t){this.pushMarkerTo_(e),t||this.redraw_()},MarkerClusterer.prototype.addMarkers=function(e,t){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.pushMarkerTo_(e[r]);t||this.redraw_()},MarkerClusterer.prototype.pushMarkerTo_=function(e){var t=this;e.getDraggable()&&google.maps.event.addListener(e,"dragend",(function(){t.ready_&&(e.isAdded=!1,t.repaint())})),e.isAdded=!1,this.markers_.push(e)},MarkerClusterer.prototype.removeMarker=function(e,t){var r=this.removeMarker_(e);return!t&&r&&this.repaint(),r},MarkerClusterer.prototype.removeMarkers=function(e,t){for(var r=!1,o=0;o<e.length;o++){var s=this.removeMarker_(e[o]);r=r||s}return!t&&r&&this.repaint(),r},MarkerClusterer.prototype.removeMarker_=function(e){var t=-1;if(this.markers_.indexOf)t=this.markers_.indexOf(e);else for(var r=0;r<this.markers_.length;r++)if(e===this.markers_[r]){t=r;break}return-1!==t&&(e.setMap(null),this.markers_.splice(t,1),!0)},MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport_(!0),this.markers_=[]},MarkerClusterer.prototype.repaint=function(){var e=this.clusters_.slice();this.clusters_=[],this.resetViewport_(!1),this.redraw_(),setTimeout((function(){for(var t=0;t<e.length;t++)e[t].remove()}),0)},MarkerClusterer.prototype.getExtendedBounds=function(e){var t=this.getProjection(),r=new google.maps.LatLng(e.getNorthEast().lat(),e.getNorthEast().lng()),o=new google.maps.LatLng(e.getSouthWest().lat(),e.getSouthWest().lng()),s=t.fromLatLngToDivPixel(r);s.x+=this.gridSize_,s.y-=this.gridSize_;var n=t.fromLatLngToDivPixel(o);n.x-=this.gridSize_,n.y+=this.gridSize_;var i=t.fromDivPixelToLatLng(s),a=t.fromDivPixelToLatLng(n);return e.extend(i),e.extend(a),e},MarkerClusterer.prototype.redraw_=function(){this.createClusters_(0)},MarkerClusterer.prototype.resetViewport_=function(e){for(var t=0;t<this.clusters_.length;t++)this.clusters_[t].remove();this.clusters_=[];for(t=0;t<this.markers_.length;t++){var r=this.markers_[t];r.isAdded=!1,e&&r.setMap(null)}},MarkerClusterer.prototype.distanceBetweenPoints_=function(e,t){var r=(t.lat()-e.lat())*Math.PI/180,o=(t.lng()-e.lng())*Math.PI/180,s=Math.sin(r/2)*Math.sin(r/2)+Math.cos(e.lat()*Math.PI/180)*Math.cos(t.lat()*Math.PI/180)*Math.sin(o/2)*Math.sin(o/2);return 6371*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))},MarkerClusterer.prototype.isMarkerInBounds_=function(e,t){return t.contains(e.getPosition())},MarkerClusterer.prototype.addToClosestCluster_=function(e){for(var t=4e4,r=null,o=0;o<this.clusters_.length;o++){var s,n=(s=this.clusters_[o]).getCenter();if(n){var i=this.distanceBetweenPoints_(n,e.getPosition());i<t&&(t=i,r=s)}}r&&r.isMarkerInClusterBounds(e)?r.addMarker(e):((s=new c(this)).addMarker(e),this.clusters_.push(s))},MarkerClusterer.prototype.createClusters_=function(e){var t=this;if(this.ready_){var r;0===e&&(google.maps.event.trigger(this,"clusteringbegin",this),"undefined"!==typeof this.timerRefStatic&&(clearTimeout(this.timerRefStatic),delete this.timerRefStatic)),r=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.02070771743472,-178.48388434375),new google.maps.LatLng(-85.08136444384544,178.00048865625));for(var o=this.getExtendedBounds(r),s=Math.min(e+this.batchSize_,this.markers_.length),n=e;n<s;n++){var i=this.markers_[n];!i.isAdded&&this.isMarkerInBounds_(i,o)&&(!this.ignoreHidden_||this.ignoreHidden_&&i.getVisible())&&this.addToClosestCluster_(i)}if(s<this.markers_.length)this.timerRefStatic=window.setTimeout((function(){t.createClusters_(s)}),0);else{delete this.timerRefStatic,google.maps.event.trigger(this,"clusteringend",this);for(n=0;n<this.clusters_.length;n++)this.clusters_[n].updateIcon()}}},MarkerClusterer.CALCULATOR=function(e,t){for(var r=0,o=e.length,s=o;0!==s;)s=Math.floor(s/10),r++;return r=Math.min(r,t),{text:o.toString(),index:r,title:""}},MarkerClusterer.withDefaultStyle=function(e){return a({textColor:"black",textSize:11,textDecoration:"none",textLineHeight:e.height,fontWeight:"bold",fontStyle:"normal",fontFamily:"Arial,sans-serif",backgroundPosition:"0 0"},e)},MarkerClusterer.BATCH_SIZE=2e3,MarkerClusterer.BATCH_SIZE_IE=500,MarkerClusterer.IMAGE_PATH="../images/m",MarkerClusterer.IMAGE_EXTENSION="png",MarkerClusterer.IMAGE_SIZES=[53,56,66,78,90],MarkerClusterer}(l);function _typeof(e){return(_typeof="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function _typeof(e){return typeof e}:function _typeof(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(e){var t=function _isNativeReflectConstruct(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function _createSuperInternal(){var r,o=_getPrototypeOf(e);if(t){var s=_getPrototypeOf(this).constructor;r=Reflect.construct(o,arguments,s)}else r=o.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var g={init:function init(){return function(e){!function _inherits(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}(GoogleMapsHtmlOverlay,google.maps.OverlayView);var t=_createSuper(GoogleMapsHtmlOverlay);function GoogleMapsHtmlOverlay(e){var r;!function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,GoogleMapsHtmlOverlay);var o=_assertThisInitialized(r=t.call(this));return o.ownerMap=e.map,o.position=e.position,o.html=e.html?e.html:'<div class="mapboxgl-marker"><i class="marker-icon fas fa-map-marker-alt"></i></div>',o.divClass=e.divClass,o.align=e.align,o.isDebugMode=e.debug,o.onClick=e.onClick,o.onMouseOver=e.onMouseOver,o.isBoolean=function(e){return"boolean"===typeof e},o.isNotUndefined=function(e){return"undefined"!==typeof e},o.hasContent=function(e){return e.length>0},o.isString=function(e){return"string"===typeof e},o.isFunction=function(e){return"function"===typeof e},r}return function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}(GoogleMapsHtmlOverlay,[{key:"onAdd",value:function onAdd(){var e=this;e.div=document.createElement("div"),e.div.style.position="absolute",e.isNotUndefined(e.divClass)&&e.hasContent(e.divClass)&&(e.div.className=e.divClass),e.isNotUndefined(e.html)&&e.hasContent(e.html)&&e.isString(e.html)&&(e.div.innerHTML=e.html),e.isBoolean(e.isDebugMode)&&e.isDebugMode&&(e.div.className="debug-mode",e.div.innerHTML='<div style="height: 10px; width: 10px; background: red; border-radius: 100%;"></div><div style="position: absolute; top: 5px; padding: 5px; width: 130px; text-align: center; font-size: 18px; text-transform: uppercase; font-weight: bolder; background: red; color: white; font-family: Arial;">Debug mode</div>',e.div.setAttribute("style","position: absolute;border: 5px dashed red;height: 150px;width: 150px;display: flex;justify-content: center;align-items: center;")),e.getPanes().overlayMouseTarget.appendChild(e.div),google.maps.event.addDomListener(e.div,"click",(function(t){google.maps.event.trigger(e,"click"),e.isFunction(e.onClick)&&e.onClick(),t.stopPropagation()})),google.maps.event.addDomListener(e.div,"mouseover",(function(t){google.maps.event.trigger(e,"mouseover"),e.isFunction(e.onMouseOver)&&e.onMouseOver(),t.stopPropagation()}))}},{key:"draw",value:function draw(){var e=this,t=document.querySelector(".popup");t.length||(t=e.div);var r=e.getProjection();if(!r)return console.log("GoogleMapsHtmlOverlay: current map is missing"),null;var o=r.fromLatLngToDivPixel(e.getPosition()),s={y:void 0,x:void 0},n=t.offsetWidth,i=t.offsetHeight;switch(Array.isArray(e.align)?e.align.join(" "):""){case"left top":s.y=i,s.x=n;break;case"left center":s.y=i/2,s.x=n;break;case"left bottom":s.y=0,s.x=n;break;case"center top":s.y=i,s.x=n/2;break;case"center center":s.y=i/2,s.x=n/2;break;case"center bottom":s.y=0,s.x=n/2;break;case"right top":s.y=i,s.x=0;break;case"right center":s.y=i/2,s.x=0;break;case"right bottom":s.y=0,s.x=0;break;default:s.y=i/2,s.x=n/2}e.div.style.top="".concat(o.y-s.y,"px"),e.div.style.left="".concat(o.x-s.x,"px")}},{key:"getPosition",value:function getPosition(){return new google.maps.LatLng(this.position)}},{key:"getDiv",value:function getDiv(){return this.div}},{key:"setPosition",value:function setPosition(e,t){var r=this;r.position=e,r.align=t,r.draw()}},{key:"remove",value:function remove(){this.setMap(null),this.div.remove()}},{key:"getDraggable",value:function getDraggable(){return!1}}]),GoogleMapsHtmlOverlay}()}};function map_google_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var d={ENVS:["xs","sm","md","lg","xl","xxl","xxxl"],MAP_DRIVER:function(e){return function(){function GoogleMapsDriver(){!function map_google_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,GoogleMapsDriver)}return function map_google_createClass(e,t,r){return t&&map_google_defineProperties(e.prototype,t),r&&map_google_defineProperties(e,r),e}(GoogleMapsDriver,[{key:"getName",value:function getName(){return"GoogleMapsDriver"}},{key:"init",value:function init(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=this;o.el=t,o.config=r,o.markers=[],e["init".concat(o.getName())]=function(){o.googleApiLoaded()};var s=document.createElement("script");s.src="https://maps.googleapis.com/maps/api/js?key=".concat(r.key,"&callback=init").concat(o.getName()),s.async=!0,s.defer=!0,document.head.appendChild(s)}},{key:"googleApiLoaded",value:function googleApiLoaded(){var e=this,t=e.el,r=e.config,s=t.querySelector(".mapAPI-map"),n=r.mapZoom&&"0"!==r.mapZoom?parseInt(r.mapZoom):10,i=r.center&&","!==r.center?{lat:r.center[1],lng:r.center[0]}:{lat:0,lng:0},a=r.style?r.style:null;console.log("".concat(e.getName(),": API is loaded")),e.MarkerUI=g.init(),e.map=new google.maps.Map(s,{zoom:n,center:i,fullscreenControl:!0,styles:a}),e.default_zoom=n,s.classList.add("mapboxgl-map"),e.popup=new e.MarkerUI({map:e.map,align:["center","top"],divClass:"mapboxgl-popup popup mapboxgl-popup-anchor-bottom d-none",html:'<div class="mapboxgl-popup-tip"></div><div class="mapboxgl-popup-content"><div class="mapboxgl-popup-close-button" type="button" aria-label="Close popup">\xd7</div><div class="html"></div></div>'}),e.popup.setMap(e.map),e.geocoder=new google.maps.Geocoder,e.cluster=new h(e.map,null,{styles:[{width:30,height:30,className:"mapboxgl-cluster"}]}),t.dispatchEvent(new Event(o))}},{key:"addMarker",value:function addMarker(e,t){var r=this,o={lat:e[1],lng:e[0]},n=new r.MarkerUI({position:o,map:r.map,align:["center","top"],html:'<div class="mapboxgl-marker"><div id="Marker'.concat(t.id,'" data-id="').concat(t.id,'" class="marker">').concat(t.icon,"</div></div>"),onClick:function onClick(){var e=document.querySelector("#Marker".concat(t.id));r.showPopup(o,t.content),e.dispatchEvent(new Event(s))}});return r.markers.push(n),r.cluster.addMarker(n),n}},{key:"showPopup",value:function showPopup(e,t){var r=this,o=r.popup.getDiv();r.config.flyToMarker&&(r.map.setCenter(e),r.config.noZoom||r.map.setZoom(18)),o.style.opacity="0",o.classList.remove("d-none"),o.querySelector(".mapboxgl-popup-content .html").innerHTML=t,o.querySelector(".mapboxgl-popup-close-button").addEventListener("click",(function(e){e.preventDefault(),r.hidePopup()})),r.popup.setPosition(e,["center","top"]),o.style.opacity="1",o.style["margin-top"]="-1rem"}},{key:"hidePopup",value:function hidePopup(){var e=this;e.popup.getDiv().classList.add("d-none"),e.config.noRestoreBounds&&!e.config.flyToBounds||e.restoreBounds(),e.el.dispatchEvent(new Event(n))}},{key:"geocode",value:function geocode(e,t){var r=this;r.geocoder.geocode({address:e},(function(e,o){if("OK"===o)return"function"===typeof t&&t(e),e;console.error("".concat(r.getName(),": Geocode was not successful for the following reason: ").concat(o))}))}},{key:"reverseGeocode",value:function reverseGeocode(e,t){var r=this;r.geocoder.geocode({location:latlng},(function(e,o){if("OK"===o)return"function"===typeof t&&t(e),e;console.error("".concat(r.getName(),": Reverse Geocoding was not successful for the following reason: ").concat(o))}))}},{key:"addGeoJson",value:function addGeoJson(e){var t=this,r=JSON.parse(e.geojson),o=(r.features[0].geometry.coordinates,new google.maps.LatLngBounds);r.features.forEach((function(r){var s=r.id,n=r.geometry.coordinates,i=r.properties.content;t.addMarker(n,{id:s,content:i,icon:r.icon,flyToMarker:e.flyToMarker}),o.extend({lat:n[1],lng:n[0]})})),t.markers.length>1?t.map.fitBounds(o,{padding:30}):t.markers[0]&&t.map.setCenter(t.markers[0].getPosition()),t.default_bounds=o,t.default_zoom=t.map.getZoom()}},{key:"getMap",value:function getMap(){return this.map}},{key:"getPopup",value:function getPopup(){return this.popup}},{key:"restoreBounds",value:function restoreBounds(){var e=this;e.default_bounds&&e.markers.length>1?e.map.fitBounds(e.default_bounds,{padding:30}):(e.markers[0]&&e.map.setCenter(e.markers[0].getPosition()),e.restoreZoom())}},{key:"restoreZoom",value:function restoreZoom(){this.map.setZoom(this.default_zoom)}}]),GoogleMapsDriver}()}(window)};function map_api_defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}!function(s){var n="js-mapapi",i=d.MAP_DRIVER,a=function(){function MapAPI(e){!function map_api_classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,MapAPI);var t=this,r=new i,s=document.querySelector("body"),a=e.dataset;a.center=[a.lng?a.lng:s.dataset["default-lng"],a.lat?a.lat:s.dataset["default-lat"]],a.icon||(a.icon='<i class="fas fa-map-marker-alt"></i>'),console.log("".concat(n,": init ").concat(r.getName(),"...")),t.drv=r,t.el=e,t.config=a,r.init(e,a),e.addEventListener(o,(function(){t.addMarkers()}))}return function map_api_createClass(e,t,r){return t&&map_api_defineProperties(e.prototype,t),r&&map_api_defineProperties(e,r),e}(MapAPI,[{key:"getMap",value:function getMap(){return ui.map}},{key:"dispose",value:function dispose(){this.el=null,this.el.classList.remove("".concat(n,"-active"))}},{key:"addMarkers",value:function addMarkers(){console.log("".concat(n,": addMarkers"));var e=this,t=e.el,o=e.drv,s=e.config;if(e.map=o.getMap(),s.geojson)console.log("".concat(n,": setting up geocode data")),o.addGeoJson(s);else if(s.address)console.log(s.address),console.log("".concat(n,": setting up address marker")),o.geocode(s.address,(function(t){console.log(t);var r=t[0].geometry.location.lat(),i=t[0].geometry.location.lng();console.log("".concat(n,": setting up single lat/lng marker lat: ").concat(r," lng: ").concat(i)),o.addMarker([i,r],s),e.map.setCenter({lat:r,lng:i})}));else if(s.lat&&s.lng){var i=s.lat,a=s.lng;console.log("".concat(n,": setting up single lat/lng marker lat: ").concat(i," lng: ").concat(a)),o.addMarker([a,i],s)}t.classList.add("".concat(n,"-active")),t.dispatchEvent(new Event(r)),console.log("".concat(n,": Map is loaded"))}}]),MapAPI}(),l=function init(){console.log("".concat(n,": init")),document.querySelectorAll(".".concat(n)).forEach((function(e,t){new a(e)}))};s.addEventListener("".concat(t),l),s.addEventListener("".concat(e),l)}(window)}();