/******/ (function() { // webpackBootstrap
/******/ 	"use strict";
/******/ 	// The require scope
/******/ 	var __webpack_require__ = {};
/******/ 	
/************************************************************************/
/******/ 	/* 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__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "ScaleLocationViewModel": function() { return /* reexport */ ScaleLocationViewModel; },
  "default": function() { return /* reexport */ ScaleLocation; }
});

;// CONCATENATED MODULE: external {"root":"Vue","commonjs":"vue","commonjs2":"vue","amd":"vue"}
var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject = require("vue");
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
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;
}
;// CONCATENATED MODULE: external "@zpc_npm/vue-iclient-common/_utils/mitt"
var mitt_namespaceObject = require("@zpc_npm/vue-iclient-common/_utils/mitt");
var mitt_default = /*#__PURE__*/__webpack_require__.n(mitt_namespaceObject);
;// CONCATENATED MODULE: external "@zpc_npm/vue-iclient-common/_utils/gis-utils"
var gis_utils_namespaceObject = require("@zpc_npm/vue-iclient-common/_utils/gis-utils");
;// CONCATENATED MODULE: ./src/leaflet/scalelocation/ScaleLocationViewModel.js


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


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

class ScaleLocationViewModel extends (mitt_default()) {
  constructor(mapTarget) {
    super();

    _defineProperty(this, "_props", null);

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

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

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


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

    gis_utils_namespaceObject.utils.getWebMap(this._props.mapTarget, this._getScalesSync);
  }
  /**
   * @description 异步获取scales
   * @private
   */


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

    let scale = e.target.getScale();
    let webMap = e.target;
    this.fire("getScales", {
      scale,
      webMap
    });
  }
  /**
   * @description 同步获取scales
   * @private
   */


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

}
;// CONCATENATED MODULE: external "@zpc_npm/vue-iclient-common/_utils/util"
var util_namespaceObject = require("@zpc_npm/vue-iclient-common/_utils/util");
;// CONCATENATED MODULE: external "@element-plus/icons-vue"
var icons_vue_namespaceObject = require("@element-plus/icons-vue");
;// 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_namespaceObject.markRaw)(icons_vue_namespaceObject.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_namespaceObject.reactive)({
      map: null,
      // 地图实例
      value: "",
      // 比例尺值
      type: "scale",
      // toolbar类型
      icon: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.markRaw)(icons_vue_namespaceObject.ScaleToOriginal),
      // toolbar icon
      children: [] // 子项

    }); // 组件容器

    let box_ref = (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.ref)(); // 逻辑类

    let viewModel = null;
    (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.onMounted)(() => {
      (0,util_namespaceObject.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_namespaceObject.resolveComponent)("kq-icon");

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

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

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

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

      return (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.openBlock)(), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.createBlock)(_component_kq_menu, {
        class: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.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_namespaceObject.withCtx)(() => [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.createVNode)(_component_kq_sub_menu, {
          "popper-append-to-body": false,
          index: __props.scaleValue.value || (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.unref)(scaleItem).value
        }, {
          title: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.withCtx)(() => [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.createVNode)(_component_kq_icon, null, {
            default: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.withCtx)(() => [((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.openBlock)(), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.createBlock)((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.resolveDynamicComponent)(__props.scaleValue.icon || (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.unref)(scaleItem).icon)))]),
            _: 1
            /* STABLE */

          }), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.createTextVNode)(" " + (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.toDisplayString)(__props.scaleValue.value || (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.unref)(scaleItem).value), 1
          /* TEXT */
          )]),
          default: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.withCtx)(() => [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.createElementVNode)("div", _hoisted_1, [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.createVNode)(_component_kq_scrollbar, null, {
            default: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.withCtx)(() => [((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.openBlock)(true), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.createElementBlock)(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.Fragment, null, (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.renderList)((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.unref)(scaleItem).children, (childItem, idx) => {
              return (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.openBlock)(), (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.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_namespaceObject.unref)(scaleItem));
                }
              }, {
                default: (0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.withCtx)(() => [(0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.createTextVNode)((0,external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_namespaceObject.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__);
;// CONCATENATED MODULE: external "@zpc_npm/vue-iclient-common/init.js"
var init_js_namespaceObject = require("@zpc_npm/vue-iclient-common/init.js");
var init_js_default = /*#__PURE__*/__webpack_require__.n(init_js_namespaceObject);
;// 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__;
/******/ })()
;