Skip to content

Commit 6143932

Browse files
authored
export DefaultSpatialReference definition (#2410)
* export DefaultSpatialReference definition * spec * fix * fix spec
1 parent 0c3fcd0 commit 6143932

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Map.VERSION = version;
3535
export { Map };
3636

3737
export { MapTool, DrawTool, AreaTool, DistanceTool } from './map/tool/index';
38-
export { default as SpatialReference } from './map/spatial-reference/SpatialReference';
38+
export { default as SpatialReference, getDefaultSpatialReference } from './map/spatial-reference/SpatialReference';
3939
// import './map/spatial-reference/SpatialReference.Arc';
4040
// import './map/spatial-reference/SpatialReference.WMTS';
4141

src/map/spatial-reference/SpatialReference.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,3 +441,8 @@ export default class SpatialReference {
441441
return this._pyramid;
442442
}
443443
}
444+
445+
446+
export function getDefaultSpatialReference(): Record<string, SpatialReferenceType> {
447+
return JSON.parse(JSON.stringify(DefaultSpatialReference));
448+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
describe('SpatialReference.Default', function () {
2+
3+
it('get default SpatialReference', function (done) {
4+
const sps = maptalks.getDefaultSpatialReference();
5+
const epsgs = ['EPSG:3857', 'EPSG:4326', 'BAIDU', 'IDENTITY', 'PRESET-VT-3857', 'PRESET-VT-4326', 'EPSG:4490', 'PRESET-3857-512', 'PRESET-4326-512', 'PRESET-4490-512'];
6+
epsgs.forEach(key => {
7+
expect(sps).to.have.property(key);
8+
const value = sps[key];
9+
expect(value).to.have.property('fullExtent');
10+
expect(value).to.have.property('projection');
11+
expect(value).to.have.property('resolutions');
12+
13+
expect(value.projection).to.be.a('string');
14+
expect(value.resolutions).to.be.a('array');
15+
expect(value.fullExtent).to.be.a('object');
16+
17+
});
18+
done();
19+
20+
});
21+
22+
});

0 commit comments

Comments
 (0)