(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory(require("vue"), require("@kq_npm/client_common_vue/_utils/mitt"), require("@kq_npm/client_common_vue/_utils/gis-utils"));
	else if(typeof define === 'function' && define.amd)
		define("@kq_npm/client_leaflet_vue", ["vue", "@kq_npm/client_common_vue/_utils/mitt", "@kq_npm/client_common_vue/_utils/gis-utils"], factory);
	else if(typeof exports === 'object')
		exports["@kq_npm/client_leaflet_vue"] = factory(require("vue"), require("@kq_npm/client_common_vue/_utils/mitt"), require("@kq_npm/client_common_vue/_utils/gis-utils"));
	else
		root["@kq_npm/client_leaflet_vue"] = factory(root["Vue"], root["@kq_npm/client_common_vue/_utils/mitt"], root["@kq_npm/client_common_vue/_utils/gis-utils"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE__1895__, __WEBPACK_EXTERNAL_MODULE__8905__, __WEBPACK_EXTERNAL_MODULE__7135__) {
return /******/ (function() { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 2118:
/***/ (function(module) {

module.exports = require("core-js/modules/es.array.push.js");

/***/ }),

/***/ 8470:
/***/ (function(module) {

module.exports = require("core-js/modules/esnext.iterator.constructor.js");

/***/ }),

/***/ 8697:
/***/ (function(module) {

module.exports = require("core-js/modules/esnext.iterator.find.js");

/***/ }),

/***/ 1058:
/***/ (function(module) {

module.exports = require("core-js/modules/esnext.iterator.for-each.js");

/***/ }),

/***/ 2170:
/***/ (function(module) {

module.exports = require("core-js/modules/esnext.iterator.map.js");

/***/ }),

/***/ 6869:
/***/ (function(module) {

module.exports = require("xe-utils");

/***/ }),

/***/ 7135:
/***/ (function(module) {

module.exports = __WEBPACK_EXTERNAL_MODULE__7135__;

/***/ }),

/***/ 8905:
/***/ (function(module) {

module.exports = __WEBPACK_EXTERNAL_MODULE__8905__;

/***/ }),

/***/ 1895:
/***/ (function(module) {

module.exports = __WEBPACK_EXTERNAL_MODULE__1895__;

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	!function() {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = function(module) {
/******/ 			var getter = module && module.__esModule ?
/******/ 				function() { return module['default']; } :
/******/ 				function() { return module; };
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/define property getters */
/******/ 	!function() {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = function(exports, definition) {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	!function() {
/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	!function() {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = function(exports) {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	}();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
!function() {
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "Scale": function() { return /* binding */ Scale; },
  "ScaleViewModel": function() { return /* reexport */ ScaleViewModel; },
  "default": function() { return /* binding */ Scale; }
});

// EXTERNAL MODULE: external "core-js/modules/es.array.push.js"
var es_array_push_js_ = __webpack_require__(2118);
// EXTERNAL MODULE: external "core-js/modules/esnext.iterator.constructor.js"
var esnext_iterator_constructor_js_ = __webpack_require__(8470);
// EXTERNAL MODULE: external "core-js/modules/esnext.iterator.find.js"
var esnext_iterator_find_js_ = __webpack_require__(8697);
// EXTERNAL MODULE: external "core-js/modules/esnext.iterator.for-each.js"
var esnext_iterator_for_each_js_ = __webpack_require__(1058);
// EXTERNAL MODULE: external "core-js/modules/esnext.iterator.map.js"
var esnext_iterator_map_js_ = __webpack_require__(2170);
// EXTERNAL MODULE: external {"root":"Vue","commonjs":"vue","commonjs2":"vue","amd":"vue"}
var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_ = __webpack_require__(1895);
// EXTERNAL MODULE: external "@kq_npm/client_common_vue/_utils/mitt"
var mitt_ = __webpack_require__(8905);
var mitt_default = /*#__PURE__*/__webpack_require__.n(mitt_);
// EXTERNAL MODULE: external "@kq_npm/client_common_vue/_utils/gis-utils"
var gis_utils_ = __webpack_require__(7135);
;// CONCATENATED MODULE: ./src/leaflet/scale/ScaleViewModel.js
/*
 * Copyright (C) 2019 KQ GEO Technologies Co., Ltd.
 * All rights reserved.
 */
/**
 * Author: 朱鹏超
 * Date: 2022-11-23
 * Description: 2d比例尺组件逻辑层
 */




/**
 * @class ScaleViewModel
 * @classdesc 2d比例尺组件逻辑层
 * @param {string} mapTarget - 绑定的当前mapview
 */

class ScaleViewModel extends (mitt_default()) {
  constructor(mapTarget) {
    super();
    this._props = {
      mapTarget
    };
    this._webMap = null;
    // 事件绑定this
    this._loadedAsync = this._loadedAsync.bind(this);
    this._loadedSync = this._loadedSync.bind(this);
  }

  /**
   * @description 逻辑初始化
   */
  init() {
    let maplayers = gis_utils_.mapLayerUtils.getLayerData(this._props.mapTarget);
    if (!maplayers) {
      // mapview初始化结束监听 如果view已经存在了，mounted事件不会添加监听，异步
      gis_utils_.mapViewUtils.bindViewOnceEvents("mounted", this._loadedAsync, this._props.mapTarget);
    } else {
      // 同步
      gis_utils_.utils.getWebMap(this._props.mapTarget, this._loadedSync);
    }
  }

  /**
   * @description 异步加载
   * @fires event:getWebMap
   * @private
   */
  _loadedAsync(e) {
    // 如果图层变化事件是自己触发的 则不继续执行 避免死循环
    if (e.eventTarget && e.eventTarget === this) {
      return;
    }
    let webMap = this._webMap = e.target;
    this.fire("getWebMap", {
      webMap
    });
  }

  /**
   * @description 同步加载
   * @private
   */
  _loadedSync(e) {
    let webMap = this._webMap = e;
    this.fire("getWebMap", {
      webMap
    });
  }
  destroy() {
    this.off();
  }
}
;// CONCATENATED MODULE: ./src/leaflet/scale/scale.js



/*
 * Copyright (C) 2019 KQ GEO Technologies Co., Ltd.
 * All rights reserved.
 */


const allActivedScales = []; // 生成的比例尺集合

/* harmony default export */ var scale = ((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.defineComponent)({
  name: "Kq2dScale",
  props: {
    mapTarget: String,
    // 控制显示隐藏
    modelValue: {
      type: Boolean,
      default: true
    },
    id: {
      type: String,
      default: null
    },
    // 填充，false|'fill'|'hollow'|'line',默认 false
    fill: {
      type: [Boolean, String],
      default: false
    },
    // 双线模式，默认false关闭
    doubleLine: {
      type: Boolean,
      default: false
    },
    // 显示子单元,在零的左侧显示较小的分区,默认false关闭
    showSubunits: {
      type: Boolean,
      default: false
    },
    // 比例单位的最小宽度
    minUnitWidth: {
      type: Number,
      default: 30
    },
    // 不包含子单位的比例尺的最大宽度
    maxUnitsWidth: {
      type: Number,
      default: 240
    },
    // 'auto'|'top'|'bottom'，在比例尺的顶部/底部显示距离标签。如果设置为自动，当比例控制在地图底部时，标签将被放置在顶部，当比例控制在地图顶部时，标签将被放置在底部（position参数）
    labelPlacement: {
      type: String,
      default: "auto"
    },
    // 控件的位置（地图角之一）。可能的值为'topLeft', 'topRight','bottomLeft'或'bottomRight'
    position: {
      type: String,
      default: "topRight"
    },
    // 如果true，控件在 moveend后更新，否则它move是更新
    updateWhenIdle: {
      type: Boolean,
      default: false
    },
    // 设置scale样式的回调函数
    setScaleStyle: Function
  },
  setup(props, context) {
    let viewModel = null;
    const {
      mapTarget,
      fill,
      doubleLine,
      showSubunits,
      minUnitWidth,
      maxUnitsWidth,
      labelPlacement,
      position,
      updateWhenIdle
    } = props;

    // position 映射
    var position_key = {
      topLeft: "topleft",
      topRight: "topright",
      bottomLeft: "bottomleft",
      bottomRight: "bottomright"
    };
    const $scale = {
      props
    };

    // 创建scale
    const createScale = webMap => {
      return webMap.mapControl.createScale({
        fill,
        doubleLine,
        showSubunits,
        minUnitWidth,
        maxUnitsWidth,
        labelPlacement,
        position: position_key[position],
        updateWhenIdle
      });
    };

    // 当前生成的比例尺实例
    let currentScale = null;
    const setScale = () => {
      return new Promise(resolve => {
        viewModel.on("getWebMap", _data => {
          let scale = createScale(_data.webMap);
          resolve(scale);
        });
        viewModel.init();
      });
    };

    /**
     * @description 初始化比例尺
     */
    const init = () => {
      const {
        setScaleStyle,
        id
      } = props;
      setScale().then(result => {
        Object.assign($scale, {
          scale: result
        });
        allActivedScales.push($scale);
        currentScale = result;
        setScaleStyle && setScaleStyle(result);
      });
    };

    /**
     * @description 清除比例尺
     * @param {Object} [scale] - 初始化生成的比例尺实例
     */
    const remove = scale => {
      if (!scale) {
        scale = currentScale;
      }
      viewModel._webMap && viewModel._webMap.map && viewModel._webMap.map.removeControl(scale);
      viewModel.destroy();
    };
    Object.assign($scale, {
      remove
    });
    (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.watch)(() => props.modelValue, value => {
      if (value) {
        init();
      } else {
        remove();
      }
    });
    (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.onMounted)(() => {
      viewModel = new ScaleViewModel(mapTarget);
      if (props.modelValue) {
        init();
      }
    });
    (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.onUnmounted)(() => {
      remove();
      viewModel = null;
    });
    return {
      remove,
      init
    };
  },
  render() {
    return null;
  }
}));
;// CONCATENATED MODULE: ./src/leaflet/scale/dynamics.js


/*
 * Copyright (C) 2019 KQ GEO Technologies Co., Ltd.
 * All rights reserved.
 */

let dynamicContainerElem;
const dynamicStore = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.reactive)({
  modals: []
});

// 动态组件
const BaseDynamics = {
  setup() {
    return () => {
      const {
        modals
      } = dynamicStore;
      return (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.h)("div", {
        class: "kq-base-dynamics--scale"
      }, {
        default: () => modals.map(item => {
          return (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.h)((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.resolveComponent)("kq2d-scale"), item);
        })
      });
    };
  }
};
const dynamicApp = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createApp)(BaseDynamics);
function checkDynamic() {
  if (!dynamicContainerElem) {
    dynamicContainerElem = document.createElement("div");
    dynamicContainerElem.className = "kq-base-dynamics";
    document.body.appendChild(dynamicContainerElem);
    dynamicApp.mount(dynamicContainerElem);
  }
}
// EXTERNAL MODULE: external "xe-utils"
var external_xe_utils_ = __webpack_require__(6869);
var external_xe_utils_default = /*#__PURE__*/__webpack_require__.n(external_xe_utils_);
;// CONCATENATED MODULE: ./src/leaflet/scale/index.js




/*
 * Copyright (C) 2019 KQ GEO Technologies Co., Ltd.
 * All rights reserved.
 */





/**
 * @description 获取scale
 * @param {string} id - scale的id
 */
const getScale = id => {
  return external_xe_utils_default().find(allActivedScales, $modal => $modal.props.id === id);
};
const ScaleController = {
  /**
   * @description 初始化动态比例尺组件
   * @param {Object} options - 参数详情参考 scale.js文件中的props
   */
  init: options => {
    options.modelValue = true;
    dynamicStore.modals.push(options);
    checkDynamic();
  },
  /**
   * @description 全局关闭动态的比例尺（只能用于关闭动态的创建的比例尺），如果传 id 则关闭指定的比例尺，如果不传则关闭所有比例尺
   * @param {string} id - scale的id
   */
  remove: id => {
    const modals = id ? [getScale(id)] : allActivedScales;
    modals.forEach($modal => {
      if ($modal) {
        $modal.remove($modal.scale);
      }
    });
  }
};

/**
 * @description Scale组件实例
 */
const Scale = Object.assign(scale, {
  install: function (Vue) {
    dynamicApp.component(Scale.name, Scale);
    Vue.component(scale.name, scale);
    Vue.config.globalProperties.$Kq2dScale = ScaleController;
  }
});

}();
/******/ 	return __webpack_exports__;
/******/ })()
;
});