diff --git a/dist/vue-mapbox.common.js b/dist/vue-mapbox.common.js index e9c199aa..13b42c3c 100644 --- a/dist/vue-mapbox.common.js +++ b/dist/vue-mapbox.common.js @@ -1517,6 +1517,11 @@ module.exports = /******/ (function(modules) { /***/ }, + /***/ "66e4": /***/ function(module, exports, __webpack_require__) { + // extracted by mini-css-extract-plugin + /***/ + }, + /***/ "6762": /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -2166,20 +2171,6 @@ module.exports = /******/ (function(modules) { /***/ }, - /***/ "8615": /***/ function(module, exports, __webpack_require__) { - // https://github.com/tc39/proposal-object-values-entries - var $export = __webpack_require__("5ca1"); - var $values = __webpack_require__("504c")(false); - - $export($export.S, "Object", { - values: function values(it) { - return $values(it); - } - }); - - /***/ - }, - /***/ "86cc": /***/ function(module, exports, __webpack_require__) { var anObject = __webpack_require__("cb7c"); var IE8_DOM_DEFINE = __webpack_require__("c69a"); @@ -2856,6 +2847,25 @@ module.exports = /******/ (function(modules) { /***/ }, + /***/ e743: /***/ function( + module, + __webpack_exports__, + __webpack_require__ + ) { + "use strict"; + /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_GlMap_vue_vue_type_style_index_0_id_54c577ae_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( + "66e4" + ); + /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_GlMap_vue_vue_type_style_index_0_id_54c577ae_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n( + _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_GlMap_vue_vue_type_style_index_0_id_54c577ae_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__ + ); + /* unused harmony reexport * */ + /* unused harmony default export */ var _unused_webpack_default_export = + _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_GlMap_vue_vue_type_style_index_0_id_54c577ae_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0___default.a; + + /***/ + }, + /***/ ebd6: /***/ function(module, exports, __webpack_require__) { // 7.3.20 SpeciesConstructor(O, defaultConstructor) var anObject = __webpack_require__("cb7c"); @@ -2919,19 +2929,7 @@ module.exports = /******/ (function(modules) { // Indicate to webpack that this file can be concatenated /* harmony default export */ var setPublicPath = null; - // EXTERNAL MODULE: ./node_modules/core-js/modules/es7.object.values.js - var es7_object_values = __webpack_require__("8615"); - - // EXTERNAL MODULE: ./node_modules/core-js/modules/es6.array.iterator.js - var es6_array_iterator = __webpack_require__("cadf"); - - // EXTERNAL MODULE: ./node_modules/core-js/modules/es6.object.keys.js - var es6_object_keys = __webpack_require__("456d"); - - // EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom.iterable.js - var web_dom_iterable = __webpack_require__("ac6a"); - - // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/map/GlMap.vue?vue&type=template&id=3e0acdb8& + // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/map/GlMap.vue?vue&type=template&id=54c577ae&scoped=true& var render = function() { var _vm = this; var _h = _vm.$createElement; @@ -2939,7 +2937,7 @@ module.exports = /******/ (function(modules) { return _c( "div", { staticClass: "mgl-map-wrapper" }, - [_vm._m(0), _vm._t("default")], + [_vm._m(0), _vm.initialized ? _vm._t("default") : _vm._e()], 2 ); }; @@ -2952,7 +2950,16 @@ module.exports = /******/ (function(modules) { } ]; - // CONCATENATED MODULE: ./src/components/map/GlMap.vue?vue&type=template&id=3e0acdb8& + // CONCATENATED MODULE: ./src/components/map/GlMap.vue?vue&type=template&id=54c577ae&scoped=true& + + // EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom.iterable.js + var web_dom_iterable = __webpack_require__("ac6a"); + + // EXTERNAL MODULE: ./node_modules/core-js/modules/es6.array.iterator.js + var es6_array_iterator = __webpack_require__("cadf"); + + // EXTERNAL MODULE: ./node_modules/core-js/modules/es6.object.keys.js + var es6_object_keys = __webpack_require__("456d"); // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js function _defineProperty(obj, key, value) { @@ -3188,6 +3195,10 @@ module.exports = /******/ (function(modules) { return "map-".concat(("" + Math.random()).split(".")[1]); } }, + mapbox: { + type: Object, + required: true + }, accessToken: { type: String, default: undefined @@ -3607,11 +3618,21 @@ module.exports = /******/ (function(modules) { withEvents ], props: options, + provide: function provide() { + var self = this; + return { + mapbox: this.mapbox, + + get map() { + return self.map; + } + }; + }, data: function data() { return { initial: true, baseMap: true, - mapLoaded: false + initialized: false }; }, computed: { @@ -3670,7 +3691,7 @@ module.exports = /******/ (function(modules) { _this.$_bindPropsUpdateEvents(); _this.initial = false; - _this.mapLoaded = true; + _this.initialized = true; _this.$emit("load", { map: map, @@ -3684,6 +3705,11 @@ module.exports = /******/ (function(modules) { }; // CONCATENATED MODULE: ./src/components/map/GlMap.vue?vue&type=script&lang=js& /* harmony default export */ var map_GlMapvue_type_script_lang_js_ = GlMapvue_type_script_lang_js_; + // EXTERNAL MODULE: ./src/components/map/GlMap.vue?vue&type=style&index=0&id=54c577ae&scoped=true&lang=css& + var GlMapvue_type_style_index_0_id_54c577ae_scoped_true_lang_css_ = __webpack_require__( + "e743" + ); + // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js /* globals __VUE_SSR_CONTEXT__ */ @@ -3795,56 +3821,12 @@ module.exports = /******/ (function(modules) { staticRenderFns, false, null, - null, + "54c577ae", null ); component.options.__file = "GlMap.vue"; /* harmony default export */ var GlMap = component.exports; - // CONCATENATED MODULE: ./src/lib/withRegistration.js - function walkParents(component) { - if (component.baseMap) { - return component; - } else { - if (component.$parent !== undefined) { - return walkParents(component.$parent); - } - } - } - - /* harmony default export */ var withRegistration = { - created: function created() { - this.map = null; - }, - mounted: function mounted() { - this.$_checkMapTree(); // We wait for "load" event from map component to ensure mapbox is loaded and map created - }, - methods: { - $_findBaseMap: function $_findBaseMap() { - var baseMapComponent = walkParents(this.$parent); - - if (baseMapComponent === undefined) { - throw new Error("Component must have root map"); - } - - return baseMapComponent; - }, - $_checkMapTree: function $_checkMapTree() { - var mapComponent = this.$_findBaseMap(); - - if (mapComponent) { - if (mapComponent.mapLoaded) { - this.$_deferredMount({ - component: mapComponent, - map: mapComponent.map - }); - } else { - mapComponent.$on("load", this.$_deferredMount); - } - } - } - } - }; // CONCATENATED MODULE: ./src/components/UI/withSelfEvents.js /* harmony default export */ var withSelfEvents = { @@ -3874,20 +3856,26 @@ module.exports = /******/ (function(modules) { } }; // CONCATENATED MODULE: ./src/components/UI/controls/controlMixin.js + // import withRegistration from "../../../lib/withRegistration"; /* harmony default export */ var controlMixin = { - mixins: [withRegistration, withEvents, withSelfEvents], + mixins: [withEvents, withSelfEvents], + inject: ["mapbox", "map"], + props: { + position: { + type: String, + default: "top-right" + } + }, beforeDestroy: function beforeDestroy() { - if (this.map !== undefined) { + if (this.map) { this.map.removeControl(this.control); } }, methods: { - $_addControl: function $_addControl(payload) { - this.map = payload.map; - + $_addControl: function $_addControl() { try { - this.map.addControl(this.control); + this.map.addControl(this.control, this.position); } catch (err) { this.$_emitEvent("error", { error: err @@ -3898,7 +3886,6 @@ module.exports = /******/ (function(modules) { this.$_emitEvent("added", { control: this.control }); - payload.component.$off("load", this.$_deferredMount); } }, render: function render() {} @@ -3909,23 +3896,18 @@ module.exports = /******/ (function(modules) { name: "NavigationControl", mixins: [controlMixin], props: { - position: { - type: String, - default: "top-right" // TODO: add validator + showCompass: { + type: Boolean, + default: true + }, + showZoom: { + type: Boolean, + default: true } }, - data: function data() { - return { - control: undefined - }; - }, created: function created() { - this.control = new this.mapbox.NavigationControl(); - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - } + this.control = new this.mapbox.NavigationControl(this.$props); + this.$_addControl(); } }; // CONCATENATED MODULE: ./src/components/UI/controls/GeolocateControl.js @@ -3949,14 +3931,6 @@ module.exports = /******/ (function(modules) { }; } }, - trackUserLocation: { - type: Boolean, - default: false - }, - showUserLocation: { - type: Boolean, - default: true - }, fitBoundsOptions: { type: Object, default: function _default() { @@ -3964,21 +3938,22 @@ module.exports = /******/ (function(modules) { maxZoom: 15 }; } + }, + trackUserLocation: { + type: Boolean, + default: false + }, + showUserLocation: { + type: Boolean, + default: true } }, - data: function data() { - return { - control: undefined - }; - }, created: function created() { - this.control = new this.mapbox.GeolocateControl(this._props); + this.control = new this.mapbox.GeolocateControl(this.$props); + this.$_addControl(); + this.$_bindSelfEvents(Object.keys(geolocationEvents), this.control); }, methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - this.$_bindSelfEvents(Object.keys(geolocationEvents), this.control); - }, $_emitSelfEvent: function $_emitSelfEvent(event) { if (event.type === "error") { this.$_emitMapEvent("geolocate-error", { @@ -4005,23 +3980,14 @@ module.exports = /******/ (function(modules) { name: "FullscreenControl", mixins: [controlMixin], props: { - position: { - type: String, - default: "top-right" + container: { + type: HTMLElement, + default: undefined } }, - data: function data() { - return { - control: undefined - }; - }, created: function created() { - this.control = new this.mapbox.FullscreenControl(); - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - } + this.control = new this.mapbox.FullscreenControl(this.$props); + this.$_addControl(); } }; // CONCATENATED MODULE: ./src/components/UI/controls/AttributionControl.js @@ -4039,20 +4005,9 @@ module.exports = /******/ (function(modules) { deafault: undefined } }, - data: function data() { - return { - control: undefined - }; - }, created: function created() { - this.control = new this.mapbox.AttributionControl({ - compact: this.compact - }); - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - } + this.control = new this.mapbox.AttributionControl(this.$props); + this.$_addControl(); } }; // CONCATENATED MODULE: ./src/components/UI/controls/ScaleControl.js @@ -4073,11 +4028,6 @@ module.exports = /******/ (function(modules) { } } }, - data: function data() { - return { - control: undefined - }; - }, watch: { unit: function unit(next, prev) { if (this.control && next !== prev) { @@ -4086,16 +4036,12 @@ module.exports = /******/ (function(modules) { } }, created: function created() { - this.control = new this.mapbox.ScaleControl(this._props); - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - } + this.control = new this.mapbox.ScaleControl(this.$props); + this.$_addControl(); } }; - // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Marker.vue?vue&type=template&id=57267865& - var Markervue_type_template_id_57267865_render = function() { + // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Marker.vue?vue&type=template&id=219782b8& + var Markervue_type_template_id_219782b8_render = function() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; @@ -4106,9 +4052,9 @@ module.exports = /******/ (function(modules) { 2 ); }; - var Markervue_type_template_id_57267865_staticRenderFns = []; + var Markervue_type_template_id_219782b8_staticRenderFns = []; - // CONCATENATED MODULE: ./src/components/UI/Marker.vue?vue&type=template&id=57267865& + // CONCATENATED MODULE: ./src/components/UI/Marker.vue?vue&type=template&id=219782b8& // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Marker.vue?vue&type=script&lang=js& @@ -4129,7 +4075,8 @@ module.exports = /******/ (function(modules) { }; /* harmony default export */ var Markervue_type_script_lang_js_ = { name: "MapMarker", - mixins: [withRegistration, withEvents, withSelfEvents], + mixins: [withEvents, withSelfEvents], + inject: ["mapbox", "map"], props: { // mapbox marker options offset: { @@ -4170,53 +4117,45 @@ module.exports = /******/ (function(modules) { this.marker.setDraggable(next); } }, - mounted: function mounted() { - this.$_checkMapTree(); - }, - beforeDestroy: function beforeDestroy() { - if (this.map !== undefined && this.marker !== undefined) { - this.marker.remove(); - } - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - var _this = this; - - if (!this.marker) { - var markerOptions = _objectSpread({}, this._props); + created: function created() { + var _this = this; - if (this.$slots.marker) { - markerOptions.element = this.$slots.marker[0].elm; - } + var markerOptions = _objectSpread({}, this.$props); - this.marker = new this.mapbox.Marker(markerOptions); - } + if (this.$slots.marker) { + markerOptions.element = this.$slots.marker[0].elm; + } - this.map = payload.map; - this.$_addMarker(); + this.marker = new this.mapbox.Marker(markerOptions); + this.$_addMarker(); - if (this.$listeners["update:coordinates"]) { - this.marker.on("dragend", function(event) { - var newCoordinates; + if (this.$listeners["update:coordinates"]) { + this.marker.on("dragend", function(event) { + var newCoordinates; - if (_this.coordinates instanceof Array) { - newCoordinates = [ - event.target._lngLat.lng, - event.target._lngLat.lat - ]; - } else { - newCoordinates = event.target._lngLat; - } + if (_this.coordinates instanceof Array) { + newCoordinates = [ + event.target._lngLat.lng, + event.target._lngLat.lat + ]; + } else { + newCoordinates = event.target._lngLat; + } - _this.$emit("update:coordinates", newCoordinates); - }); - } + _this.$emit("update:coordinates", newCoordinates); + }); + } - var eventNames = Object.keys(markerEvents); - this.$_bindSelfEvents(eventNames, this.marker); - this.initial = false; - payload.component.$off("load", this.$_deferredMount); - }, + var eventNames = Object.keys(markerEvents); + this.$_bindSelfEvents(eventNames, this.marker); + this.initial = false; + }, + beforeDestroy: function beforeDestroy() { + if (this.map !== undefined && this.marker !== undefined) { + this.marker.remove(); + } + }, + methods: { $_addMarker: function $_addMarker() { this.marker.setLngLat(this.coordinates).addTo(this.map); this.$_emitEvent("added", { @@ -4247,8 +4186,8 @@ module.exports = /******/ (function(modules) { var Marker_component = normalizeComponent( UI_Markervue_type_script_lang_js_, - Markervue_type_template_id_57267865_render, - Markervue_type_template_id_57267865_staticRenderFns, + Markervue_type_template_id_219782b8_render, + Markervue_type_template_id_219782b8_staticRenderFns, false, null, null, @@ -4257,8 +4196,8 @@ module.exports = /******/ (function(modules) { Marker_component.options.__file = "Marker.vue"; /* harmony default export */ var Marker = Marker_component.exports; - // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Popup.vue?vue&type=template&id=3210c140& - var Popupvue_type_template_id_3210c140_render = function() { + // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Popup.vue?vue&type=template&id=24cace89& + var Popupvue_type_template_id_24cace89_render = function() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; @@ -4269,9 +4208,9 @@ module.exports = /******/ (function(modules) { 2 ); }; - var Popupvue_type_template_id_3210c140_staticRenderFns = []; + var Popupvue_type_template_id_24cace89_staticRenderFns = []; - // CONCATENATED MODULE: ./src/components/UI/Popup.vue?vue&type=template&id=3210c140& + // CONCATENATED MODULE: ./src/components/UI/Popup.vue?vue&type=template&id=24cace89& // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Popup.vue?vue&type=script&lang=js& @@ -4294,7 +4233,8 @@ module.exports = /******/ (function(modules) { /* harmony default export */ var Popupvue_type_script_lang_js_ = { name: "Popup", - mixins: [withRegistration, withEvents, withSelfEvents], + mixins: [withEvents, withSelfEvents], + inject: ["mapbox", "map"], props: { /** * If `true`, a close button will appear in the top right corner of the popup. @@ -4382,8 +4322,12 @@ module.exports = /******/ (function(modules) { return false; } }, + created: function created() { + this.popup = new this.mapbox.Popup(this.$props); + }, mounted: function mounted() { - this.$_checkMapTree(); + this.$_addPopup(); + this.initial = false; }, beforeDestroy: function beforeDestroy() { if (this.map) { @@ -4398,16 +4342,10 @@ module.exports = /******/ (function(modules) { } }, methods: { - $_deferredMount: function $_deferredMount(payload) { - this.map = payload.map; - this.$_addPopup(); - this.initial = false; - payload.component.$off("load", this.$_deferredMount); - }, $_addPopup: function $_addPopup() { var _this = this; - this.popup = new this.mapbox.Popup(_objectSpread({}, this._props)); + this.popup = new this.mapbox.Popup(this.$props); if (this.coordinates !== undefined) this.popup.setLngLat(this.coordinates); @@ -4461,8 +4399,8 @@ module.exports = /******/ (function(modules) { var Popup_component = normalizeComponent( UI_Popupvue_type_script_lang_js_, - Popupvue_type_template_id_3210c140_render, - Popupvue_type_template_id_3210c140_staticRenderFns, + Popupvue_type_template_id_24cace89_render, + Popupvue_type_template_id_24cace89_staticRenderFns, false, null, null, @@ -4490,6 +4428,50 @@ module.exports = /******/ (function(modules) { "touchend", "touchcancel" ]; + // CONCATENATED MODULE: ./src/lib/withRegistration.js + function walkParents(component) { + if (component.baseMap) { + return component; + } else { + if (component.$parent !== undefined) { + return walkParents(component.$parent); + } + } + } + + /* harmony default export */ var withRegistration = { + created: function created() { + this.map = null; + }, + mounted: function mounted() { + this.$_checkMapTree(); // We wait for "load" event from map component to ensure mapbox is loaded and map created + }, + methods: { + $_findBaseMap: function $_findBaseMap() { + var baseMapComponent = walkParents(this.$parent); + + if (baseMapComponent === undefined) { + throw new Error("Component must have root map"); + } + + return baseMapComponent; + }, + $_checkMapTree: function $_checkMapTree() { + var mapComponent = this.$_findBaseMap(); + + if (mapComponent) { + if (mapComponent.mapLoaded) { + this.$_deferredMount({ + component: mapComponent, + map: mapComponent.map + }); + } else { + mapComponent.$on("load", this.$_deferredMount); + } + } + } + } + }; // CONCATENATED MODULE: ./src/components/layer/layerMixin.js var mapboxSourceProps = { @@ -5471,40 +5453,32 @@ module.exports = /******/ (function(modules) { var MglVectorLayer = VectorLayer; var MglRasterLayer = RasterLayer; var MglMarker = Marker; - var MglPopup = Popup; - var main_plugin = { - /** - * Create Vue-mapbox plugin for Vue - * - * @param {Object} Vue - * @param {Object} options: mapboxgl: MapboxGl JS instances - * @returns - */ - install: function install(Vue) { - var options = - arguments.length > 1 && arguments[1] !== undefined - ? arguments[1] - : {}; - var _data = { - mapbox: options.mapboxgl - }; - - if (options.plugins && options.plugins.length) { - options.plugins.forEach(function(plugin) { - var key = Object.keys(plugin)[0]; - var value = Object.values(plugin)[0]; - _data[key] = value; - }); - } - - Vue.mixin({ - data: function data() { - return _data; - } - }); - } - }; - /* harmony default export */ var main = main_plugin; + var MglPopup = Popup; // export const plugin = { + // /** + // * Create Vue-mapbox plugin for Vue + // * + // * @param {Object} Vue + // * @param {Object} options: mapboxgl: MapboxGl JS instances + // * @returns + // */ + // install(Vue, options = {}) { + // const data = { mapbox: options.mapboxgl }; + // if (options.plugins && options.plugins.length) { + // options.plugins.forEach(plugin => { + // const key = Object.keys(plugin)[0]; + // const value = Object.values(plugin)[0]; + // data[key] = value; + // }); + // } + // Vue.mixin({ + // data() { + // return data; + // } + // }); + // } + // }; + + /* harmony default export */ var main = GlMap; // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js /* concated harmony reexport mglRegistrationMixin */ __webpack_require__.d( __webpack_exports__, @@ -5618,13 +5592,6 @@ module.exports = /******/ (function(modules) { return MglPopup; } ); - /* concated harmony reexport plugin */ __webpack_require__.d( - __webpack_exports__, - "plugin", - function() { - return main_plugin; - } - ); /* harmony default export */ var entry_lib = (__webpack_exports__[ "default" diff --git a/dist/vue-mapbox.css b/dist/vue-mapbox.css new file mode 100644 index 00000000..3901d49a --- /dev/null +++ b/dist/vue-mapbox.css @@ -0,0 +1,11 @@ +.mgl-map-wrapper[data-v-54c577ae] { + position: relative; + width: 100%; + height: 100%; +} +.mapboxgl-map[data-v-54c577ae] { + height: 100%; + width: 100%; + overflow: hidden; + position: absolute; +} diff --git a/dist/vue-mapbox.umd.js b/dist/vue-mapbox.umd.js index 3891a878..be3000d1 100644 --- a/dist/vue-mapbox.umd.js +++ b/dist/vue-mapbox.umd.js @@ -1541,6 +1541,11 @@ /***/ }, + /***/ "66e4": /***/ function(module, exports, __webpack_require__) { + // extracted by mini-css-extract-plugin + /***/ + }, + /***/ "6762": /***/ function(module, exports, __webpack_require__) { "use strict"; @@ -2193,20 +2198,6 @@ /***/ }, - /***/ "8615": /***/ function(module, exports, __webpack_require__) { - // https://github.com/tc39/proposal-object-values-entries - var $export = __webpack_require__("5ca1"); - var $values = __webpack_require__("504c")(false); - - $export($export.S, "Object", { - values: function values(it) { - return $values(it); - } - }); - - /***/ - }, - /***/ "86cc": /***/ function(module, exports, __webpack_require__) { var anObject = __webpack_require__("cb7c"); var IE8_DOM_DEFINE = __webpack_require__("c69a"); @@ -2887,6 +2878,25 @@ /***/ }, + /***/ e743: /***/ function( + module, + __webpack_exports__, + __webpack_require__ + ) { + "use strict"; + /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_GlMap_vue_vue_type_style_index_0_id_54c577ae_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( + "66e4" + ); + /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_GlMap_vue_vue_type_style_index_0_id_54c577ae_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n( + _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_GlMap_vue_vue_type_style_index_0_id_54c577ae_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__ + ); + /* unused harmony reexport * */ + /* unused harmony default export */ var _unused_webpack_default_export = + _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_index_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_GlMap_vue_vue_type_style_index_0_id_54c577ae_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0___default.a; + + /***/ + }, + /***/ ebd6: /***/ function(module, exports, __webpack_require__) { // 7.3.20 SpeciesConstructor(O, defaultConstructor) var anObject = __webpack_require__("cb7c"); @@ -2950,19 +2960,7 @@ // Indicate to webpack that this file can be concatenated /* harmony default export */ var setPublicPath = null; - // EXTERNAL MODULE: ./node_modules/core-js/modules/es7.object.values.js - var es7_object_values = __webpack_require__("8615"); - - // EXTERNAL MODULE: ./node_modules/core-js/modules/es6.array.iterator.js - var es6_array_iterator = __webpack_require__("cadf"); - - // EXTERNAL MODULE: ./node_modules/core-js/modules/es6.object.keys.js - var es6_object_keys = __webpack_require__("456d"); - - // EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom.iterable.js - var web_dom_iterable = __webpack_require__("ac6a"); - - // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/map/GlMap.vue?vue&type=template&id=3e0acdb8& + // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/map/GlMap.vue?vue&type=template&id=54c577ae&scoped=true& var render = function() { var _vm = this; var _h = _vm.$createElement; @@ -2970,7 +2968,7 @@ return _c( "div", { staticClass: "mgl-map-wrapper" }, - [_vm._m(0), _vm._t("default")], + [_vm._m(0), _vm.initialized ? _vm._t("default") : _vm._e()], 2 ); }; @@ -2986,7 +2984,16 @@ } ]; - // CONCATENATED MODULE: ./src/components/map/GlMap.vue?vue&type=template&id=3e0acdb8& + // CONCATENATED MODULE: ./src/components/map/GlMap.vue?vue&type=template&id=54c577ae&scoped=true& + + // EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom.iterable.js + var web_dom_iterable = __webpack_require__("ac6a"); + + // EXTERNAL MODULE: ./node_modules/core-js/modules/es6.array.iterator.js + var es6_array_iterator = __webpack_require__("cadf"); + + // EXTERNAL MODULE: ./node_modules/core-js/modules/es6.object.keys.js + var es6_object_keys = __webpack_require__("456d"); // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js function _defineProperty(obj, key, value) { @@ -3225,6 +3232,10 @@ return "map-".concat(("" + Math.random()).split(".")[1]); } }, + mapbox: { + type: Object, + required: true + }, accessToken: { type: String, default: undefined @@ -3650,11 +3661,21 @@ withEvents ], props: options, + provide: function provide() { + var self = this; + return { + mapbox: this.mapbox, + + get map() { + return self.map; + } + }; + }, data: function data() { return { initial: true, baseMap: true, - mapLoaded: false + initialized: false }; }, computed: { @@ -3713,7 +3734,7 @@ _this.$_bindPropsUpdateEvents(); _this.initial = false; - _this.mapLoaded = true; + _this.initialized = true; _this.$emit("load", { map: map, @@ -3727,6 +3748,11 @@ }; // CONCATENATED MODULE: ./src/components/map/GlMap.vue?vue&type=script&lang=js& /* harmony default export */ var map_GlMapvue_type_script_lang_js_ = GlMapvue_type_script_lang_js_; + // EXTERNAL MODULE: ./src/components/map/GlMap.vue?vue&type=style&index=0&id=54c577ae&scoped=true&lang=css& + var GlMapvue_type_style_index_0_id_54c577ae_scoped_true_lang_css_ = __webpack_require__( + "e743" + ); + // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js /* globals __VUE_SSR_CONTEXT__ */ @@ -3838,56 +3864,12 @@ staticRenderFns, false, null, - null, + "54c577ae", null ); component.options.__file = "GlMap.vue"; /* harmony default export */ var GlMap = component.exports; - // CONCATENATED MODULE: ./src/lib/withRegistration.js - function walkParents(component) { - if (component.baseMap) { - return component; - } else { - if (component.$parent !== undefined) { - return walkParents(component.$parent); - } - } - } - - /* harmony default export */ var withRegistration = { - created: function created() { - this.map = null; - }, - mounted: function mounted() { - this.$_checkMapTree(); // We wait for "load" event from map component to ensure mapbox is loaded and map created - }, - methods: { - $_findBaseMap: function $_findBaseMap() { - var baseMapComponent = walkParents(this.$parent); - - if (baseMapComponent === undefined) { - throw new Error("Component must have root map"); - } - - return baseMapComponent; - }, - $_checkMapTree: function $_checkMapTree() { - var mapComponent = this.$_findBaseMap(); - - if (mapComponent) { - if (mapComponent.mapLoaded) { - this.$_deferredMount({ - component: mapComponent, - map: mapComponent.map - }); - } else { - mapComponent.$on("load", this.$_deferredMount); - } - } - } - } - }; // CONCATENATED MODULE: ./src/components/UI/withSelfEvents.js /* harmony default export */ var withSelfEvents = { @@ -3917,20 +3899,26 @@ } }; // CONCATENATED MODULE: ./src/components/UI/controls/controlMixin.js + // import withRegistration from "../../../lib/withRegistration"; /* harmony default export */ var controlMixin = { - mixins: [withRegistration, withEvents, withSelfEvents], + mixins: [withEvents, withSelfEvents], + inject: ["mapbox", "map"], + props: { + position: { + type: String, + default: "top-right" + } + }, beforeDestroy: function beforeDestroy() { - if (this.map !== undefined) { + if (this.map) { this.map.removeControl(this.control); } }, methods: { - $_addControl: function $_addControl(payload) { - this.map = payload.map; - + $_addControl: function $_addControl() { try { - this.map.addControl(this.control); + this.map.addControl(this.control, this.position); } catch (err) { this.$_emitEvent("error", { error: err @@ -3941,7 +3929,6 @@ this.$_emitEvent("added", { control: this.control }); - payload.component.$off("load", this.$_deferredMount); } }, render: function render() {} @@ -3952,23 +3939,18 @@ name: "NavigationControl", mixins: [controlMixin], props: { - position: { - type: String, - default: "top-right" // TODO: add validator + showCompass: { + type: Boolean, + default: true + }, + showZoom: { + type: Boolean, + default: true } }, - data: function data() { - return { - control: undefined - }; - }, created: function created() { - this.control = new this.mapbox.NavigationControl(); - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - } + this.control = new this.mapbox.NavigationControl(this.$props); + this.$_addControl(); } }; // CONCATENATED MODULE: ./src/components/UI/controls/GeolocateControl.js @@ -3992,14 +3974,6 @@ }; } }, - trackUserLocation: { - type: Boolean, - default: false - }, - showUserLocation: { - type: Boolean, - default: true - }, fitBoundsOptions: { type: Object, default: function _default() { @@ -4007,24 +3981,22 @@ maxZoom: 15 }; } + }, + trackUserLocation: { + type: Boolean, + default: false + }, + showUserLocation: { + type: Boolean, + default: true } }, - data: function data() { - return { - control: undefined - }; - }, created: function created() { - this.control = new this.mapbox.GeolocateControl(this._props); + this.control = new this.mapbox.GeolocateControl(this.$props); + this.$_addControl(); + this.$_bindSelfEvents(Object.keys(geolocationEvents), this.control); }, methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - this.$_bindSelfEvents( - Object.keys(geolocationEvents), - this.control - ); - }, $_emitSelfEvent: function $_emitSelfEvent(event) { if (event.type === "error") { this.$_emitMapEvent("geolocate-error", { @@ -4051,23 +4023,14 @@ name: "FullscreenControl", mixins: [controlMixin], props: { - position: { - type: String, - default: "top-right" + container: { + type: HTMLElement, + default: undefined } }, - data: function data() { - return { - control: undefined - }; - }, created: function created() { - this.control = new this.mapbox.FullscreenControl(); - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - } + this.control = new this.mapbox.FullscreenControl(this.$props); + this.$_addControl(); } }; // CONCATENATED MODULE: ./src/components/UI/controls/AttributionControl.js @@ -4085,20 +4048,9 @@ deafault: undefined } }, - data: function data() { - return { - control: undefined - }; - }, created: function created() { - this.control = new this.mapbox.AttributionControl({ - compact: this.compact - }); - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - } + this.control = new this.mapbox.AttributionControl(this.$props); + this.$_addControl(); } }; // CONCATENATED MODULE: ./src/components/UI/controls/ScaleControl.js @@ -4119,11 +4071,6 @@ } } }, - data: function data() { - return { - control: undefined - }; - }, watch: { unit: function unit(next, prev) { if (this.control && next !== prev) { @@ -4132,16 +4079,12 @@ } }, created: function created() { - this.control = new this.mapbox.ScaleControl(this._props); - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - this.$_addControl(payload); - } + this.control = new this.mapbox.ScaleControl(this.$props); + this.$_addControl(); } }; - // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Marker.vue?vue&type=template&id=57267865& - var Markervue_type_template_id_57267865_render = function() { + // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Marker.vue?vue&type=template&id=219782b8& + var Markervue_type_template_id_219782b8_render = function() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; @@ -4152,9 +4095,9 @@ 2 ); }; - var Markervue_type_template_id_57267865_staticRenderFns = []; + var Markervue_type_template_id_219782b8_staticRenderFns = []; - // CONCATENATED MODULE: ./src/components/UI/Marker.vue?vue&type=template&id=57267865& + // CONCATENATED MODULE: ./src/components/UI/Marker.vue?vue&type=template&id=219782b8& // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Marker.vue?vue&type=script&lang=js& @@ -4175,7 +4118,8 @@ }; /* harmony default export */ var Markervue_type_script_lang_js_ = { name: "MapMarker", - mixins: [withRegistration, withEvents, withSelfEvents], + mixins: [withEvents, withSelfEvents], + inject: ["mapbox", "map"], props: { // mapbox marker options offset: { @@ -4216,53 +4160,45 @@ this.marker.setDraggable(next); } }, - mounted: function mounted() { - this.$_checkMapTree(); - }, - beforeDestroy: function beforeDestroy() { - if (this.map !== undefined && this.marker !== undefined) { - this.marker.remove(); - } - }, - methods: { - $_deferredMount: function $_deferredMount(payload) { - var _this = this; - - if (!this.marker) { - var markerOptions = _objectSpread({}, this._props); + created: function created() { + var _this = this; - if (this.$slots.marker) { - markerOptions.element = this.$slots.marker[0].elm; - } + var markerOptions = _objectSpread({}, this.$props); - this.marker = new this.mapbox.Marker(markerOptions); - } + if (this.$slots.marker) { + markerOptions.element = this.$slots.marker[0].elm; + } - this.map = payload.map; - this.$_addMarker(); + this.marker = new this.mapbox.Marker(markerOptions); + this.$_addMarker(); - if (this.$listeners["update:coordinates"]) { - this.marker.on("dragend", function(event) { - var newCoordinates; + if (this.$listeners["update:coordinates"]) { + this.marker.on("dragend", function(event) { + var newCoordinates; - if (_this.coordinates instanceof Array) { - newCoordinates = [ - event.target._lngLat.lng, - event.target._lngLat.lat - ]; - } else { - newCoordinates = event.target._lngLat; - } + if (_this.coordinates instanceof Array) { + newCoordinates = [ + event.target._lngLat.lng, + event.target._lngLat.lat + ]; + } else { + newCoordinates = event.target._lngLat; + } - _this.$emit("update:coordinates", newCoordinates); - }); - } + _this.$emit("update:coordinates", newCoordinates); + }); + } - var eventNames = Object.keys(markerEvents); - this.$_bindSelfEvents(eventNames, this.marker); - this.initial = false; - payload.component.$off("load", this.$_deferredMount); - }, + var eventNames = Object.keys(markerEvents); + this.$_bindSelfEvents(eventNames, this.marker); + this.initial = false; + }, + beforeDestroy: function beforeDestroy() { + if (this.map !== undefined && this.marker !== undefined) { + this.marker.remove(); + } + }, + methods: { $_addMarker: function $_addMarker() { this.marker.setLngLat(this.coordinates).addTo(this.map); this.$_emitEvent("added", { @@ -4293,8 +4229,8 @@ var Marker_component = normalizeComponent( UI_Markervue_type_script_lang_js_, - Markervue_type_template_id_57267865_render, - Markervue_type_template_id_57267865_staticRenderFns, + Markervue_type_template_id_219782b8_render, + Markervue_type_template_id_219782b8_staticRenderFns, false, null, null, @@ -4303,8 +4239,8 @@ Marker_component.options.__file = "Marker.vue"; /* harmony default export */ var Marker = Marker_component.exports; - // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Popup.vue?vue&type=template&id=3210c140& - var Popupvue_type_template_id_3210c140_render = function() { + // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"752d9a0d-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Popup.vue?vue&type=template&id=24cace89& + var Popupvue_type_template_id_24cace89_render = function() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; @@ -4315,9 +4251,9 @@ 2 ); }; - var Popupvue_type_template_id_3210c140_staticRenderFns = []; + var Popupvue_type_template_id_24cace89_staticRenderFns = []; - // CONCATENATED MODULE: ./src/components/UI/Popup.vue?vue&type=template&id=3210c140& + // CONCATENATED MODULE: ./src/components/UI/Popup.vue?vue&type=template&id=24cace89& // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/UI/Popup.vue?vue&type=script&lang=js& @@ -4340,7 +4276,8 @@ /* harmony default export */ var Popupvue_type_script_lang_js_ = { name: "Popup", - mixins: [withRegistration, withEvents, withSelfEvents], + mixins: [withEvents, withSelfEvents], + inject: ["mapbox", "map"], props: { /** * If `true`, a close button will appear in the top right corner of the popup. @@ -4430,8 +4367,12 @@ return false; } }, + created: function created() { + this.popup = new this.mapbox.Popup(this.$props); + }, mounted: function mounted() { - this.$_checkMapTree(); + this.$_addPopup(); + this.initial = false; }, beforeDestroy: function beforeDestroy() { if (this.map) { @@ -4446,18 +4387,10 @@ } }, methods: { - $_deferredMount: function $_deferredMount(payload) { - this.map = payload.map; - this.$_addPopup(); - this.initial = false; - payload.component.$off("load", this.$_deferredMount); - }, $_addPopup: function $_addPopup() { var _this = this; - this.popup = new this.mapbox.Popup( - _objectSpread({}, this._props) - ); + this.popup = new this.mapbox.Popup(this.$props); if (this.coordinates !== undefined) this.popup.setLngLat(this.coordinates); @@ -4511,8 +4444,8 @@ var Popup_component = normalizeComponent( UI_Popupvue_type_script_lang_js_, - Popupvue_type_template_id_3210c140_render, - Popupvue_type_template_id_3210c140_staticRenderFns, + Popupvue_type_template_id_24cace89_render, + Popupvue_type_template_id_24cace89_staticRenderFns, false, null, null, @@ -4540,6 +4473,50 @@ "touchend", "touchcancel" ]; + // CONCATENATED MODULE: ./src/lib/withRegistration.js + function walkParents(component) { + if (component.baseMap) { + return component; + } else { + if (component.$parent !== undefined) { + return walkParents(component.$parent); + } + } + } + + /* harmony default export */ var withRegistration = { + created: function created() { + this.map = null; + }, + mounted: function mounted() { + this.$_checkMapTree(); // We wait for "load" event from map component to ensure mapbox is loaded and map created + }, + methods: { + $_findBaseMap: function $_findBaseMap() { + var baseMapComponent = walkParents(this.$parent); + + if (baseMapComponent === undefined) { + throw new Error("Component must have root map"); + } + + return baseMapComponent; + }, + $_checkMapTree: function $_checkMapTree() { + var mapComponent = this.$_findBaseMap(); + + if (mapComponent) { + if (mapComponent.mapLoaded) { + this.$_deferredMount({ + component: mapComponent, + map: mapComponent.map + }); + } else { + mapComponent.$on("load", this.$_deferredMount); + } + } + } + } + }; // CONCATENATED MODULE: ./src/components/layer/layerMixin.js var mapboxSourceProps = { @@ -5532,40 +5509,32 @@ var MglVectorLayer = VectorLayer; var MglRasterLayer = RasterLayer; var MglMarker = Marker; - var MglPopup = Popup; - var main_plugin = { - /** - * Create Vue-mapbox plugin for Vue - * - * @param {Object} Vue - * @param {Object} options: mapboxgl: MapboxGl JS instances - * @returns - */ - install: function install(Vue) { - var options = - arguments.length > 1 && arguments[1] !== undefined - ? arguments[1] - : {}; - var _data = { - mapbox: options.mapboxgl - }; - - if (options.plugins && options.plugins.length) { - options.plugins.forEach(function(plugin) { - var key = Object.keys(plugin)[0]; - var value = Object.values(plugin)[0]; - _data[key] = value; - }); - } - - Vue.mixin({ - data: function data() { - return _data; - } - }); - } - }; - /* harmony default export */ var main = main_plugin; + var MglPopup = Popup; // export const plugin = { + // /** + // * Create Vue-mapbox plugin for Vue + // * + // * @param {Object} Vue + // * @param {Object} options: mapboxgl: MapboxGl JS instances + // * @returns + // */ + // install(Vue, options = {}) { + // const data = { mapbox: options.mapboxgl }; + // if (options.plugins && options.plugins.length) { + // options.plugins.forEach(plugin => { + // const key = Object.keys(plugin)[0]; + // const value = Object.values(plugin)[0]; + // data[key] = value; + // }); + // } + // Vue.mixin({ + // data() { + // return data; + // } + // }); + // } + // }; + + /* harmony default export */ var main = GlMap; // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js /* concated harmony reexport mglRegistrationMixin */ __webpack_require__.d( __webpack_exports__, @@ -5679,13 +5648,6 @@ return MglPopup; } ); - /* concated harmony reexport plugin */ __webpack_require__.d( - __webpack_exports__, - "plugin", - function() { - return main_plugin; - } - ); /* harmony default export */ var entry_lib = (__webpack_exports__[ "default" diff --git a/dist/vue-mapbox.umd.min.js b/dist/vue-mapbox.umd.min.js index ffa1bd1a..b89ccc0e 100644 --- a/dist/vue-mapbox.umd.min.js +++ b/dist/vue-mapbox.umd.min.js @@ -73,8 +73,8 @@ s = n("41a0"), u = n("7f20"), f = n("38fd"), - d = n("2b4c")("iterator"), - l = !([].keys && "next" in [].keys()), + l = n("2b4c")("iterator"), + d = !([].keys && "next" in [].keys()), p = "@@iterator", h = "keys", m = "values", @@ -87,7 +87,7 @@ S, $, I = function(t) { - if (!l && t in M) return M[t]; + if (!d && t in M) return M[t]; switch (t) { case h: return function() { @@ -106,33 +106,33 @@ E = g == m, L = !1, M = t.prototype, - O = M[d] || M[p] || (g && M[g]), - k = O || I(g), - j = g ? (E ? I("entries") : k) : void 0, + O = M[l] || M[p] || (g && M[g]), + j = O || I(g), + k = g ? (E ? I("entries") : j) : void 0, P = ("Array" == e && M.entries) || O; if ( (P && (($ = f(P.call(new t()))), $ !== Object.prototype && $.next && - (u($, w, !0), r || "function" == typeof $[d] || a($, d, v))), + (u($, w, !0), r || "function" == typeof $[l] || a($, l, v))), E && O && O.name !== m && ((L = !0), - (k = function() { + (j = function() { return O.call(this); })), - (r && !_) || (!l && !L && M[d]) || a(M, d, k), - (c[e] = k), + (r && !_) || (!d && !L && M[l]) || a(M, l, j), + (c[e] = j), (c[w] = v), g) ) if ( - ((x = { values: E ? k : I(m), keys: b ? k : I(h), entries: j }), _) + ((x = { values: E ? j : I(m), keys: b ? j : I(h), entries: k }), _) ) for (S in x) S in M || i(M, S, x[S]); - else o(o.P + o.F * (l || L), e, x); + else o(o.P + o.F * (d || L), e, x); return x; }; }, @@ -188,8 +188,8 @@ s = n("fab2"), u = n("230e"), f = n("7726"), - d = f.process, - l = f.setImmediate, + l = f.process, + d = f.setImmediate, p = f.clearImmediate, h = f.MessageChannel, m = f.Dispatch, @@ -206,8 +206,8 @@ _ = function(t) { b.call(t.data); }; - (l && p) || - ((l = function(t) { + (d && p) || + ((d = function(t) { var e = [], n = 1; while (arguments.length > n) e.push(arguments[n++]); @@ -222,9 +222,9 @@ (p = function(t) { delete y[t]; }), - "process" == n("2d95")(d) + "process" == n("2d95")(l) ? (r = function(t) { - d.nextTick(a(b, t, 1)); + l.nextTick(a(b, t, 1)); }) : m && m.now ? (r = function(t) { @@ -252,7 +252,7 @@ : function(t) { setTimeout(a(b, t, 1), 0); })), - (t.exports = { set: l, clear: p }); + (t.exports = { set: d, clear: p }); }, "1fa8": function(t, e, n) { var r = n("cb7c"); @@ -276,7 +276,7 @@ var s = c(t), u = n(a, s, ""[t]), f = u[0], - d = u[1]; + l = u[1]; i(function() { var e = {}; return ( @@ -292,10 +292,10 @@ s, 2 == e ? function(t, e) { - return d.call(t, this, e); + return l.call(t, this, e); } : function(t) { - return d.call(t, this); + return l.call(t, this); } )); }; @@ -370,8 +370,8 @@ if (!o(t)) return i.call(n, t, e); var r, c, - d, l, + d, p, h = [], m = @@ -385,8 +385,8 @@ f || (r = new RegExp("^" + g.source + "$(?!\\s)", m)); while ((c = g.exec(n))) { if ( - ((d = c.index + c[0][s]), - d > v && + ((l = c.index + c[0][s]), + l > v && (h.push(n.slice(v, c.index)), !f && c[s] > 1 && @@ -395,8 +395,8 @@ void 0 === arguments[p] && (c[p] = void 0); }), c[s] > 1 && c.index < n[s] && a.apply(h, c.slice(1)), - (l = c[0][s]), - (v = d), + (d = c[0][s]), + (v = l), h[s] >= y)) ) break; @@ -404,7 +404,7 @@ } return ( v === n[s] - ? (!l && g.test("")) || h.push("") + ? (!d && g.test("")) || h.push("") : h.push(n.slice(v)), h[s] > y ? h.slice(0, y) : h ); @@ -627,17 +627,17 @@ s = n("27ee"), u = {}, f = {}; - e = t.exports = function(t, e, n, d, l) { + e = t.exports = function(t, e, n, l, d) { var p, h, m, v, - y = l + y = d ? function() { return t; } : s(t), - g = r(n, d, e ? 2 : 1), + g = r(n, l, e ? 2 : 1), b = 0; if ("function" != typeof y) throw TypeError(t + " is not iterable!"); if (i(y)) { @@ -703,8 +703,8 @@ s = n("7726"), u = n("9b43"), f = n("23c6"), - d = n("5ca1"), - l = n("d3f4"), + l = n("5ca1"), + d = n("d3f4"), p = n("d8e8"), h = n("f605"), m = n("4a59"), @@ -722,17 +722,17 @@ L = (E && E.v8) || "", M = s[$], O = "process" == f(w), - k = function() {}, - j = (o = b.f), + j = function() {}, + k = (o = b.f), P = !!(function() { try { var t = M.resolve(1), e = ((t.constructor = {})[n("2b4c")("species")] = function(t) { - t(k, k); + t(j, j); }); return ( (O || "function" == typeof PromiseRejectionEvent) && - t.then(k) instanceof e && + t.then(j) instanceof e && 0 !== L.indexOf("6.6") && -1 === x.indexOf("Chrome/66") ); @@ -740,7 +740,7 @@ })(), T = function(t) { var e; - return !(!l(t) || "function" != typeof (e = t.then)) && e; + return !(!d(t) || "function" != typeof (e = t.then)) && e; }, C = function(t, e) { if (!t._n) { @@ -760,7 +760,7 @@ f = e.domain; try { c - ? (o || (2 == t._h && A(t), (t._h = 1)), + ? (o || (2 == t._h && F(t), (t._h = 1)), !0 === c ? (n = r) : (f && f.enter(), @@ -772,8 +772,8 @@ ? i.call(n, s, u) : s(n)) : u(r); - } catch (d) { - f && !a && f.exit(), u(d); + } catch (l) { + f && !a && f.exit(), u(l); } }; while (n.length > i) a(n[i++]); @@ -787,7 +787,7 @@ n, r, o = t._v, - i = F(t); + i = z(t); if ( (i && ((e = _(function() { @@ -799,17 +799,17 @@ r.error && r.error("Unhandled promise rejection", o); })), - (t._h = O || F(t) ? 2 : 1)), + (t._h = O || z(t) ? 2 : 1)), (t._a = void 0), i && e.e) ) throw e.v; }); }, - F = function(t) { + z = function(t) { return 1 !== t._h && 0 === (t._a || t._c).length; }, - A = function(t) { + F = function(t) { y.call(s, function() { var e; O @@ -817,7 +817,7 @@ : (e = s.onrejectionhandled) && e({ promise: t, reason: t._v }); }); }, - R = function(t) { + A = function(t) { var e = this; e._d || ((e._d = !0), @@ -827,7 +827,7 @@ e._a || (e._a = e._c.slice()), C(e, !0)); }, - z = function(t) { + R = function(t) { var e, n = this; if (!n._d) { @@ -838,14 +838,14 @@ ? g(function() { var r = { _w: n, _d: !1 }; try { - e.call(t, u(z, r, 1), u(R, r, 1)); + e.call(t, u(R, r, 1), u(A, r, 1)); } catch (o) { - R.call(r, o); + A.call(r, o); } }) : ((n._v = t), (n._s = 1), C(n, !1)); } catch (r) { - R.call({ _w: n, _d: !1 }, r); + A.call({ _w: n, _d: !1 }, r); } } }; @@ -853,9 +853,9 @@ ((M = function(t) { h(this, M, $, "_h"), p(t), r.call(this); try { - t(u(z, this, 1), u(R, this, 1)); + t(u(R, this, 1), u(A, this, 1)); } catch (e) { - R.call(this, e); + A.call(this, e); } }), (r = function(t) { @@ -869,7 +869,7 @@ }), (r.prototype = n("dcbc")(M.prototype, { then: function(t, e) { - var n = j(v(this, M)); + var n = k(v(this, M)); return ( (n.ok = "function" != typeof t || t), (n.fail = "function" == typeof e && e), @@ -887,42 +887,42 @@ (i = function() { var t = new r(); (this.promise = t), - (this.resolve = u(z, t, 1)), - (this.reject = u(R, t, 1)); + (this.resolve = u(R, t, 1)), + (this.reject = u(A, t, 1)); }), - (b.f = j = function(t) { + (b.f = k = function(t) { return t === M || t === a ? new i(t) : o(t); })), - d(d.G + d.W + d.F * !P, { Promise: M }), + l(l.G + l.W + l.F * !P, { Promise: M }), n("7f20")(M, $), n("7a56")($), (a = n("8378")[$]), - d(d.S + d.F * !P, $, { + l(l.S + l.F * !P, $, { reject: function(t) { - var e = j(this), + var e = k(this), n = e.reject; return n(t), e.promise; } }), - d(d.S + d.F * (c || !P), $, { + l(l.S + l.F * (c || !P), $, { resolve: function(t) { return S(c && this === a ? M : this, t); } }), - d( - d.S + - d.F * + l( + l.S + + l.F * !( P && n("5cc5")(function(t) { - M.all(t)["catch"](k); + M.all(t)["catch"](j); }) ), $, { all: function(t) { var e = this, - n = j(e), + n = k(e), r = n.resolve, o = n.reject, i = _(function() { @@ -944,7 +944,7 @@ }, race: function(t) { var e = this, - n = j(e), + n = k(e), r = n.reject, o = _(function() { m(t, !1, function(t) { @@ -978,8 +978,8 @@ s = "prototype", u = function(t, e, n) { var f, - d, l, + d, p, h = t & u.F, m = t & u.G, @@ -990,17 +990,17 @@ _ = m ? o : o[e] || (o[e] = {}), x = _[s] || (_[s] = {}); for (f in (m && (n = e), n)) - (d = !h && b && void 0 !== b[f]), - (l = (d ? b : n)[f]), + (l = !h && b && void 0 !== b[f]), + (d = (l ? b : n)[f]), (p = - g && d - ? c(l, r) - : y && "function" == typeof l - ? c(Function.call, l) - : l), - b && a(b, f, l, t & u.U), - _[f] != l && i(_, f, p), - y && x[f] != l && (x[f] = l); + g && l + ? c(d, r) + : y && "function" == typeof d + ? c(Function.call, d) + : d), + b && a(b, f, d, t & u.U), + _[f] != d && i(_, f, p), + y && x[f] != d && (x[f] = d); }; (r.core = o), (u.F = 1), @@ -1093,6 +1093,7 @@ return "String" == r(t) ? t.split("") : Object(t); }; }, + "66e4": function(t, e, n) {}, 6762: function(t, e, n) { "use strict"; var r = n("5ca1"), @@ -1448,7 +1449,7 @@ f(t) ); } - function d(t) { + function l(t) { for (var e = 1; e < arguments.length; e++) { var n = null != arguments[e] ? arguments[e] : {}, r = Object.keys(n); @@ -1459,12 +1460,12 @@ }) )), r.forEach(function(e) { - l(t, e, n[e]); + d(t, e, n[e]); }); } return t; } - function l(t, e, n) { + function d(t, e, n) { return ( e in t ? Object.defineProperty(t, e, { @@ -1514,7 +1515,7 @@ ) s === r - 1 ? c.push( - d( + l( {}, i, (s < 0 || arguments.length <= s @@ -1527,7 +1528,7 @@ ? void 0 : arguments[s]) || null ); - var l = [], + var d = [], m = (arguments.length <= 0 ? void 0 : arguments[0]) || {}; try { n.apply(t, c), @@ -1544,12 +1545,12 @@ (arguments.length <= 3 ? void 0 : arguments[3]) && "object" === f(arguments.length <= 3 ? void 0 : arguments[3]) && - (m = d( + (m = l( {}, m, arguments.length <= 3 ? void 0 : arguments[3] ))), - (l = a.map(function(e) { + (d = a.map(function(e) { var n = e.event, r = e.func; return n.check(t, m) @@ -1564,7 +1565,7 @@ }), v); } - return Promise.all(l).then(function() { + return Promise.all(d).then(function() { return u[e].getter(t); }); }; @@ -1633,11 +1634,11 @@ o.call(r, u); }; else { - var d = !0, - l = document.createTextNode(""); - new i(u).observe(l, { characterData: !0 }), + var l = !0, + d = document.createTextNode(""); + new i(u).observe(d, { characterData: !0 }), (n = function() { - l.data = d = !d; + d.data = l = !l; }); } return function(r) { @@ -1653,15 +1654,6 @@ "84f2": function(t, e) { t.exports = {}; }, - 8615: function(t, e, n) { - var r = n("5ca1"), - o = n("504c")(!1); - r(r.S, "Object", { - values: function(t) { - return o(t); - } - }); - }, "86cc": function(t, e, n) { var r = n("cb7c"), o = n("c69a"), @@ -1822,15 +1814,15 @@ s = " ", u = RegExp("^" + c + c + "*"), f = RegExp(c + c + "*$"), - d = function(t, e, n) { + l = function(t, e, n) { var o = {}, c = i(function() { return !!a[t]() || s[t]() != s; }), - u = (o[t] = c ? e(l) : a[t]); + u = (o[t] = c ? e(d) : a[t]); n && (o[n] = u), r(r.P + r.F * c, "String", o); }, - l = (d.trim = function(t, e) { + d = (l.trim = function(t, e) { return ( (t = String(o(t))), 1 & e && (t = t.replace(u, "")), @@ -1838,7 +1830,7 @@ t ); }); - t.exports = d; + t.exports = l; }, aae3: function(t, e, n) { var r = n("d3f4"), @@ -1859,8 +1851,8 @@ s = n("84f2"), u = n("2b4c"), f = u("iterator"), - d = u("toStringTag"), - l = s.Array, + l = u("toStringTag"), + d = s.Array, p = { CSSRuleList: !0, CSSStyleDeclaration: !1, @@ -1904,7 +1896,7 @@ g = p[y], b = a[y], _ = b && b.prototype; - if (_ && (_[f] || c(_, f, l), _[d] || c(_, d, y), (s[y] = l), g)) + if (_ && (_[f] || c(_, f, d), _[l] || c(_, l, y), (s[y] = d), g)) for (v in r) _[v] || i(_, v, r[v], !0); } }, @@ -1954,8 +1946,8 @@ s = n("79e5"), u = n("9093").f, f = n("11e9").f, - d = n("86cc").f, - l = n("aa77").trim, + l = n("86cc").f, + d = n("aa77").trim, p = "Number", h = r[p], m = h, @@ -1965,7 +1957,7 @@ b = function(t) { var e = c(t, !1); if ("string" == typeof e && e.length > 2) { - e = g ? e.trim() : l(e, 3); + e = g ? e.trim() : d(e, 3); var n, r, o, @@ -2016,7 +2008,7 @@ x.length > S; S++ ) - o(m, (_ = x[S])) && !o(h, _) && d(h, _, f(m, _)); + o(m, (_ = x[S])) && !o(h, _) && l(h, _, f(m, _)); (h.prototype = v), (v.constructor = h), n("2aba")(r, p, h); } }, @@ -2130,6 +2122,12 @@ "," ); }, + e743: function(t, e, n) { + "use strict"; + var r = n("66e4"), + o = n.n(r); + o.a; + }, ebd6: function(t, e, n) { var r = n("cb7c"), o = n("d8e8"), @@ -2158,7 +2156,6 @@ ((r = window.document.currentScript) && (r = r.src.match(/(.+\/)[^\/]+\.js(\?.*)?$/)) && (n.p = r[1])); - n("8615"), n("cadf"), n("456d"), n("ac6a"); var o = function() { var t = this, e = t.$createElement, @@ -2166,7 +2163,7 @@ return n( "div", { staticClass: "mgl-map-wrapper" }, - [t._m(0), t._t("default")], + [t._m(0), t.initialized ? t._t("default") : t._e()], 2 ); }, @@ -2178,6 +2175,7 @@ return n("div", { ref: "container", attrs: { id: t.container } }); } ]; + n("ac6a"), n("cadf"), n("456d"); function a(t, e, n) { return ( e in t @@ -2279,6 +2277,7 @@ return "map-".concat(("" + Math.random()).split(".")[1]); } }, + mapbox: { type: Object, required: !0 }, accessToken: { type: String, default: void 0 }, minZoom: { type: Number, default: 0 }, maxZoom: { type: Number, default: 22 }, @@ -2342,7 +2341,7 @@ fadeDuration: { type: Number, default: 300 }, crossSourceCollisions: { type: Boolean, default: !0 } }), - d = (n("ffc1"), + l = (n("ffc1"), { maxBounds: function(t) { this.map.setMaxBounds(t); @@ -2381,7 +2380,7 @@ this.map.setLigh(t); } }); - function l(t, e, n, r) { + function d(t, e, n, r) { var o = this; this.initial || (this.$listeners["update:".concat(t)] @@ -2397,9 +2396,9 @@ function p() { var t = {}; return ( - Object.entries(d).forEach(function(e) { + Object.entries(l).forEach(function(e) { t[e[0]] = function(t, n) { - return l.call(this, e[0], e[1].bind(this), t, n); + return d.call(this, e[0], e[1].bind(this), t, n); }; }), t @@ -2516,8 +2515,17 @@ name: "GlMap", mixins: [h, g, m, s], props: f, + provide: function() { + var t = this; + return { + mapbox: this.mapbox, + get map() { + return t.map; + } + }; + }, data: function() { - return { initial: !0, baseMap: !0, mapLoaded: !1 }; + return { initial: !0, baseMap: !0, initialized: !1 }; }, computed: { loaded: function() { @@ -2565,7 +2573,7 @@ t.$_registerAsyncActions(e), t.$_bindPropsUpdateEvents(), (t.initial = !1), - (t.mapLoaded = !0), + (t.initialized = !0), t.$emit("load", { map: e, component: t }); }); }, @@ -2574,6 +2582,7 @@ } }, _ = b; + n("e743"); function x(t, e, n, r, o, i, a, c) { var s, u = "function" === typeof t ? t.options : t; @@ -2613,40 +2622,15 @@ return s.call(e), f(t, e); }; } else { - var d = u.beforeCreate; - u.beforeCreate = d ? [].concat(d, s) : [s]; + var l = u.beforeCreate; + u.beforeCreate = l ? [].concat(l, s) : [s]; } return { exports: t, options: u }; } - var S = x(_, o, i, !1, null, null, null); + var S = x(_, o, i, !1, null, "54c577ae", null); S.options.__file = "GlMap.vue"; - var $ = S.exports; - function I(t) { - return t.baseMap ? t : void 0 !== t.$parent ? I(t.$parent) : void 0; - } - var w = { - created: function() { - this.map = null; - }, - mounted: function() { - this.$_checkMapTree(); - }, - methods: { - $_findBaseMap: function() { - var t = I(this.$parent); - if (void 0 === t) throw new Error("Component must have root map"); - return t; - }, - $_checkMapTree: function() { - var t = this.$_findBaseMap(); - t && - (t.mapLoaded - ? this.$_deferredMount({ component: t, map: t.map }) - : t.$on("load", this.$_deferredMount)); - } - } - }, - E = { + var $ = S.exports, + I = { methods: { $_bindSelfEvents: function(t, e) { var n = this; @@ -2663,50 +2647,46 @@ } } }, - L = { - mixins: [w, s, E], + w = { + mixins: [s, I], + inject: ["mapbox", "map"], + props: { position: { type: String, default: "top-right" } }, beforeDestroy: function() { - void 0 !== this.map && this.map.removeControl(this.control); + this.map && this.map.removeControl(this.control); }, methods: { - $_addControl: function(t) { - this.map = t.map; + $_addControl: function() { try { - this.map.addControl(this.control); - } catch (e) { - return void this.$_emitEvent("error", { error: e }); + this.map.addControl(this.control, this.position); + } catch (t) { + return void this.$_emitEvent("error", { error: t }); } - this.$_emitEvent("added", { control: this.control }), - t.component.$off("load", this.$_deferredMount); + this.$_emitEvent("added", { control: this.control }); } }, render: function() {} }, - M = { + E = { name: "NavigationControl", - mixins: [L], - props: { position: { type: String, default: "top-right" } }, - data: function() { - return { control: void 0 }; + mixins: [w], + props: { + showCompass: { type: Boolean, default: !0 }, + showZoom: { type: Boolean, default: !0 } }, created: function() { - this.control = new this.mapbox.NavigationControl(); - }, - methods: { - $_deferredMount: function(t) { - this.$_addControl(t); - } + (this.control = new this.mapbox.NavigationControl(this.$props)), + this.$_addControl(); } }, - O = { + L = { trackuserlocationstart: "trackuserlocationstart", trackuserlocationend: "trackuserlocationend", geolocate: "geolocate", error: "error" }, - k = { + M = { name: "GeolocateControl", - mixins: [s, E, L], + mixins: [s, I, w], props: { positionOptions: { type: Object, @@ -2714,26 +2694,21 @@ return { enableHighAccuracy: !1, timeout: 6e3 }; } }, - trackUserLocation: { type: Boolean, default: !1 }, - showUserLocation: { type: Boolean, default: !0 }, fitBoundsOptions: { type: Object, default: function() { return { maxZoom: 15 }; } - } - }, - data: function() { - return { control: void 0 }; + }, + trackUserLocation: { type: Boolean, default: !1 }, + showUserLocation: { type: Boolean, default: !0 } }, created: function() { - this.control = new this.mapbox.GeolocateControl(this._props); + (this.control = new this.mapbox.GeolocateControl(this.$props)), + this.$_addControl(), + this.$_bindSelfEvents(Object.keys(L), this.control); }, methods: { - $_deferredMount: function(t) { - this.$_addControl(t), - this.$_bindSelfEvents(Object.keys(O), this.control); - }, $_emitSelfEvent: function(t) { "error" === t.type && this.$_emitMapEvent("geolocate-error", { @@ -2747,46 +2722,30 @@ } } }, - j = { + O = { name: "FullscreenControl", - mixins: [L], - props: { position: { type: String, default: "top-right" } }, - data: function() { - return { control: void 0 }; - }, + mixins: [w], + props: { container: { type: HTMLElement, default: void 0 } }, created: function() { - this.control = new this.mapbox.FullscreenControl(); - }, - methods: { - $_deferredMount: function(t) { - this.$_addControl(t); - } + (this.control = new this.mapbox.FullscreenControl(this.$props)), + this.$_addControl(); } }, - P = { + j = { name: "AttributionControl", - mixins: [L], + mixins: [w], props: { compact: { type: Boolean, default: !0 }, customAttribution: { type: [String, Array], deafault: void 0 } }, - data: function() { - return { control: void 0 }; - }, created: function() { - this.control = new this.mapbox.AttributionControl({ - compact: this.compact - }); - }, - methods: { - $_deferredMount: function(t) { - this.$_addControl(t); - } + (this.control = new this.mapbox.AttributionControl(this.$props)), + this.$_addControl(); } }, - T = { + k = { name: "ScaleControl", - mixins: [L], + mixins: [w], props: { maxWidth: { type: Number, default: 150 }, unit: { @@ -2797,24 +2756,17 @@ } } }, - data: function() { - return { control: void 0 }; - }, watch: { unit: function(t, e) { this.control && t !== e && this.control.setUnit(t); } }, created: function() { - this.control = new this.mapbox.ScaleControl(this._props); - }, - methods: { - $_deferredMount: function(t) { - this.$_addControl(t); - } + (this.control = new this.mapbox.ScaleControl(this.$props)), + this.$_addControl(); } }, - C = function() { + P = function() { var t = this, e = t.$createElement, n = t._self._c || e; @@ -2825,11 +2777,12 @@ 2 ); }, - B = [], - F = { drag: "drag", dragstart: "dragstart", dragend: "dragend" }, - A = { + T = [], + C = { drag: "drag", dragstart: "dragstart", dragend: "dragend" }, + B = { name: "MapMarker", - mixins: [w, s, E], + mixins: [s, I], + inject: ["mapbox", "map"], props: { offset: { type: [Object, Array], @@ -2853,8 +2806,23 @@ this.initial || this.marker.setDraggable(t); } }, - mounted: function() { - this.$_checkMapTree(); + created: function() { + var t = this, + e = c({}, this.$props); + this.$slots.marker && (e.element = this.$slots.marker[0].elm), + (this.marker = new this.mapbox.Marker(e)), + this.$_addMarker(), + this.$listeners["update:coordinates"] && + this.marker.on("dragend", function(e) { + var n; + (n = + t.coordinates instanceof Array + ? [e.target._lngLat.lng, e.target._lngLat.lat] + : e.target._lngLat), + t.$emit("update:coordinates", n); + }); + var n = Object.keys(C); + this.$_bindSelfEvents(n, this.marker), (this.initial = !1); }, beforeDestroy: function() { void 0 !== this.map && @@ -2862,29 +2830,6 @@ this.marker.remove(); }, methods: { - $_deferredMount: function(t) { - var e = this; - if (!this.marker) { - var n = c({}, this._props); - this.$slots.marker && (n.element = this.$slots.marker[0].elm), - (this.marker = new this.mapbox.Marker(n)); - } - (this.map = t.map), - this.$_addMarker(), - this.$listeners["update:coordinates"] && - this.marker.on("dragend", function(t) { - var n; - (n = - e.coordinates instanceof Array - ? [t.target._lngLat.lng, t.target._lngLat.lat] - : t.target._lngLat), - e.$emit("update:coordinates", n); - }); - var r = Object.keys(F); - this.$_bindSelfEvents(r, this.marker), - (this.initial = !1), - t.component.$off("load", this.$_deferredMount); - }, $_addMarker: function() { this.marker.setLngLat(this.coordinates).addTo(this.map), this.$_emitEvent("added", { marker: this.marker }); @@ -2901,11 +2846,11 @@ } } }, - R = A, - z = x(R, C, B, !1, null, null, null); - z.options.__file = "Marker.vue"; - var N = z.exports, - Z = function() { + z = B, + F = x(z, P, T, !1, null, null, null); + F.options.__file = "Marker.vue"; + var A = F.exports, + R = function() { var t = this, e = t.$createElement, n = t._self._c || e; @@ -2916,11 +2861,12 @@ 2 ); }, - D = [], - U = { open: "open", close: "close" }, - G = { + N = [], + Z = { open: "open", close: "close" }, + D = { name: "Popup", - mixins: [w, s, E], + mixins: [s, I], + inject: ["mapbox", "map"], props: { closeButton: { type: Boolean, default: !0 }, closeOnClick: { type: Boolean, default: !0 }, @@ -2957,8 +2903,11 @@ return void 0 !== this.popup && this.popup.isOpen(); } }, + created: function() { + this.popup = new this.mapbox.Popup(this.$props); + }, mounted: function() { - this.$_checkMapTree(); + this.$_addPopup(), (this.initial = !1); }, beforeDestroy: function() { this.map && (this.popup.remove(), this.$_emitEvent("removed")); @@ -2969,16 +2918,10 @@ } }, methods: { - $_deferredMount: function(t) { - (this.map = t.map), - this.$_addPopup(), - (this.initial = !1), - t.component.$off("load", this.$_deferredMount); - }, $_addPopup: function() { var t = this; if ( - ((this.popup = new this.mapbox.Popup(c({}, this._props))), + ((this.popup = new this.mapbox.Popup(this.$props)), void 0 !== this.coordinates && this.popup.setLngLat(this.coordinates), void 0 !== this.$slots.default) @@ -2992,7 +2935,7 @@ this.popup.setText(this.$slots.default[0].elm.innerText); else this.popup.setDOMContent(this.$slots.default[0].elm); this.popup.addTo(this.map), - this.$_bindSelfEvents(Object.keys(U), this.popup), + this.$_bindSelfEvents(Object.keys(Z), this.popup), this.$_emitEvent("added", { popup: this.popup }), void 0 !== this.$parent.marker ? this.$parent.marker.setPopup(this.popup) @@ -3010,11 +2953,11 @@ } } }, - V = G, - q = x(V, Z, D, !1, null, null, null); - q.options.__file = "Popup.vue"; - var H = q.exports, - W = (n("a481"), + U = D, + G = x(U, R, N, !1, null, null, null); + G.options.__file = "Popup.vue"; + var V = G.exports, + q = (n("a481"), [ "mousedown", "mouseup", @@ -3029,7 +2972,32 @@ "touchstart", "touchend", "touchcancel" - ]), + ]); + function H(t) { + return t.baseMap ? t : void 0 !== t.$parent ? H(t.$parent) : void 0; + } + var W = { + created: function() { + this.map = null; + }, + mounted: function() { + this.$_checkMapTree(); + }, + methods: { + $_findBaseMap: function() { + var t = H(this.$parent); + if (void 0 === t) throw new Error("Component must have root map"); + return t; + }, + $_checkMapTree: function() { + var t = this.$_findBaseMap(); + t && + (t.mapLoaded + ? this.$_deferredMount({ component: t, map: t.map }) + : t.$on("load", this.$_deferredMount)); + } + } + }, X = { sourceId: { type: String, required: !0 }, source: { type: [Object, String], default: void 0 } @@ -3045,7 +3013,7 @@ replace: { type: Boolean, default: !1 } }, J = { - mixins: [w, s], + mixins: [W, s], props: c({}, X, K, Y), data: function() { return { initial: !0 }; @@ -3286,7 +3254,7 @@ } } this.$_addLayer(), - this.$_bindLayerEvents(W), + this.$_bindLayerEvents(q), this.map.off("dataloading", this.$_watchSourceLoading), (this.initial = !1), t.component.$off("load", this.$_deferredMount); @@ -3362,7 +3330,7 @@ this.map.addSource(this.sourceId, e)); } this.$_addLayer(), - this.$_bindLayerEvents(W), + this.$_bindLayerEvents(q), (this.initial = !1), t.component.$off("load", this.$_deferredMount); }, @@ -3437,7 +3405,7 @@ this.map.addSource(this.sourceId, n)); } this.$_addLayer(), - this.$_bindLayerEvents(W), + this.$_bindLayerEvents(q), t.component.$off("load", this.$_deferredMount), (this.initial = !1); }, @@ -3502,7 +3470,7 @@ this.map.addSource(this.sourceId, e)); } this.$_addLayer(), - this.$_bindLayerEvents(W), + this.$_bindLayerEvents(q), (this.initial = !1), t.component.$off("load", this.$_deferredMount); }, @@ -3571,7 +3539,7 @@ this.map.addSource(this.sourceId, e)); } this.$_addLayer(), - this.$_bindLayerEvents(W), + this.$_bindLayerEvents(q), this.map.off("dataloading", this.$_watchSourceLoading), (this.initial = !1), t.component.$off("load", this.$_deferredMount); @@ -3632,7 +3600,7 @@ this.map.addSource(this.sourceId, e)); } this.$_addLayer(), - this.$_bindLayerEvents(W), + this.$_bindLayerEvents(q), this.map.off("dataloading", this.$_watchSourceLoading), (this.initial = !1), t.component.$off("load", this.$_deferredMount); @@ -3656,44 +3624,23 @@ } } }, - it = w, - at = L, + it = W, + at = w, ct = $, - st = M, - ut = k, - ft = j, - dt = P, - lt = T, + st = E, + ut = M, + ft = O, + lt = j, + dt = k, pt = Q, ht = tt, mt = et, vt = nt, yt = rt, gt = ot, - bt = N, - _t = H, - xt = { - install: function(t) { - var e = - arguments.length > 1 && void 0 !== arguments[1] - ? arguments[1] - : {}, - n = { mapbox: e.mapboxgl }; - e.plugins && - e.plugins.length && - e.plugins.forEach(function(t) { - var e = Object.keys(t)[0], - r = Object.values(t)[0]; - n[e] = r; - }), - t.mixin({ - data: function() { - return n; - } - }); - } - }, - St = xt; + bt = A, + _t = V, + xt = $; n.d(e, "mglRegistrationMixin", function() { return it; }), @@ -3713,10 +3660,10 @@ return ft; }), n.d(e, "MglAttributionControl", function() { - return dt; + return lt; }), n.d(e, "MglScaleControl", function() { - return lt; + return dt; }), n.d(e, "MglGeojsonLayer", function() { return pt; @@ -3741,11 +3688,8 @@ }), n.d(e, "MglPopup", function() { return _t; - }), - n.d(e, "plugin", function() { - return xt; }); - e["default"] = St; + e["default"] = xt; }, fdef: function(t, e) { t.exports = "\t\n\v\f\r \u2028\u2029\ufeff"; diff --git a/docs/404.html b/docs/404.html index 166139b7..eef25c12 100644 --- a/docs/404.html +++ b/docs/404.html @@ -7,11 +7,11 @@ - +