Skip to content

Commit ed59f71

Browse files
committed
【fix】ICL-1535
1 parent 81cdac3 commit ed59f71

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

src/mapboxgl/mapping/WebMap.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
44
import mapboxgl from 'mapbox-gl';
55
import { FetchRequest } from '@supermap/iclient-common/util/FetchRequest';
6-
import { Lang } from '@supermap/iclient-common/lang/Lang';
76
import { Util } from '../core/Util';
87
import { WebMap as WebMapV2 } from './webmap/v2/WebMap';
98
import { WebMap as WebMapV3 } from './webmap/v3/WebMap';
@@ -135,12 +134,6 @@ export class WebMap extends mapboxgl.Evented {
135134
return response.json();
136135
})
137136
.then((mapInfo) => {
138-
const projectionMap = ['EPSG:4490', 'EPSG:4214', 'EPSG:4610', 'EPSG:3857', 'EPSG:4326'];
139-
const baseProjection = this._getMapProjection(mapInfo);
140-
// 坐标系异常处理
141-
if (!projectionMap.find(item => item === baseProjection)) {
142-
throw Error(Lang.i18n('msg_crsunsupport'));
143-
}
144137
this.webMapInstance = this._initMap(mapInfo);
145138
this._registerWebMapEvents();
146139
this.webMapInstance.initializeMap(mapInfo);
@@ -155,19 +148,6 @@ export class WebMap extends mapboxgl.Evented {
155148
});
156149
}
157150

158-
/**
159-
* @private
160-
* @function WebMap.prototype._getMapProjection
161-
* @param {object} mapInfo - 地图信息。
162-
* @description 获取地图投影。
163-
*/
164-
_getMapProjection(mapInfo) {
165-
if (this._isWebMapV3(mapInfo.version)) {
166-
return mapInfo.crs;
167-
}
168-
return mapInfo.projection;
169-
}
170-
171151
/**
172152
* @private
173153
* @function WebMap.prototype._initMap

src/mapboxgl/mapping/webmap/v2/WebMap.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ export class WebMap extends mapboxgl.Evented {
7979
* @param {Object} mapInfo - map 信息。
8080
*/
8181
initializeMap(mapInfo) {
82+
const projectionMap = ['EPSG:4490', 'EPSG:4214', 'EPSG:4610', 'EPSG:3857', 'EPSG:4326'];
83+
// 坐标系异常处理
84+
if (!projectionMap.find(item => item === mapInfo.projection)) {
85+
throw Error(Lang.i18n('msg_crsunsupport'));
86+
}
8287
this.baseProjection = mapInfo.projection;
8388
//存储地图的名称以及描述等信息,返回给用户
8489
this.mapParams = {

test/mapboxgl/mapping/WebMapSpec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import mapboxgl from 'mapbox-gl';
22
import mbglmap from '../../tool/mock_mapboxgl_map';
33
import { WebMap } from '../../../src/mapboxgl/mapping/WebMap';
44
import { FetchRequest } from '@supermap/iclient-common/util/FetchRequest';
5+
import { Lang } from '@supermap/iclient-common/lang/Lang';
56
import { ArrayStatistic } from '../../../src/common/util/ArrayStatistic';
67
import '../../resources/WebMapV5.js';
78
window.jsonsql = { query: () => { } };
@@ -866,4 +867,22 @@ describe('mapboxgl_WebMap', () => {
866867
}, 100);
867868
});
868869
});
870+
871+
it('crs unsupport', (done) => {
872+
let options = {
873+
server: server
874+
};
875+
spyOn(FetchRequest, 'get').and.callFake((url) => {
876+
if (url.indexOf('map.json') > -1) {
877+
var mapJson = JSON.stringify({...JSON.parse(datavizWebMap_WMTS1), projection: 'EPSG:-1000'});
878+
return Promise.resolve(new Response(mapJson));
879+
}
880+
return Promise.resolve();
881+
});
882+
var datavizWebmap = new WebMap(id, options);
883+
datavizWebmap.on('getmapfailed', ({ error }) => {
884+
expect(error.message).toBe(Lang.i18n('msg_crsunsupport'));
885+
done();
886+
});
887+
})
869888
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy