Skip to content

Commit ba826b7

Browse files
committed
fix getMapBoxStyle请求携带withCredentials参数 review by xiongjj
1 parent 35f5104 commit ba826b7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/common/mapping/WebMapService.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ export class WebMapService {
199199

200200
getMapBoxStyle(styleURL, withoutFormatSuffix = false) {
201201
return new Promise((resolve, reject) => {
202-
FetchRequest.get(styleURL, {}, { withoutFormatSuffix })
202+
const proxy = this.handleProxy();
203+
FetchRequest.get(styleURL, {}, {
204+
withoutFormatSuffix,
205+
withCredentials: this.handleWithCredentials(proxy, styleURL, this.withCredentials)
206+
})
203207
.then(response => {
204208
return response.json();
205209
})

test/mapboxgl/mapping/WebMapV2Spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,15 @@ describe('mapboxgl_WebMapV2', () => {
350350
});
351351

352352
it('test baseLayer layers count maploaded', (done) => {
353-
spyOn(FetchRequest, 'get').and.callFake((url) => {
353+
spyOn(FetchRequest, 'get').and.callFake((url, params, options) => {
354354
if (url.indexOf('portal.json') > -1) {
355355
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
356356
}
357357
if (url.indexOf('map.json') > -1) {
358358
return Promise.resolve(new Response(JSON.stringify(webmap_MAPBOXSTYLE_Tile)));
359359
}
360360
if (url.indexOf('maps/China_4326/style.json') > -1) {
361+
expect(options.withCredentials).not.toBeUndefined();
361362
return Promise.resolve(new Response(styleJson));
362363
}
363364
if (url.indexOf('%E4%BA%AC%E6%B4%A5%E5%9C%B0%E5%8C%BA%E5%9C%B0%E5%9B%BE.json') > -1) {

0 commit comments

Comments
 (0)