2 lines
5.0 KiB
JavaScript
2 lines
5.0 KiB
JavaScript
import t,{Component as e}from"react";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e){return o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},o(t,e)}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)}function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t,e){if(e&&("object"===i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function c(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=p(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){l=!0,a=t},f:function(){try{i||null==n.return||n.return()}finally{if(l)throw a}}}}function p(t,e){if(t){if("string"==typeof t)return f(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(t,e):void 0}}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function y(){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(t){return!1}}var v,d,h,b=function(o){a(h,e);var i,l,p,f,v,d=(i=h,l=y(),function(){var t,e=s(i);if(l){var n=s(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return u(this,t)});function h(){return n(this,h),d.apply(this,arguments)}return p=h,(f=[{key:"initMap",value:function(){this.map=new google.maps.Map(this.container,this.props.options),this.props.onMapReady&&this.props.onMapReady({map:this.map}),this.initOverlays(this.props.overlays),this.bindMapEvent("click",this.props.onMapClick),this.bindMapEvent("dragend",this.props.onMapDragEnd),this.bindMapEvent("zoom_changed",this.props.onZoomChanged)}},{key:"initOverlays",value:function(t){if(t){var e,n=c(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;r.setMap(this.map),this.bindOverlayEvents(r)}}catch(t){n.e(t)}finally{n.f()}}}},{key:"bindOverlayEvents",value:function(t){var e=this;t.addListener("click",(function(n){e.props.onOverlayClick&&e.props.onOverlayClick({originalEvent:n,overlay:t,map:e.map})})),t.getDraggable()&&this.bindDragEvents(t)}},{key:"bindDragEvents",value:function(t){this.bindDragEvent(t,"dragstart",this.props.onOverlayDragStart),this.bindDragEvent(t,"drag",this.props.onOverlayDrag),this.bindDragEvent(t,"dragend",this.props.onOverlayDragEnd)}},{key:"bindMapEvent",value:function(t,e){this.map.addListener(t,(function(t){e&&e(t)}))}},{key:"bindDragEvent",value:function(t,e,n){var r=this;t.addListener(e,(function(e){n&&n({originalEvent:e,overlay:t,map:r.map})}))}},{key:"getMap",value:function(){return this.map}},{key:"componentDidUpdate",value:function(t,e,n){if(t.overlays!==this.props.overlays){if(t.overlays){var r,o=c(t.overlays);try{for(o.s();!(r=o.n()).done;){var a=r.value;google.maps.event.clearInstanceListeners(a),a.setMap(null)}}catch(t){o.e(t)}finally{o.f()}}this.initOverlays(this.props.overlays)}}},{key:"componentDidMount",value:function(){this.initMap()}},{key:"render",value:function(){var e=this;return t.createElement("div",{ref:function(t){return e.container=t},style:this.props.style,className:this.props.className})}}])&&r(p.prototype,f),v&&r(p,v),Object.defineProperty(p,"prototype",{writable:!1}),h}();h={options:null,overlays:null,style:null,className:null,onMapReady:null,onMapClick:null,onMapDragEnd:null,onZoomChanged:null,onOverlayDragStart:null,onOverlayDrag:null,onOverlayDragEnd:null,onOverlayClick:null},(d="defaultProps")in(v=b)?Object.defineProperty(v,d,{value:h,enumerable:!0,configurable:!0,writable:!0}):v[d]=h;export{b as GMap};
|