/******/ (function() { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 403:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": function() { return /* binding */ Mitt; }
/* harmony export */ });
/* harmony import */ var _Users_zpc_Documents_KQGEOSpace_KQGISClientForVue_node_modules_babel_runtime_helpers_esm_defineProperty_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8270);
/* harmony import */ var _common_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2107);
/* harmony import */ var _common_utils_util__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_common_utils_util__WEBPACK_IMPORTED_MODULE_0__);


/**
 * 向外暴露的默认函数
 * @param 入参为 EventHandlerMap
 * @returns 返回一个对象，对象包含属性 all，方法 on，off，emit
 */

class Mitt {
  /*
      此处实参可传一个EventHandlerMap对象，实现多个 mitt 的合并。例如：
      const m1 = mitt();
      m1.on('hi', () => { console.log('Hi, I am belongs to m1.'); });
      const m2 = mitt(m1.all);
      m2.emit('hi') // Hi, I am belongs to m1.
      m2.on('hello', () => { console.log('Hello, I am belongs to m2.'); });
      m1.emit('hello'); // Hello, I am belongs to m2.
      m1.all === m2.all // true
    */
  constructor(all) {
    (0,_Users_zpc_Documents_KQGEOSpace_KQGISClientForVue_node_modules_babel_runtime_helpers_esm_defineProperty_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)(this, "all", null);

    this.all = all || new Map();
  }
  /**
   * 注册一个命名的事件处理
   * @param type 事件名，官方表示事件名如是 *，用来标记为通用事件，调用任何事件，都会触发命名为 * 的事件
   * @param handler 事件处理函数
   */


  on(type, handler) {
    // 根据type去查找事件
    const handlers = this.all.get(type);

    if (handlers) {
      for (let i = 0; i < handlers.length; i++) {
        // 防止重复监听 事件执行的方法相同时 不添加
        if (handlers[i] === handler) {
          return;
        }
      }

      handlers.push(handler);
    } else {
      this.all.set(type, [handler]);
    }
  }
  /**
   * 只执行一次 就会被移除
   * @param type
   * @param fn
   */


  once(type, fn) {
    const handler = (0,_common_utils_util__WEBPACK_IMPORTED_MODULE_0__.bind)(function () {
      this.off(type, fn);
      this.off(type, handler);
    }, this); // 添加执行事件和移除执行事件的监听

    this.on(type, fn);
    this.on(type, handler);
  }
  /**
   * 移除指定的事件处理
   * @param type 事件名，和第二个参数一起用来移除指定的事件，
   * @param handler 事件处理函数
   */


  off(type, handler) {
    if (!type) {
      this.all.clear();
      return;
    } // 根据type去查找事件


    const handlers = this.all.get(type); // 如果找到则进行删除操作

    if (handlers) {
      // 这里用了个骚操作，其实就是找到了，则删除(多个相同的只会删除找到的第一个)，没找到则不会对原数组有任何影响
      handlers.splice(handlers.indexOf(handler) >>> 0, 1);
    }
  }
  /**
   * 触发所有 type 事件，如果有type为 * 的事件，则最后会执行。
   * @param type 事件名
   * @param evt 传递给处理函数的参数
   */


  fire(type, evt) {
    // 找到type的事件循环执行
    (this.all.get(type) || []).slice().map(handler => {
      handler(evt);
    }); // 然后找到所有为*的事件，循环执行

    (this.all.get("*") || []).slice().map(handler => {
      handler(type, evt);
    });
  }

}

/***/ }),

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

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

/***/ }),

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

module.exports = require("@zpc_npm/vue-iclient-leaflet/_utils/gis-utils");

/***/ }),

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

module.exports = require("@zpc_npm/vue-iclient-leaflet/_utils/util");

/***/ }),

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

module.exports = require("@zpc_npm/vue-iclient-leaflet/init.js");

/***/ }),

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

module.exports = require("vue");

/***/ }),

/***/ 8270:
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": function() { return /* binding */ _defineProperty; }
/* harmony export */ });
function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// 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__(637);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
var defineProperty = __webpack_require__(8270);
// EXTERNAL MODULE: ./src/common/_utils/mitt.js
var mitt = __webpack_require__(403);
// EXTERNAL MODULE: external "@zpc_npm/vue-iclient-leaflet/_utils/gis-utils"
var gis_utils_ = __webpack_require__(257);
;// CONCATENATED MODULE: ./src/leaflet/scalelocation/ScaleLocationViewModel.js



class ScaleLocationViewModel extends mitt/* default */.Z {
  constructor(mapTarget) {
    super();

    (0,defineProperty/* default */.Z)(this, "_props", null);

    this._props = {
      mapTarget
    }; // 事件绑定this

    this._getScalesAsync = this._getScalesAsync.bind(this);
    this._getScalesSync = this._getScalesSync.bind(this);

    this._registerEvents();
  }
  /**
   * 注册事件
   */


  _registerEvents() {
    // 监听地图初始化完成事件
    // 异步
    gis_utils_.mapViewUtils.bindViewEvents("mounted", this._getScalesAsync, this._props.mapTarget); // 同步

    gis_utils_.utils.getWebMap(this._props.mapTarget, this._getScalesSync);
  }
  /**
   * 获取scales
   */


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

    let scale = e.target.getScale();
    let webMap = e.target;
    this.fire("getScales", {
      scale,
      webMap
    });
  }

  _getScalesSync(e) {
    let scale = e.getScale();
    let webMap = e;
    this.fire("getScales", {
      scale,
      webMap
    });
  }

}
// EXTERNAL MODULE: external "@zpc_npm/vue-iclient-leaflet/_utils/util"
var util_ = __webpack_require__(2107);
// 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]!./src/leaflet/scalelocation/ScaleLocation.vue?vue&type=script&setup=true&lang=js

const _hoisted_1 = {
  style: {
    "height": "400px",
    "width": "150px",
    "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]
  },

  setup(__props) {
    const props = __props;
    let scaleItem = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.reactive)({
      map: null,
      value: "",
      type: "scale",
      icon: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.markRaw)(icons_vue_.ScaleToOriginal),
      children: []
    });
    let box_ref = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.ref)();
    let viewModel = null;
    (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_.onMounted)(() => {
      (0,util_.updatePosition)(box_ref.value.$el, props);
      viewModel = new ScaleLocationViewModel(props.mapTarget);
      viewModel.on("getScales", _data => {
        setScale(_data.scale, _data.webMap.map.getZoom(), _data.webMap.map);
      });
    });

    function setScale(s, level, map) {
      for (let i = 0; i < s.length; i++) {
        if (i === level) {
          scaleItem.value = "1:" + Math.round(s[i]);
          map.setZoom(level);
        }

        scaleItem.map = map;
        scaleItem.children.push({
          id: "1_" + i,
          name: "1:" + Math.round(s[i])
        });
        map.on("zoomend", function (e) {
          if (i === e.target.getZoom()) {
            scaleItem.value = "1:" + Math.round(s[i]);
          }
        });
      }
    }

    const selectScale = (value, item, parent) => {
      let z = Number(value.index.split("_")[1]);
      parent.map.setZoom(z);
      parent.value = item.name;
    };

    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)(["kq-2d-scale-location kq-menu-wrap", __props.showShadow ? 'shadow' : null]),
        mode: "horizontal",
        ellipsis: false,
        "unique-opened": true,
        ref_key: "box_ref",
        ref: box_ref
      }, {
        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, {
          "popper-append-to-body": 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, null, {
            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, {
                style: {
                  "height": "36px",
                  "line-height": "36px"
                },
                index: childItem.id,
                key: idx,
                onClick: value => {
                  selectScale(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", "onClick"]);
            }), 128
            /* KEYED_FRAGMENT */
            ))]),
            _: 1
            /* STABLE */

          })])]),
          _: 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 "@zpc_npm/vue-iclient-leaflet/init.js"
var init_js_ = __webpack_require__(1396);
var init_js_default = /*#__PURE__*/__webpack_require__.n(init_js_);
;// CONCATENATED MODULE: ./src/leaflet/scalelocation/index.js




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


}();
module.exports = __webpack_exports__;
/******/ })()
;