(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"), require("@kq_npm/client_common_vue/_utils/util"), require("@kq_npm/client_common_vue/init.js"));
	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", "@kq_npm/client_common_vue/_utils/util", "@kq_npm/client_common_vue/init.js"], 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"), require("@kq_npm/client_common_vue/_utils/util"), require("@kq_npm/client_common_vue/init.js"));
	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"], root["@kq_npm/client_common_vue/_utils/util"], root["@kq_npm/client_common_vue/init.js"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE__1895__, __WEBPACK_EXTERNAL_MODULE__8905__, __WEBPACK_EXTERNAL_MODULE__7135__, __WEBPACK_EXTERNAL_MODULE__3458__, __WEBPACK_EXTERNAL_MODULE__7997__) {
return /******/ (function() { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

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

module.exports = require("@element-plus/icons-vue");

/***/ }),

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

module.exports = __WEBPACK_EXTERNAL_MODULE__7135__;

/***/ }),

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

module.exports = __WEBPACK_EXTERNAL_MODULE__8905__;

/***/ }),

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

module.exports = __WEBPACK_EXTERNAL_MODULE__3458__;

/***/ }),

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

module.exports = __WEBPACK_EXTERNAL_MODULE__7997__;

/***/ }),

/***/ 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__, {
  "ScaleLocationViewModel": function() { return /* reexport */ ScaleLocationViewModel; },
  "default": function() { return /* reexport */ ScaleLocation; }
});

// 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/scalelocation/ScaleLocationViewModel.js
/*
 * Copyright (C) 2019 KQ GEO Technologies Co., Ltd.
 * All rights reserved.
 */

/**
 * Author: 朱鹏超
 * Date: 2022-11-23
 * Description: 比例尺定位逻辑层
 */


/**
 * @class ScaleLocationViewModel
 * @classdesc 比例尺定位
 * @param {string} mapTarget - 绑定的当前mapview
 */

class ScaleLocationViewModel extends (mitt_default()) {
  constructor(mapTarget, decimalPlaces) {
    super();
    this._props = {
      mapTarget,
      decimalPlaces
    };
    this._webMap = null; // 事件绑定this

    this._getScalesAsync = this._getScalesAsync.bind(this);
    this._getScalesSync = this._getScalesSync.bind(this);
  }
  /**
   * @description 逻辑初始化
   */


  init() {
    gis_utils_.utils.getWebMap(this._props.mapTarget, this._getScalesSync);
  }
  /**
   * @description 异步获取scales
   * @fires event:getScales
   * @private
   */


  _getScalesAsync(e) {
    // 如果图层变化事件是自己触发的 则不继续执行 避免死循环
    if (e.eventTarget && e.eventTarget === this) {
      return;
    }

    let webMap = this._webMap = e.target;

    if (e && e.target) {
      let scale = e.target.getScale();
      scale.forEach((item, index, array) => {
        array[index] = this.roundToDecimalPlace(item, this._props.decimalPlaces);
      });
      this.fire("getScales", {
        scale,
        webMap
      });
    } // else {
    //   let scale = [];
    //   for (let i = 0; i < e.target.map.getMaxZoom() + 1; i++) {
    //     scale.push(i);
    //   }
    //   this.fire("getScales", { scale, webMap });
    // }

  }
  /**
   * @description 同步获取scales
   * @private
   */


  _getScalesSync(e) {
    let scale = e.getScale();
    scale.forEach((item, index, array) => {
      array[index] = this.roundToDecimalPlace(item, this._props.decimalPlaces);
    });
    let webMap = this._webMap = e;
    this.fire("getScales", {
      scale,
      webMap
    });
  }
  /**
   * @description 获取比例尺，返回scale&webMap
   * @returns {scale,webMap}
   */


  getScales() {
    if (this._webMap) {
      return {
        scale: this._webMap.getScale(),
        webMap: this._webMap
      };
    }
  }

  roundToDecimalPlace(number, decimalPlaces) {
    var factor = Math.pow(10, decimalPlaces);
    var tempNumber = number * factor;
    var roundedTempNumber = Math.round(tempNumber);
    return roundedTempNumber / factor;
  }

}
// EXTERNAL MODULE: external "@kq_npm/client_common_vue/_utils/util"
var util_ = __webpack_require__(3458);
// EXTERNAL MODULE: external "@element-plus/icons-vue"
var icons_vue_ = __webpack_require__(8422);
;// CONCATENATED MODULE: ./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/leaflet/scalelocation/ScaleLocation.vue?vue&type=script&setup=true&lang=js

const _hoisted_1 = {
  style: {
    "max-height": "400px",
    "width": "165px",
    "overflow-x": "hidden"
  }
};




const __default__ = {
  name: "Kq2dScaleLocation"
};
/* harmony default export */ var ScaleLocationvue_type_script_setup_true_lang_js = (/*#__PURE__*/Object.assign(__default__, {
  props: {
    mapTarget: String,
    scaleValue: {
      type: Object,
      default: {
        value: "",
        icon: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.markRaw)(icons_vue_.ScaleToOriginal)
      }
    },
    showShadow: {
      type: Boolean,
      default: false
    },

    /**
     * 例："center", {top:'16px',left:'16px'}, {top:16,left:16}
     */
    position: [String, Object],

    /**
     * 初始化时，比例尺的显示值
     */
    scaleNames: {
      type: Array,
      default: []
    },

    /**
     * 初始化时，显示的小数位数
     */
    decimalPlaces: {
      type: Number,
      default: 5
    }
  },

  setup(__props, {
    expose: __expose
  }) {
    const props = __props; // 组件变量集合

    let scaleItem = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.reactive)({
      // map: null, // 地图实例
      value: "",
      // 比例尺值
      type: "scale",
      // toolbar类型
      icon: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.markRaw)(icons_vue_.ScaleToOriginal),
      // toolbar icon
      children: [] // 子项

    });
    let _map = null; // 组件容器Ref

    let boxRef = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.ref)(); // 逻辑类

    let viewModel = null; // 比例尺定位ref

    let kqScrollbarRef = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.ref)();
    (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.onMounted)(() => {
      (0,util_.updatePosition)(boxRef.value.$el, props);
      viewModel = new ScaleLocationViewModel(props.mapTarget, props.decimalPlaces);
      viewModel.on("getScales", _data => {
        setScale(_data.scale, _data.webMap.map.getZoom(), _data.webMap.map);
      });
      (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.nextTick)(() => {
        // 逻辑初始化
        viewModel.init();
      });
    });
    /**
     * @description 设置比例尺
     */

    function setScale(s, level, map) {
      scaleItem.children = [];

      for (let i = 0; i < s.length; i++) {
        if (i === level) {
          let _v = "1:" + Math.round(s[i] * 1000000) / 1000000;

          if (props.scaleNames.length && props.scaleNames[i]) {
            _v = props.scaleNames[i];
          }

          scaleItem.value = _v;
          map.setZoom(level);
        }

        _map = map;
        let hasMax = typeof map.options.maxZoom === "number" && !isNaN(map.options.maxZoom);
        let hasMin = typeof map.options.minZoom === "number" && !isNaN(map.options.minZoom);

        if (hasMax && hasMin) {
          if (i <= map.options.maxZoom && i >= map.options.minZoom) {
            let name = "1:" + Math.round(s[i] * 1000000) / 1000000;

            if (props.scaleNames.length && props.scaleNames[i]) {
              name = props.scaleNames[i];
            }

            scaleItem.children.push({
              id: "1_" + i,
              name
            });
          }
        } else if (hasMax && !hasMin) {
          if (i <= map.options.maxZoom) {
            let name = "1:" + Math.round(s[i] * 1000000) / 1000000;

            if (props.scaleNames.length && props.scaleNames[i]) {
              name = props.scaleNames[i];
            }

            scaleItem.children.push({
              id: "1_" + i,
              name
            });
          }
        } else if (!hasMax && hasMin) {
          if (i >= map.options.minZoom) {
            let name = "1:" + Math.round(s[i] * 1000000) / 1000000;

            if (props.scaleNames.length && props.scaleNames[i]) {
              name = props.scaleNames[i];
            }

            scaleItem.children.push({
              id: "1_" + i,
              name
            });
          }
        }

        map.on("zoomend", function (e) {
          if (i === e.target.getZoom()) {
            let _v = "1:" + Math.round(s[i] * 1000000) / 1000000;

            if (props.scaleNames.length && props.scaleNames[i]) {
              _v = props.scaleNames[i];
            }

            scaleItem.value = _v;
          }
        });
      }
    }
    /**
     * @description 监听选择比例尺
     * @param {string} value - childItem.value
     * @param {Object} item - childItem
     * @param {Object} parent - scaleItem
     */


    const onSelectScale = (value, item, parent) => {
      let z = Number(value.index.split("_")[1]);

      _map.setZoom(z);

      parent.value = item.name;
    }; // 切换空间参考时刷新


    const refresh = (s, level, map) => {
      setScale(s, level, map);
      map.setZoom(level); // setScale(viewModel._webMap.map.options.zoom, viewModel._webMap.map.getZoom(), viewModel._webMap.map);
    };

    __expose({
      refresh
    });

    return (_ctx, _cache) => {
      const _component_kq_icon = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.resolveComponent)("kq-icon");

      const _component_kq_menu_item = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.resolveComponent)("kq-menu-item");

      const _component_kq_scrollbar = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.resolveComponent)("kq-scrollbar");

      const _component_kq_sub_menu = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.resolveComponent)("kq-sub-menu");

      const _component_kq_menu = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.resolveComponent)("kq-menu");

      return (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.openBlock)(), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createBlock)(_component_kq_menu, {
        class: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.normalizeClass)(["kq2d-scale-location kq-menu-wrap", {
          'kq-box-shadow': __props.showShadow
        }]),
        mode: "horizontal",
        ellipsis: false,
        "unique-opened": true,
        ref_key: "boxRef",
        ref: boxRef
      }, {
        default: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.withCtx)(() => [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createVNode)(_component_kq_sub_menu, {
          class: "kq-tool-sub-menu",
          teleported: false,
          index: __props.scaleValue.value || (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.unref)(scaleItem).value
        }, {
          title: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.withCtx)(() => [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createVNode)(_component_kq_icon, null, {
            default: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.withCtx)(() => [((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.openBlock)(), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createBlock)((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.resolveDynamicComponent)(__props.scaleValue.icon || (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.unref)(scaleItem).icon)))]),
            _: 1
            /* STABLE */

          }), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createTextVNode)(" " + (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.toDisplayString)(__props.scaleValue.value || (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.unref)(scaleItem).value), 1
          /* TEXT */
          )]),
          default: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.withCtx)(() => [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createElementVNode)("div", _hoisted_1, [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createVNode)(_component_kq_scrollbar, {
            ref_key: "kqScrollbarRef",
            ref: kqScrollbarRef,
            class: "kq2d-scale-location-scroll"
          }, {
            default: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.withCtx)(() => [((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.openBlock)(true), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createElementBlock)(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.Fragment, null, (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.renderList)((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.unref)(scaleItem).children, (childItem, idx) => {
              return (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.openBlock)(), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createBlock)(_component_kq_menu_item, {
                class: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.normalizeClass)(["kq-tool-menu-item", (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.unref)(scaleItem).value === childItem.name ? 'is-active' : 'no-active']),
                style: {
                  "height": "36px",
                  "line-height": "36px"
                },
                index: childItem.id,
                key: idx,
                onClick: value => {
                  onSelectScale(value, childItem, (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.unref)(scaleItem));
                }
              }, {
                default: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.withCtx)(() => [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.createTextVNode)((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.toDisplayString)(childItem.name), 1
                /* TEXT */
                )]),
                _: 2
                /* DYNAMIC */

              }, 1032
              /* PROPS, DYNAMIC_SLOTS */
              , ["index", "class", "onClick"]);
            }), 128
            /* KEYED_FRAGMENT */
            ))]),
            _: 1
            /* STABLE */

          }, 512
          /* NEED_PATCH */
          )])]),
          _: 1
          /* STABLE */

        }, 8
        /* PROPS */
        , ["index"])]),
        _: 1
        /* STABLE */

      }, 8
      /* PROPS */
      , ["class"]);
    };
  }

}));
;// CONCATENATED MODULE: ./src/leaflet/scalelocation/ScaleLocation.vue?vue&type=script&setup=true&lang=js
 
;// CONCATENATED MODULE: ./src/leaflet/scalelocation/ScaleLocation.vue



const __exports__ = ScaleLocationvue_type_script_setup_true_lang_js;

/* harmony default export */ var ScaleLocation = (__exports__);
// EXTERNAL MODULE: external "@kq_npm/client_common_vue/init.js"
var init_js_ = __webpack_require__(7997);
var init_js_default = /*#__PURE__*/__webpack_require__.n(init_js_);
;// CONCATENATED MODULE: ./src/leaflet/scalelocation/index.js
/*
 * Copyright (C) 2019 KQ GEO Technologies Co., Ltd.
 * All rights reserved.
 */




ScaleLocation.install = (Vue, opts) => {
  init_js_default()(Vue, opts);
  Vue.component(ScaleLocation.name, ScaleLocation);
};


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