@@ -26528,23 +26528,27 @@ var Tianditu = function (_ol$source$WMTS) {
2652826528 var attributions = options.attributions || new _olDebug2.default.Attribution({
2652926529 html: "Map Data <a href='http://www.tianditu.com' target='_blank'><img style='background-color:transparent;bottom:2px;opacity:1;' " + "src='http://api.tianditu.com/img/map/logo.png' width='53px' height='22px' opacity='0'></a> with " + "<span>© <a href='http://iclient.supermapol.com' target='_blank'>SuperMap iClient</a></span>"
2653026530 });
26531-
26531+ options.layerType = options.layerType || "vec";
26532+ options.layerType = options.isLabel ? _olDebug2.default.source.Tianditu.layerLabelMap[options.layerType] : options.layerType;
26533+ options.matrixSet = options.projection === 'EPSG:4326' || options.projection === 'EPSG:4490' ? "c" : "w";
2653226534 if (!options.url && !options.urls) {
26533- options.url = "http://t{0-7}.tianditu.com/img_w /wmts";
26535+ options.url = "http://t{0-7}.tianditu.com/{layer}_{proj} /wmts? ";
2653426536 }
26537+ options.url = options.url.replace("{layer}", options.layerType).replace("{proj}", options.matrixSet);
26538+ var tileGrid = options.tileGrid || _olDebug2.default.source.Tianditu.getTileGrid(options.projection || 'EPSG:3857');
2653526539 return _possibleConstructorReturn(this, (Tianditu.__proto__ || Object.getPrototypeOf(Tianditu)).call(this, {
2653626540 version: options.version || '1.0.0',
2653726541 format: options.format || 'tiles',
2653826542 dimensions: options.dimensions || {},
26539- layer: options.layer || 'img' ,
26540- matrixSet: options.matrixSet || 'w' ,
26541- tileGrid: options. tileGrid || _olDebug2.default.source.Tianditu.getTileGrid(options.projection || 'EPSG:3857') ,
26543+ layer: options.layerType ,
26544+ matrixSet: options.matrixSet,
26545+ tileGrid: tileGrid,
2654226546 style: options.style || 'default',
2654326547 attributions: attributions,
2654426548 cacheSize: options.cacheSize,
2654526549 crossOrigin: options.crossOrigin,
2654626550 opaque: options.opaque || true,
26547- maxZoom: options.maxZoom || 19 ,
26551+ maxZoom: _olDebug2.default.source.Tianditu.layerZoomMap[ options.layerType] ,
2654826552 reprojectionErrorThreshold: options.reprojectionErrorThreshold,
2654926553 tileLoadFunction: options.tileLoadFunction,
2655026554 url: options.url,
@@ -26570,21 +26574,21 @@ var Tianditu = function (_ol$source$WMTS) {
2657026574 }
2657126575 return _olDebug2.default.source.Tianditu.default3857TileGrid();
2657226576 }
26577+ }, {
26578+ key: "default4326TileGrid",
26579+
2657326580
2657426581 /**
2657526582 * @function ol.source.Tianditu.default4326TileGrid
2657626583 * @description 获取默认4326网格瓦片
2657726584 * @return {ol.tilegrid.WMTS} 返回默认4326网格瓦片对象
2657826585 */
26579-
26580- }, {
26581- key: "default4326TileGrid",
2658226586 value: function default4326TileGrid() {
2658326587 var tdt_WGS84_resolutions = [];
2658426588 var matrixIds = [];
26585- for (var i = 0 ; i < 18 ; i++) {
26586- tdt_WGS84_resolutions.push(0.703125 / Math.pow(2, i));
26587- matrixIds.push(i + 1 );
26589+ for (var i = 1 ; i < 19 ; i++) {
26590+ tdt_WGS84_resolutions.push(0.703125 * 2 / Math.pow(2, i));
26591+ matrixIds.push(i);
2658826592 }
2658926593 var tileGird = new _olDebug2.default.tilegrid.WMTS({
2659026594 extent: [-180, -90, 180, 90],
@@ -26607,9 +26611,9 @@ var Tianditu = function (_ol$source$WMTS) {
2660726611 value: function default3857TileGrid() {
2660826612 var tdt_Mercator_resolutions = [];
2660926613 var matrixIds = [];
26610- for (var i = 0 ; i < 18 ; i++) {
26611- tdt_Mercator_resolutions.push(78271.5169640203125 / Math.pow(2, i));
26612- matrixIds.push(i + 1 );
26614+ for (var i = 1 ; i < 19 ; i++) {
26615+ tdt_Mercator_resolutions.push(78271.5169640203125 * 2 / Math.pow(2, i));
26616+ matrixIds.push(i);
2661326617 }
2661426618 var tileGird = new _olDebug2.default.tilegrid.WMTS({
2661526619 extent: [-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892],
@@ -26625,6 +26629,15 @@ var Tianditu = function (_ol$source$WMTS) {
2662526629 return Tianditu;
2662626630}(_olDebug2.default.source.WMTS);
2662726631
26632+ Tianditu.layerLabelMap = {
26633+ "vec": "cva",
26634+ "ter": "cta",
26635+ "img": "cia"
26636+ };
26637+ Tianditu.layerZoomMap = {
26638+ "vec": 18,
26639+ "ter": 14,
26640+ "img": 18 };
2662826641exports.default = Tianditu;
2662926642
2663026643_olDebug2.default.source.Tianditu = Tianditu;
@@ -27487,26 +27500,12 @@ var WebMap = function (_ol$Observable) {
2748727500 }, {
2748827501 key: 'createTiandituLayer',
2748927502 value: function createTiandituLayer(layerInfo, epsgCode) {
27490- var proj = epsgCode === 4326 ? "c" : "w";
27491- var tdtURL = "http://t{0-7}.tianditu.com/{type}_{proj}/wmts?";
2749227503 var type = layerInfo.type.split('_')[1].toLowerCase();
27493- if (layerInfo.layerType === 'OVERLAY_LAYER') {
27494- if (type == "vec") {
27495- type = "cva";
27496- }
27497- if (type == "img") {
27498- type = "cia";
27499- }
27500- if (type == "ter") {
27501- type = "cta";
27502- }
27503- }
27504- tdtURL = tdtURL.replace("{type}", type).replace("{proj}", proj);
27504+ var isLabel = layerInfo.layerType === 'OVERLAY_LAYER';
2750527505 var layer = new _olDebug2.default.layer.Tile({
2750627506 source: new _olDebug2.default.source.Tianditu({
27507- url: tdtURL,
27508- matrixSet: proj,
27509- layer: type,
27507+ layerType: type,
27508+ isLabel: isLabel,
2751027509 projection: "EPSG:" + epsgCode
2751127510 })
2751227511 });
0 commit comments