UNPKG

@vtx/cs-map

Version:

React components for Vortex

96 lines (93 loc) 9.01 kB
"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["default"] = exports.TdtLabelImageryProvider = void 0; var _cesium = require("cesium"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 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 _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); } function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var MAP_URL = 'https://{s}.tianditu.gov.cn/DataServer?T={style}_w&x={x}&y={y}&l={z}&tk={key}'; var MAP_LABEL_URL = 'https://{s}.tianditu.gov.cn/DataServer?T={style}&x={x}&y={y}&l={z}&tk={key}'; var TdtLabelImageryProvider = exports.TdtLabelImageryProvider = /*#__PURE__*/function (_UrlTemplateImageryPr) { _inherits(TdtLabelImageryProvider, _UrlTemplateImageryPr); var _super = _createSuper(TdtLabelImageryProvider); function TdtLabelImageryProvider() { var _this; var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, TdtLabelImageryProvider); var style = options.style, value = options.value, key = options.key, replaceLabel = options.replaceLabel; var _style = value === 'img' ? 'cia_w' : 'cva_w'; _this = _super.call(this, { // 调用影响中文注记服务 url: MAP_LABEL_URL.replace(/\{style\}/g, _style).replace(/\{key\}/g, key || '13b4890427f17c692f9efed46b98db81'), subdomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'], tilingScheme: new _cesium.WebMercatorTilingScheme(), maximumLevel: 18 }); if (style === 'dark') { var _options$alpha, _options$contrast, _options$brightness, _options$hue, _options$saturation; _this.defaultAlpha = (_options$alpha = options.alpha) !== null && _options$alpha !== void 0 ? _options$alpha : 1.0; // 透明度 _this.defaultContrast = (_options$contrast = options.contrast) !== null && _options$contrast !== void 0 ? _options$contrast : -1.0; // 对比度 _this.defaultBrightness = (_options$brightness = options.brightness) !== null && _options$brightness !== void 0 ? _options$brightness : 0.9; // 亮度 _this.defaultHue = (_options$hue = options.hue) !== null && _options$hue !== void 0 ? _options$hue : 3.6; // 色调 _this.defaultSaturation = (_options$saturation = options.saturation) !== null && _options$saturation !== void 0 ? _options$saturation : -0.8; // 饱和度 } _this.replaceLabel = replaceLabel; return _this; } _createClass(TdtLabelImageryProvider, [{ key: "requestImage", value: function requestImage(x, y, level, request) { if (this.replaceLabel && this.replaceLabel["/".concat(level, "/").concat(x, "/").concat(y)]) { return _cesium.ImageryProvider.loadImage(this, this.replaceLabel["/".concat(level, "/").concat(x, "/").concat(y)]); } return _get(_getPrototypeOf(TdtLabelImageryProvider.prototype), "requestImage", this).call(this, x, y, level, request); } }]); return TdtLabelImageryProvider; }(_cesium.UrlTemplateImageryProvider); var TdtImageryProvider = /*#__PURE__*/function (_UrlTemplateImageryPr2) { _inherits(TdtImageryProvider, _UrlTemplateImageryPr2); var _super2 = _createSuper(TdtImageryProvider); function TdtImageryProvider() { var _this2; var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, TdtImageryProvider); var style = options.style; var _style = style === undefined || style === 'vec' || style === 'dark' ? 'vec' : style; _this2 = _super2.call(this, { url: MAP_URL.replace(/\{style\}/g, _style).replace(/\{key\}/g, options.key || '13b4890427f17c692f9efed46b98db81'), subdomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'], tilingScheme: new _cesium.WebMercatorTilingScheme(), maximumLevel: 18 }); if (style === 'dark') { var _options$alpha2, _options$contrast2, _options$brightness2, _options$hue2, _options$saturation2; _this2.defaultAlpha = (_options$alpha2 = options.alpha) !== null && _options$alpha2 !== void 0 ? _options$alpha2 : 1.0; // 透明度 _this2.defaultContrast = (_options$contrast2 = options.contrast) !== null && _options$contrast2 !== void 0 ? _options$contrast2 : -1.0; // 对比度 _this2.defaultBrightness = (_options$brightness2 = options.brightness) !== null && _options$brightness2 !== void 0 ? _options$brightness2 : 0.9; // 亮度 _this2.defaultHue = (_options$hue2 = options.hue) !== null && _options$hue2 !== void 0 ? _options$hue2 : 3.6; // 色调 _this2.defaultSaturation = (_options$saturation2 = options.saturation) !== null && _options$saturation2 !== void 0 ? _options$saturation2 : -0.8; // 饱和度 } return _this2; } return _createClass(TdtImageryProvider); }(_cesium.UrlTemplateImageryProvider); var _default = exports["default"] = TdtImageryProvider; //# sourceMappingURL=TdtImageryProvider.js.map