"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getSource = exports["default"] = void 0;
var _layer = require("ol/layer");
var _source = require("ol/source");
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _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(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var getSource = exports.getSource = function getSource(_ref) {
  var mapStyle = _ref.mapStyle,
    tk = _ref.tk;
  var P = {
    vec: {
      img: 'vec_w',
      label: 'cva_w'
    },
    img: {
      img: 'img_w',
      label: 'cia_w'
    }
  };
  var tileLayer = new _source.XYZ({
    url: "//t{0-7}.tianditu.gov.cn/DataServer?T=".concat(P[mapStyle].img, "&tk=").concat(tk, "&x={x}&y={y}&l={z}"),
    maxZoom: 18,
    crossOrigin: 'anonymous'
  });
  var markLayer = new _source.XYZ({
    url: "//t{0-7}.tianditu.gov.cn/DataServer?T=".concat(P[mapStyle].label, "&tk=").concat(tk, "&x={x}&y={y}&l={z}"),
    maxZoom: 18,
    crossOrigin: 'anonymous'
  });
  return [tileLayer, markLayer];
};
var getLayer = function getLayer(_ref2) {
  var mapStyle = _ref2.mapStyle,
    tk = _ref2.tk,
    dark = _ref2.dark;
  mapStyle = mapStyle || 'vec';
  var _getSource = getSource({
      mapStyle: mapStyle,
      tk: tk
    }),
    _getSource2 = _slicedToArray(_getSource, 2),
    tileLayerSource = _getSource2[0],
    markLayerSource = _getSource2[1];
  var tileLayer = new _layer.Tile({
    preload: Infinity,
    // 预加载
    title: '天地图路网',
    name: 'baseMap',
    className: dark && 'ol-map-dark',
    source: tileLayerSource,
    zIndex: 0
  });
  tileLayer.key = '__TDT_TILE';
  var markLayer = new _layer.Tile({
    preload: Infinity,
    // 预加载
    title: '天地图文字标注',
    name: 'baseMap',
    className: dark && 'ol-map-dark-label',
    source: markLayerSource,
    zIndex: 0
  });
  markLayer.key = '__TDT_MARK';
  return [tileLayer, markLayer];
};
var _default = exports["default"] = {
  // mercator: bd09Mercator,
  // transform,
  getLayer: getLayer,
  getSource: getSource
};
//# sourceMappingURL=TdtImageryProvider.js.map
