Skip to content

Commit e4313b1

Browse files
committed
更新ol 天地图比例尺信息 修改过时api
1 parent fdc15c6 commit e4313b1

File tree

9 files changed

+94
-109
lines changed

9 files changed

+94
-109
lines changed

dist/iclient9-openlayers.js

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -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 };
2662826641
exports.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
});

dist/iclient9-openlayers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/openlayers/tiandituLayer_ll.html

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,26 @@
88
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%">
99
<div id="map" style="width: 100%;height:100%"></div>
1010
<script type="text/javascript">
11-
var resolutions = [];
12-
for (var i = 6; i < 10; i++) {
13-
resolutions.push(0.703125 / (Math.pow(2, i)));
14-
}
1511
var map = new ol.Map({
1612
target: 'map',
1713
controls: ol.control.defaults({attributionOptions: {collapsed: false}})
1814
.extend([new ol.supermap.control.Logo()]),
1915
view: new ol.View({
2016
center: [116.402, 39.905],
21-
zoom: 0,
22-
projection: "EPSG:4326",
23-
resolutions: resolutions
17+
zoom: 5,
18+
projection: "EPSG:4326"
2419
}),
2520

2621
layers: [new ol.layer.Tile({
2722
source: new ol.source.Tianditu({
28-
url: "http://t0.tianditu.com/vec_c/wmts",
29-
matrixSet: 'c',
30-
layer: 'vec',
23+
layerType: 'ter',
3124
projection: "EPSG:4326"
3225
})
3326
}), new ol.layer.Tile({
3427
source: new ol.source.Tianditu({
35-
url: " http://t0.tianditu.com/cva_c/wmts",
36-
matrixSet: 'c',
37-
layer: 'cva',
38-
projection: "EPSG:4326",
39-
tileGrid: new ol.tilegrid.WMTS({
40-
extent: [-180, -90, 180, 90],
41-
resolutions: resolutions,
42-
origin: [-180, 90],
43-
matrixIds: [7, 8, 9, 10],
44-
})
28+
layerType: 'ter',
29+
isLabel: true,
30+
projection: "EPSG:4326"
4531
})
4632
})]
4733
});

examples/openlayers/tiandituLayer_mecartor.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,21 @@
1010
<script type="text/javascript">
1111
var resolutions = [];
1212
for (var i = 0; i < 18; i++) {
13-
resolutions.push(78271.5169640203125 / (Math.pow(2, i)));
13+
resolutions.push(78271.5169640203125*2 / (Math.pow(2, i)));
1414
}
15-
new ol.Map({
15+
new ol.Map({
1616
target: 'map',
1717
controls: ol.control.defaults({attributionOptions: {collapsed: false}})
1818
.extend([new ol.supermap.control.Logo()]),
1919
view: new ol.View({
2020
center: [0, 0],
21-
zoom: 0,
22-
resolutions: resolutions
21+
zoom: 1
2322
}),
2423
layers: [new ol.layer.Tile({
2524
source: new ol.source.Tianditu()
2625
}), new ol.layer.Tile({
2726
source: new ol.source.Tianditu({
28-
url: "http://t0.tianditu.com/cia_w/wmts",
29-
matrixSet: 'w',
30-
layer: 'cia'
27+
isLabel: true
3128
})
3229
})]
3330
});

src/leaflet/core/Proj4Leaflet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ L.Proj.Projection = L.Class.extend({
9191
* bounds -{Array|L.Bounds} 范围
9292
* @example
9393
* 用法:
94-
* var crs =L.Proj.CRS("EPSG:4326", '', {
94+
* var crs =L.Proj.CRS("EPSG:4326",{
9595
* origin: [-180,90],
9696
* scaleDenominators: [2000,1000,500,200,100,50,20,10],
9797
* });

src/leaflet/core/UnicodeMarker.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@ import '../core/Base';
22
import L from "leaflet";
33

44
/**
5-
* @class L.supermap.baiduTileLayer
6-
* @classdesc 百度地图图层。
7-
* @extends L.TileLayer{@linkdoc-leaflet/#tilelayer}
8-
* @param url -{string} 切片地址
9-
* @param options -{Object} 切片参数。如:<br>
10-
* minZoom - {number} 最小缩放级别 <br>
11-
* maxZoom - {number} 最大缩放级别 <br>
12-
* bounds - {[L.LatLngBounds]{@linkdoc-leaflet/#latlngbounds}} 显示范围 <br>
13-
* retina - {[L.Browser]{@linkdoc-leaflet/#browser}} 浏览器显示分辨率 <br>
14-
* attribution - {string} 版权信息 <br>
5+
* @class L.supermap.unicodeMarker
6+
* @classdesc Unicode字符图标。
7+
* @extends L.Path{@linkdoc-leaflet/#Path}
8+
* @param latlng -[L.LatLngBounds]{@linkdoc-leaflet/#latlng}} 经纬度坐标
9+
* @param options -{Object} 符号参数。<br>
10+
* label - {string} 符号Unicode值 <br>
11+
* labelRotation - {string} 符号旋转角度 <br>
12+
* globalAlpha - {string} 符号的透明值 <br>
13+
* fontStyle - {string} 符号的风格 <br>
14+
* fontWeight - {string} 符号的粗细 <br>
15+
* fontSize - {string} 符号的尺寸 <br>
16+
* fontFamily - {string} 符号的字体 <br>
17+
* textAlign - {string} 符号内容的对齐方式 <br>
18+
* textBaseline - {string} 绘制符号时使用的基线 <br>
1519
*/
1620
export var UnicodeMarker = L.Path.extend({
1721
// @section
1822
// @aka CircleMarker options
1923
options: {
20-
fill: true,
2124
fontStyle: "normal",
2225
fontWeight: "normal",
2326
fontSize: "1em",
@@ -26,8 +29,6 @@ export var UnicodeMarker = L.Path.extend({
2629
textBaseline: "middle",
2730
vfactor: -.5,
2831
labelRotation: 0,
29-
labelXOffset: 0,
30-
labelYOffset: 0,
3132
globalAlpha: 1,
3233
label: ""
3334
},

src/leaflet/mapping/TiandituTileLayer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import {WMTSLayer} from "./TileLayer.WMTS";
66
* @class L.supermap.tiandituTileLayer
77
* @classdesc 天地图图层类。
88
* @extends L.supermap.wmtsLayer
9-
* @param defaultURL -{string} 默认图层地址
109
* @param options -{Object} 切片图层参数。如:<br>
11-
* layer - {string} 图层类型。<br>
10+
* url - {string} 地图地址。<br>
11+
* layerType - {string} 图层类型。(vec:矢量图层,img:影像图层,ter:地形图层)<br>
1212
* style - {string} 图层风格。<br>
13-
* tilematrixSet - {string} 瓦片矩阵集。<br>
1413
* format - {string} 格式。<br>
14+
* isLabel - {boolean} 是否是标注图层<br>
1515
* subdomains - {Array<number>} 子域名数组。<br>
1616
* attribution - {string} 版权信息
1717
*/

src/openlayers/mapping/Tianditu.js

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,45 @@ import ol from 'openlayers/dist/ol-debug';
55
* @classdesc 天地图图层源。
66
* @param opt_options - {Object} 参数。
77
* url - {string} 服务地址。<br>
8+
* layerType - {string} 图层类型。(vec:矢量图层,img:影像图层,ter:地形图层)<br>
89
* attributions - {string} 版权描述信息。<br>
910
* cacheSize - {number} 缓冲大小。<br>
1011
* tileLoadFunction - {function} 切片加载完成后执行函数。<br>
11-
* maxZoom - {Object} 最大缩放级别。<br>
12+
* style - {string} 图层风格。<br>
13+
* format - {string} 格式。<br>
14+
* isLabel - {boolean} 是否是标注图层<br>
1215
* opaque - {boolean} 是否透明。
1316
* @extends ol.source.WMTS{@linkdoc-openlayers/ol.source.WMTS}
1417
*/
1518
export default class Tianditu extends ol.source.WMTS {
16-
1719
constructor(opt_options) {
1820
var options = opt_options || {};
1921
var attributions = options.attributions || new ol.Attribution({
2022
html: "Map Data <a href='http://www.tianditu.com' target='_blank'><img style='background-color:transparent;bottom:2px;opacity:1;' " +
2123
"src='http://api.tianditu.com/img/map/logo.png' width='53px' height='22px' opacity='0'></a> with " +
2224
"<span>© <a href='http://iclient.supermapol.com' target='_blank'>SuperMap iClient</a></span>"
2325
});
24-
26+
options.layerType = options.layerType || "vec";
27+
options.layerType = options.isLabel ? ol.source.Tianditu.layerLabelMap[options.layerType] : options.layerType;
28+
options.matrixSet = (options.projection === 'EPSG:4326' || options.projection === 'EPSG:4490') ? "c" : "w";
2529
if (!options.url && !options.urls) {
26-
options.url = "http://t{0-7}.tianditu.com/img_w/wmts"
30+
options.url = "http://t{0-7}.tianditu.com/{layer}_{proj}/wmts?"
2731
}
32+
options.url = options.url.replace("{layer}", options.layerType).replace("{proj}", options.matrixSet);
33+
var tileGrid = options.tileGrid || ol.source.Tianditu.getTileGrid(options.projection || 'EPSG:3857');
2834
super({
2935
version: options.version || '1.0.0',
3036
format: options.format || 'tiles',
3137
dimensions: options.dimensions || {},
32-
layer: options.layer || 'img',
33-
matrixSet: options.matrixSet || 'w',
34-
tileGrid: options.tileGrid || ol.source.Tianditu.getTileGrid(options.projection || 'EPSG:3857'),
38+
layer: options.layerType,
39+
matrixSet: options.matrixSet,
40+
tileGrid: tileGrid,
3541
style: options.style || 'default',
3642
attributions: attributions,
3743
cacheSize: options.cacheSize,
3844
crossOrigin: options.crossOrigin,
3945
opaque: options.opaque || true,
40-
maxZoom: options.maxZoom || 19,
46+
maxZoom: ol.source.Tianditu.layerZoomMap[options.layerType],
4147
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
4248
tileLoadFunction: options.tileLoadFunction,
4349
url: options.url,
@@ -60,6 +66,17 @@ export default class Tianditu extends ol.source.WMTS {
6066
return ol.source.Tianditu.default3857TileGrid();
6167
}
6268

69+
static layerLabelMap = {
70+
"vec": "cva",
71+
"ter": "cta",
72+
"img": "cia"
73+
}
74+
static layerZoomMap = {
75+
"vec": 18,
76+
"ter": 14,
77+
"img": 18
78+
}
79+
6380
/**
6481
* @function ol.source.Tianditu.default4326TileGrid
6582
* @description 获取默认4326网格瓦片
@@ -68,9 +85,9 @@ export default class Tianditu extends ol.source.WMTS {
6885
static default4326TileGrid() {
6986
var tdt_WGS84_resolutions = [];
7087
var matrixIds = [];
71-
for (var i = 0; i < 18; i++) {
72-
tdt_WGS84_resolutions.push(0.703125 / (Math.pow(2, i)));
73-
matrixIds.push(i + 1);
88+
for (var i = 1; i < 19; i++) {
89+
tdt_WGS84_resolutions.push(0.703125 * 2 / (Math.pow(2, i)));
90+
matrixIds.push(i);
7491
}
7592
var tileGird = new ol.tilegrid.WMTS({
7693
extent: [-180, -90, 180, 90],
@@ -90,9 +107,9 @@ export default class Tianditu extends ol.source.WMTS {
90107
static default3857TileGrid() {
91108
var tdt_Mercator_resolutions = [];
92109
var matrixIds = [];
93-
for (var i = 0; i < 18; i++) {
94-
tdt_Mercator_resolutions.push(78271.5169640203125 / (Math.pow(2, i)));
95-
matrixIds.push(i + 1);
110+
for (var i = 1; i < 19; i++) {
111+
tdt_Mercator_resolutions.push(78271.5169640203125 * 2 / (Math.pow(2, i)));
112+
matrixIds.push(i);
96113
}
97114
var tileGird = new ol.tilegrid.WMTS({
98115
extent: [-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892],

src/openlayers/mapping/WebMap.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -347,27 +347,12 @@ export default class WebMap extends ol.Observable {
347347
* @return {ol.layer.Tile} 获取天地图的图层
348348
*/
349349
createTiandituLayer(layerInfo, epsgCode) {
350-
var proj = epsgCode === 4326 ? "c" : "w";
351-
var tdtURL =
352-
"http://t{0-7}.tianditu.com/{type}_{proj}/wmts?";
353350
var type = layerInfo.type.split('_')[1].toLowerCase();
354-
if (layerInfo.layerType === 'OVERLAY_LAYER') {
355-
if (type == "vec") {
356-
type = "cva"
357-
}
358-
if (type == "img") {
359-
type = "cia"
360-
}
361-
if (type == "ter") {
362-
type = "cta"
363-
}
364-
}
365-
tdtURL = tdtURL.replace("{type}", type).replace("{proj}", proj);
351+
var isLabel=layerInfo.layerType === 'OVERLAY_LAYER';
366352
var layer = new ol.layer.Tile({
367353
source: new ol.source.Tianditu({
368-
url: tdtURL,
369-
matrixSet: proj,
370-
layer: type,
354+
layerType: type,
355+
isLabel:isLabel,
371356
projection: "EPSG:" + epsgCode
372357
})
373358
})

0 commit comments

Comments
 (0)