webpack-bootstrap-ui-kit/dist/js/app_Site.Controllers.MapEle...

1 line
12 KiB
JavaScript

!function(){"use strict";var e={n:function(o){var t=o&&o.__esModule?function(){return o.default}:function(){return o};return e.d(t,{a:t}),t},d:function(o,t){for(var n in t)e.o(t,n)&&!e.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:t[n]})},o:function(e,o){return Object.prototype.hasOwnProperty.call(e,o)}},o=jQuery,t=e.n(o),n="ajax-load",a="load",r="map-loaded",i="map-api-loaded",c="map-marker-click",l="map-popup-close";function s(e){return(s="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,o){return(p=Object.setPrototypeOf||function(e,o){return e.__proto__=o,e})(e,o)}function f(e){var o=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var t,n=m(e);if(o){var a=m(this).constructor;t=Reflect.construct(n,arguments,a)}else t=n.apply(this,arguments);return d(this,t)}}function d(e,o){return!o||"object"!==s(o)&&"function"!==typeof o?g(e):o}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var v={init:function(){return function(e){!function(e,o){if("function"!==typeof o&&null!==o)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(o&&o.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),o&&p(e,o)}(i,google.maps.OverlayView);var o,n,a,r=f(i);function i(e){var o;!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,i);var t=g(o=r.call(this));return t.setMap(e.map),t.position=e.position,t.html=e.html?e.html:'<div class="mapboxgl-marker"><i class="marker-icon fas fa-map-marker-alt"></i></div>',t.divClass=e.divClass,t.align=e.align,t.isDebugMode=e.debug,t.onClick=e.onClick,t.onMouseOver=e.onMouseOver,t.isBoolean=function(e){return"boolean"===typeof e},t.isNotUndefined=function(e){return"undefined"!==typeof e},t.hasContent=function(e){return e.length>0},t.isString=function(e){return"string"===typeof e},t.isFunction=function(e){return"function"===typeof e},o}return o=i,(n=[{key:"onAdd",value:function(){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(o){google.maps.event.trigger(e,"click"),e.isFunction(e.onClick)&&e.onClick(),o.stopPropagation()})),google.maps.event.addDomListener(e.div,"mouseover",(function(o){google.maps.event.trigger(e,"mouseover"),e.isFunction(e.onMouseOver)&&e.onMouseOver(),o.stopPropagation()}))}},{key:"draw",value:function(){var e=this,o=t()(e.div).find(".mapboxgl-marker,.marker-pin,.mapboxgl-popup,.popup");o.length||(o=t()(e.div));var n=e.getProjection().fromLatLngToDivPixel(new google.maps.LatLng(e.position)),a={y:void 0,x:void 0},r=o.outerWidth(),i=o.outerHeight();switch(Array.isArray(e.align)?e.align.join(" "):""){case"left top":a.y=i,a.x=r;break;case"left center":a.y=i/2,a.x=r;break;case"left bottom":a.y=0,a.x=r;break;case"center top":a.y=i,a.x=r/2;break;case"center center":a.y=i/2,a.x=r/2;break;case"center bottom":a.y=0,a.x=r/2;break;case"right top":a.y=i,a.x=0;break;case"right center":a.y=i/2,a.x=0;break;case"right bottom":a.y=0,a.x=0;break;default:a.y=i/2,a.x=r/2}e.div.style.top="".concat(n.y-a.y,"px"),e.div.style.left="".concat(n.x-a.x,"px")}},{key:"getPosition",value:function(){return this.position}},{key:"getDiv",value:function(){return this.div}},{key:"setPosition",value:function(e,o){var t=this;t.position=e,t.align=o,t.draw()}}])&&u(o.prototype,n),a&&u(o,a),i}()}};function y(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var h,b={ENVS:["xs","sm","md","lg","xl","xxl","xxxl"],MAP_DRIVER:(h=t(),function(){function e(){!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,e)}var o,t,n;return o=e,(t=[{key:"getName",value:function(){return"GoogleMapsDriver"}},{key:"init",value:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],t=this,n=window;t.$el=e,t.config=o,t.markers=[],n["init".concat(t.getName())]=function(){t.googleApiLoaded()},h("body").append('<script async defer src="https://maps.googleapis.com/maps/api/js?key='.concat(o.key,"&callback=init").concat(t.getName(),'"><\/script>'))}},{key:"googleApiLoaded",value:function(){var e=this,o=e.$el,t=e.config,n=o.find(".mapAPI-map"),a=t.mapZoom?t.mapZoom:10,r=t.center?{lat:t.center[1],lng:t.center[0]}:{lat:0,lng:0},c=t.style?t.style:null;console.log("".concat(e.getName(),": API is loaded")),e.MarkerUI=v.init(h),e.map=new google.maps.Map(n[0],{zoom:a,center:r,fullscreenControl:!0,styles:c}),e.default_zoom=a,n.addClass("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.geocoder=new google.maps.Geocoder,o.trigger(i)}},{key:"addMarker",value:function(e,o){var t=this,n={lat:e[1],lng:e[0]},a=new t.MarkerUI({position:n,map:t.map,align:["center","top"],html:'<div class="mapboxgl-marker"><div id="Marker'.concat(o.id,'" data-id="').concat(o.id,'" class="marker">').concat(o.icon,"</div></div>"),onClick:function(){var e=h("#Marker".concat(o.id));t.showPopup(n,o.content),e.trigger(c)}});return t.markers.push(a),a}},{key:"showPopup",value:function(e,o){var t=this,n=h(t.popup.getDiv());t.config.flyToMarker&&(t.map.setCenter(e),t.config.noZoom||t.map.setZoom(18)),n.css({opacity:"0"}),n.removeClass("d-none"),n.find(".mapboxgl-popup-content .html").html(o),n.find(".mapboxgl-popup-close-button").on("click",(function(e){e.preventDefault(),t.hidePopup()})),t.popup.setPosition(e,["center","top"]),n.css({"margin-top":"-1rem",opacity:"1"})}},{key:"hidePopup",value:function(){var e=this;h(e.popup.getDiv()).addClass("d-none"),e.config.noRestoreBounds&&!e.config.flyToBounds||e.restoreBounds(),e.$el.trigger(l)}},{key:"geocode",value:function(e,o){var t=this;t.geocoder.geocode({address:e},(function(e,n){if("OK"===n)return"function"===typeof o&&o(e),e;console.error("".concat(t.getName(),": Geocode was not successful for the following reason: ").concat(n))}))}},{key:"reverseGeocode",value:function(e,o){var t=this;t.geocoder.geocode({location:latlng},(function(e,n){if("OK"===n)return"function"===typeof o&&o(e),e;console.error("".concat(t.getName(),": Reverse Geocoding was not successful for the following reason: ").concat(n))}))}},{key:"addGeoJson",value:function(e){var o=this,t=(e.geojson.features[0].geometry.coordinates,new google.maps.LatLngBounds);e.geojson.features.forEach((function(n){var a=n.id,r=n.geometry.coordinates,i=n.properties.content;o.addMarker(r,{id:a,content:i,icon:n.icon,flyToMarker:e.flyToMarker}),t.extend({lat:r[1],lng:r[0]})})),o.markers.length>1?o.map.fitBounds(t,{padding:30}):o.markers[0]&&o.map.setCenter(o.markers[0].getPosition()),o.default_bounds=t,o.default_zoom=o.map.getZoom()}},{key:"getMap",value:function(){return this.map}},{key:"getPopup",value:function(){return this.popup}},{key:"restoreBounds",value:function(){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(){this.map.setZoom(this.default_zoom)}}])&&y(o.prototype,t),n&&y(o,n),e}())};function k(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}!function(e){var o="jsMapAPI",t=o,c=e("body"),l=b.MAP_DRIVER,s=window,u=function(){function n(a){!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,n);var s=this,u=new l;s.$el=e(a);var p=s.$el,f=p.data();f.center=[f.lng?f.lng:c.data("default-lng"),f.lat?f.lat:c.data("default-lat")],f.style=f.style?jQuery.parseJSON(f.style):null,f["font-family"]=c.css("font-family"),f.icon||(f.icon='<i class="fas fa-map-marker-alt"></i>'),console.log("".concat(o,": init ").concat(u.getName(),"...")),u.init(p,f),s.drv=u,p.on(i,(function(e){if(s.map=u.getMap(),f.geojson)console.log("".concat(o,": setting up geocode data")),u.addGeoJson(f);else if(f.address)console.log(f.address),console.log("".concat(o,": setting up address marker")),u.geocode(f.address,(function(e){console.log(e);var t=e[0].geometry.location.lat(),n=e[0].geometry.location.lng();console.log("".concat(o,": setting up single lat/lng marker lat: ").concat(t," lng: ").concat(n)),u.addMarker([n,t],f),s.map.setCenter({lat:t,lng:n})}));else if(f.lat&&f.lng){var n=f.lat,a=f.lng;console.log("".concat(o,": setting up single lat/lng marker lat: ").concat(n," lng: ").concat(a)),u.addMarker([a,n],f)}p.data(t,s),p.addClass("".concat(o,"-active")),p.trigger(r),console.log("".concat(o,": Map is loaded"))}))}var a,u,p;return a=n,p=[{key:"_jQueryInterface",value:function(){var o=this;if("undefined"!==typeof s.localStorage)return this.each((function(){var a=e(o),r=a.data(t);r||(r=new n(o),a.data(t,r))}))}}],(u=[{key:"getMap",value:function(){return ui.map}},{key:"dispose",value:function(){var n=this;n.$el=null,e.removeData(n.$el[0],t),n.$el.removeClass("".concat(o,"-active"))}}])&&k(a.prototype,u),p&&k(a,p),n}();e.fn[o]=u._jQueryInterface,e.fn[o].Constructor=u,e.fn[o].noConflict=function(){return e.fn[o]=JQUERY_NO_CONFLICT,u._jQueryInterface},e(s).on("".concat(n," ").concat(a),(function(){e(".mapAPI-map-container").jsMapAPI()}))}(t());function x(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}!function(e){var o=window,t=(document,e("body")),i="LocationUI",s=function(){function o(){!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,o)}var n,a,r;return n=o,r=[{key:"init",value:function(){this.dispose(),console.log("Initializing: ".concat(i))}},{key:"initMap",value:function(){e(".mapAPI-map-container").find(".marker").on("".concat(c),(function(o){var n=e(o.currentTarget).data("id");t.find(".locations .location").removeClass("active"),t.find('.locations .location[data-id="'.concat(n,'"]')).addClass("active")})),t.find(".locations .location").on("click",(function(o){var n=e(o.currentTarget).data("id");t.find("#Marker".concat(n)).click()})),e(".mapAPI-map-container").on(l,(function(e){t.find(".locations .location").removeClass("active")}))}},{key:"dispose",value:function(){console.log("Destroying: ".concat(i))}}],(a=null)&&x(n.prototype,a),r&&x(n,r),o}();e(o).on("".concat(n," ").concat(a),(function(){s.init()})),e(o).on(r,(function(){s.initMap()}))}(t())}();