"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.OPTIONS = exports.Imagery = exports.BaseMap = void 0;
var _GeoQImageryProvider = _interopRequireDefault(require("./imagery/geoq/GeoQImageryProvider"));
var _BaiduImageryProvider = _interopRequireDefault(require("./imagery/baidu/BaiduImageryProvider"));
var _AmapImageryProvider = _interopRequireDefault(require("./imagery/amap/AmapImageryProvider"));
var _TencentImageryProvider = _interopRequireDefault(require("./imagery/tencent/TencentImageryProvider"));
var _TdtImageryProvider = _interopRequireWildcard(require("./imagery/tdt/TdtImageryProvider"));
var _JiangSuTdtImageryProvider = _interopRequireDefault(require("./imagery/tdt/JiangSuTdtImageryProvider"));
var _GoogleImageryProvider = _interopRequireDefault(require("./imagery/google/GoogleImageryProvider"));
var _IRSImageryProvider = _interopRequireWildcard(require("./imagery/irs/IRSImageryProvider"));
var _baseImg = _interopRequireDefault(require("../../assets/base-img.png"));
var _baseImg2 = _interopRequireDefault(require("../../assets/base-img-1.png"));
var _baseImg3 = _interopRequireDefault(require("../../assets/base-img-2.png"));
var _baseImg4 = _interopRequireDefault(require("../../assets/base-img-3.png"));
var _baseImg5 = _interopRequireDefault(require("../../assets/base-img-4.png"));
var _baseImg6 = _interopRequireDefault(require("../../assets/base-img-5.png"));
var _baseImg7 = _interopRequireDefault(require("../../assets/base-img-6.png"));
var _EventEmitter2 = _interopRequireDefault(require("../../_util/EventEmitter"));
var _excluded = ["imageryProvider", "style"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var Imagery = exports.Imagery = {
  GeoQImageryProvider: _GeoQImageryProvider["default"],
  AmapImageryProvider: _AmapImageryProvider["default"],
  BaiduImageryProvider: _BaiduImageryProvider["default"],
  TencentImageryProvider: _TencentImageryProvider["default"],
  TdtImageryProvider: _TdtImageryProvider["default"],
  GoogleImageryProvider: _GoogleImageryProvider["default"],
  IRSImageryProvider: _IRSImageryProvider["default"],
  JiangSuTdtImageryProvider: _JiangSuTdtImageryProvider["default"]
};
var OPTIONS = exports.OPTIONS = [{
  label: '地图风格',
  value: 'GeoQImageryProvider',
  children: [{
    label: '蓝黑版',
    value: 'Blue',
    img: _baseImg6["default"]
  }, {
    label: '彩色版',
    value: 'Community',
    img: _baseImg3["default"]
  }, {
    label: '暖色版',
    value: 'StreetWarm',
    img: _baseImg4["default"]
  }, {
    label: '灰色版',
    value: 'ChinaOnlineStreetGray',
    img: _baseImg5["default"]
  }]
}, {
  label: '天地图',
  value: 'TdtImageryProvider',
  children: [{
    label: '影像图',
    value: 'img',
    img: _baseImg["default"]
  }, {
    label: '矢量图',
    value: 'vec',
    img: _baseImg2["default"]
  }, {
    label: '矢量图(暗色)',
    value: 'dark',
    img: _baseImg7["default"],
    style: 'dark'
  }]
}, {
  label: '高德地图',
  value: 'AmapImageryProvider',
  children: [{
    label: '影像图',
    value: 'IMG',
    img: _baseImg["default"]
  }, {
    label: '矢量图',
    value: 'ELEC',
    img: _baseImg2["default"]
  }, {
    label: '矢量图(暗色)',
    value: 'dark',
    img: _baseImg7["default"]
  }]
}, {
  label: '腾讯地图',
  value: 'TencentImageryProvider',
  children: [{
    label: '影像图',
    value: 'IMG',
    img: _baseImg["default"]
  }, {
    label: '矢量图',
    value: 'ELEC',
    img: _baseImg2["default"]
  }, {
    label: '矢量图(暗色)',
    value: 'dark',
    img: _baseImg7["default"]
  }]
}, {
  label: '百度地图',
  value: 'BaiduImageryProvider',
  children: [{
    label: '影像图',
    value: 'IMG',
    img: _baseImg["default"]
  }, {
    label: '矢量图',
    value: 'CUSTOM',
    img: _baseImg2["default"]
  }, {
    label: '矢量图(暗色)',
    value: 'dark',
    img: _baseImg7["default"]
  }]
}];
var BaseMap = exports.BaseMap = /*#__PURE__*/function (_EventEmitter) {
  function BaseMap(options) {
    var _this;
    _classCallCheck(this, BaseMap);
    _this = _callSuper(this, BaseMap);
    _this.map = options.map;
    _this.options = options.options || OPTIONS;
    _this.imageryProvider = options.imageryProvider || '';
    _this.style = options.style || '';
    _this.layer = options.layer || _this.addLayer();
    return _this;
  }
  _inherits(BaseMap, _EventEmitter);
  return _createClass(BaseMap, [{
    key: "setBaseMap",
    value: function setBaseMap(options) {
      this.removeLayer(); // 删除老的底图

      var imageryProvider = options.imageryProvider,
        style = options.style,
        otherVal = _objectWithoutProperties(options, _excluded);
      this.imageryProvider = imageryProvider;
      this.style = style;
      var ImageryProvider = Imagery[imageryProvider];
      var layer = new ImageryProvider(_objectSpread({
        style: style
      }, otherVal));
      this.map.imageryLayers.addImageryProvider(layer, 0);
      return layer;
    }
  }, {
    key: "getValue",
    value: function getValue() {
      var imageryProvider = this.imageryProvider;
      var style = this.style;
      var options = this.options;
      var value = {};
      options.map(function (v) {
        if (v.value === imageryProvider) {
          v.children.map(function (c) {
            if (c.value === style) {
              value = _objectSpread(_objectSpread({}, c), {}, {
                value: "".concat(v.value, "_").concat(c.value)
              });
            }
          });
        }
      });
      return value;
    }
  }, {
    key: "setValue",
    value: function setValue(imageryProvider, style) {
      this.removeLayer(); // 删除老的底图

      this.imageryProvider = imageryProvider;
      this.style = style;
      this.layer = this.addLayer();
    }
  }, {
    key: "addLayer",
    value: function addLayer() {
      var _this2 = this;
      var map = this.map;
      var imageryProvider = this.imageryProvider;
      var style = this.style;
      var options = this.options;
      var layer;
      if (imageryProvider) {
        if (options !== null && options !== void 0 && options.length) {
          options.map(function (v) {
            var children = v.children,
              value = v.value;
            if (value === imageryProvider && Imagery[value]) {
              var child = children.find(function (c) {
                return c.value === style;
              });
              var ImageryProvider = Imagery[value];
              layer = new ImageryProvider(_objectSpread({
                style: child.value,
                crs: 'WGS84',
                dark: map.dark
              }, child));
              _this2.layer = map.imageryLayers.addImageryProvider(layer, 0);

              // 调用影响中文注记服务
              if (imageryProvider === 'TdtImageryProvider') {
                var cia = new _TdtImageryProvider.TdtLabelImageryProvider(_objectSpread({}, child));
                map.imageryLayers.addImageryProvider(cia, 1); // 添加到cesium图层上
              } else if (imageryProvider === 'IRSImageryProvider') {
                var _cia = new _IRSImageryProvider.IRSLabelImageryProvider(_objectSpread({}, child));
                map.imageryLayers.addImageryProvider(_cia, 1); // 添加到cesium图层上
              }
            }
          });
        }
      }
      return layer;
    }
  }, {
    key: "removeLayer",
    value: function removeLayer() {
      var map = this.map;
      var layers = map.imageryLayers._layers;
      var removeLayers = [];
      layers.map(function (layer) {
        if (layer.imageryProvider) {
          if (layer.imageryProvider instanceof _GeoQImageryProvider["default"] || layer.imageryProvider instanceof _AmapImageryProvider["default"] || layer.imageryProvider instanceof _BaiduImageryProvider["default"] || layer.imageryProvider instanceof _TencentImageryProvider["default"] || layer.imageryProvider instanceof _TdtImageryProvider["default"] || layer.imageryProvider instanceof _JiangSuTdtImageryProvider["default"] || layer.imageryProvider instanceof _GoogleImageryProvider["default"] || layer.imageryProvider instanceof _TdtImageryProvider.TdtLabelImageryProvider || layer.imageryProvider instanceof _IRSImageryProvider.IRSLabelImageryProvider || layer.imageryProvider instanceof _IRSImageryProvider["default"]) {
            removeLayers.push(layer);
          }
        }
      });
      removeLayers.map(function (layer) {
        return map.imageryLayers.remove(layer);
      });
    }
  }]);
}(_EventEmitter2["default"]);
//# sourceMappingURL=index.js.map
