Skip to content

Commit 5cca217

Browse files
update 处理对webmap crs 的3857 4326 投影兼容判断
1 parent 8c2aad9 commit 5cca217

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/mapboxgl/mapping/webmap/CRSManager.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import mapboxgl from 'mapbox-gl';
22

3+
const equivalenceMap = {
4+
'EPSG:4490': 'EPSG:4326',
5+
'EPSG:4326': 'EPSG:4490',
6+
'EPSG:3857': 'EPSG:900913',
7+
'EPSG:900913': 'EPSG:3857'
8+
};
39
export class CRSManager {
410
constructor(proj4) {
511
this.proj4 = proj4;
612
this.builtInEPSG = ['EPSG:3857', 'EPSG:4326'];
713
}
814

915
isSameProjection(map, epsgCode) {
10-
return map.getCRS().epsgCode === epsgCode;
16+
const mapEpsgCode = map.getCRS().epsgCode;
17+
return mapEpsgCode === epsgCode ||
18+
(equivalenceMap[mapEpsgCode] === epsgCode && equivalenceMap[epsgCode] === mapEpsgCode);
1119
}
1220

1321
getProj4() {

test/mapboxgl/mapping/WebMapV3Spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ describe('mapboxgl-webmap3.0', () => {
318318
existedMap.on('load', function () {
319319
mapstudioWebmap.initializeMap(nextMapInfo, existedMap);
320320
});
321+
const isSameCrs = extendOptions.crsManager.isSameProjection(existedMap, 'EPSG:4326');
322+
expect(isSameCrs).toBe(true);
321323
mapstudioWebmap.on('mapcreatesucceeded', ({ map }) => {
322324
expect(mapstudioWebmap._appendLayers).toBe(true);
323325
expect(map).toEqual(existedMap);

0 commit comments

Comments
 (0)