"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.OPTIONS = void 0;
exports["default"] = _default;
var _react = _interopRequireWildcard(require("react"));
var _antd = require("antd");
var _ItemWrap = _interopRequireDefault(require("../components/ItemWrap"));
var _classnames = _interopRequireDefault(require("classnames"));
var _Icon = _interopRequireDefault(require("../components/Icon"));
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 _useProps2 = _interopRequireDefault(require("../../use-props"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var IMG = {
  "vec": _baseImg2["default"],
  "img": _baseImg["default"],
  "TdtImageryProvider-vec": _baseImg2["default"],
  "TdtImageryProvider-img": _baseImg["default"],
  "AmapImageryProvider-ELEC": _baseImg2["default"],
  "BaiduImageryProvider-CUSTOM": _baseImg2["default"],
  "GeoQImageryProvider-Blue": _baseImg6["default"],
  "GeoQImageryProvider-Community": _baseImg3["default"],
  "GeoQImageryProvider-Warm": _baseImg4["default"],
  "GeoQImageryProvider-Gray": _baseImg5["default"]
};
var getImage = function getImage(type) {
  return IMG[type] || _baseImg2["default"];
};
var OPTIONS = [{
  label: '天地图',
  value: 'TdtImageryProvider',
  children: [{
    label: '矢量图',
    value: 'vec'
  }, {
    label: '影像图',
    value: 'img'
  }]
}, {
  label: '高德地图',
  value: 'AmapImageryProvider',
  children: [{
    label: '矢量图',
    value: 'ELEC'
  }]
}, {
  label: '百度地图',
  value: 'BaiduImageryProvider',
  children: [{
    label: '矢量图',
    value: 'CUSTOM'
  }]
}, {
  label: '其他',
  value: 'GeoQImageryProvider',
  children: [{
    label: '蓝黑版',
    value: 'Blue'
  }, {
    label: '彩色版',
    value: 'Community'
  }, {
    label: '暖色版',
    value: 'Warm'
  }, {
    label: '灰色版',
    value: 'Gray'
  }]
}];
exports.OPTIONS = OPTIONS;
function _default(props) {
  var options = props.options;
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map;
  var _useState = (0, _react.useState)(null),
    _useState2 = _slicedToArray(_useState, 2),
    value = _useState2[0],
    setValue = _useState2[1];

  // 切换
  var onChange = function onChange(item, val) {
    setValue(_objectSpread(_objectSpread({}, val), {}, {
      value: "".concat(item.value, "_").concat(val.value)
    }));
    map.changeBaseLayer({
      imageryProvider: item.value,
      style: val.value
    });
  };
  var _options = options || OPTIONS;
  var content = function content() {
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])('base-map-switch-list-wrap')
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])('base-map-switch-list-title')
    }, "\u5E95\u56FE\u9009\u62E9"), /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])('base-map-switch-list')
    }, _options.map(function (item) {
      return /*#__PURE__*/_react["default"].createElement(_antd.Row, {
        key: item.label
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: (0, _classnames["default"])('base-map-switch-list-label')
      }, item.label), /*#__PURE__*/_react["default"].createElement("div", {
        className: (0, _classnames["default"])('base-map-switch-list-item-wrap')
      }, /*#__PURE__*/_react["default"].createElement(_antd.Row, {
        gutter: [12, 12]
      }, item.children.map(function (v) {
        return /*#__PURE__*/_react["default"].createElement(_antd.Col, {
          span: 12,
          key: "".concat(item.label, "-").concat(v.label)
        }, /*#__PURE__*/_react["default"].createElement("div", {
          onClick: function onClick() {
            return onChange(item, v);
          },
          className: (0, _classnames["default"])('base-map-switch-list-item', {
            'base-map-switch-list-item-active': (value === null || value === void 0 ? void 0 : value.value) === "".concat(item.value, "_").concat(v.value)
          })
        }, /*#__PURE__*/_react["default"].createElement("img", {
          className: (0, _classnames["default"])('base-map-switch-list-item-img'),
          src: v.image || getImage(v.imageType || "".concat(item.value, "-").concat(v.value)),
          alt: ""
        }), /*#__PURE__*/_react["default"].createElement("div", {
          className: (0, _classnames["default"])('base-map-switch-list-item-label')
        }, v.label)));
      }))));
    })));
  };
  return /*#__PURE__*/_react["default"].createElement(_ItemWrap["default"], {
    content: /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
      type: "icon-ditu"
    })
  }, content());
}
//# sourceMappingURL=index.js.map
