Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit199cc61

Browse files
[fix]leaflet wmts token不对 review by qiw
1 parent2c8bb4c commit199cc61

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

‎src/leaflet/mapping/TileLayer.WMTS.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
44
importLfrom"leaflet";
55
import"../core/Base";
6+
import{SecurityManager}from'@supermap/iclient-common/security/SecurityManager';
7+
import{UtilasCommonUtil}from'@supermap/iclient-common/commontypes/Util';
68

79
/**
810
*@class WMTSLayer
@@ -81,8 +83,11 @@ export var WMTSLayer = L.TileLayer.extend({
8183
getTileUrl:function(coords){// (Point, Number) -> String
8284
varzoom=this._getZoomForUrl();
8385
varident=this.options.matrixIds ?this.options.matrixIds[zoom].identifier :zoom;
86+
varindex=this._url.indexOf('?');
87+
varurl=index>-1 ?this._url.substring(0,this._url.indexOf('?')) :this._url;
88+
varurlParams=index>-1 ?this._url.substring(this._url.indexOf('?')) :'';
8489

85-
varurl=L.Util.template(this._url,{s:this._getSubdomain(coords)});
90+
url=L.Util.template(url,{s:this._getSubdomain(coords)});
8691

8792
varobj={
8893
service:'WMTS',
@@ -108,7 +113,9 @@ export var WMTSLayer = L.TileLayer.extend({
108113
}elseif(this.options.requestEncoding==='REST'){
109114
varparams="/"+obj.layer+"/"+obj.style+"/"+obj.tilematrixSet+"/"+obj.tilematrix+"/"+obj.tilerow+"/"+obj.tilecol+this.formatSuffix;
110115
url+=params;
111-
}
116+
}
117+
url=CommonUtil.urlAppend(url,urlParams);
118+
url=SecurityManager.appendCredential(url);
112119
returnurl;
113120
}
114121
});

‎test/leaflet/mapping/TileLayer.WMTSSpec.js‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import{wmtsLayer}from'../../../src/leaflet/mapping/TileLayer.WMTS';
2+
import{SecurityManager}from'../../../src/common/security/SecurityManager';
23

34
varurl=GlobeParameter.WMTSURL;
45
describe('leaflet_TileLayerWMTS',()=>{
@@ -71,4 +72,36 @@ describe('leaflet_TileLayerWMTS', () => {
7172
expect(WMTStiledMapLayerObject.getTileUrl(coords)).toBe(url+'/China/default/Custom_China/NaN/0/0.png');
7273
});
7374

75+
it("getTileUrl_params Token",()=>{
76+
varcoords={x:0,y:0,z:0};
77+
varoption={
78+
layer:"China",
79+
style:"default",
80+
tilematrixSet:"Custom_China",
81+
format:"image/png",
82+
requestEncoding:'REST'
83+
};
84+
varurl=GlobeParameter.WMTSURL+'?token=test';
85+
WMTStiledMapLayerObject=wmtsLayer(url,option);
86+
consttileUrl=WMTStiledMapLayerObject.getTileUrl(coords)
87+
expect(tileUrl).not.toBeNull();
88+
expect(tileUrl).toBe(GlobeParameter.WMTSURL+'/China/default/Custom_China/NaN/0/0.png?token=test');
89+
});
90+
91+
it("getTileUrl_registerToken",()=>{
92+
varcoords={x:0,y:0,z:0};
93+
varoption={
94+
layer:"China",
95+
style:"default",
96+
tilematrixSet:"Custom_China",
97+
format:"image/png",
98+
requestEncoding:'REST'
99+
};
100+
varurl=GlobeParameter.WMTSURL;
101+
SecurityManager.registerToken(url,'test');
102+
WMTStiledMapLayerObject=wmtsLayer(url,option);
103+
consttileUrl=WMTStiledMapLayerObject.getTileUrl(coords)
104+
expect(tileUrl).not.toBeNull();
105+
expect(tileUrl).toBe(GlobeParameter.WMTSURL+'/China/default/Custom_China/NaN/0/0.png?token=test');
106+
});
74107
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp