Skip to content

Commit 14ab9bc

Browse files
【fix】 修复经纬网图层获取extent 错误
1 parent ec2e084 commit 14ab9bc

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

src/mapboxgl/overlay/GraticuleLayer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export class GraticuleLayer {
255255

256256
getDefaultExtent(extent, map = this.map) {
257257
const crs = (map.getCRS && map.getCRS()) || {};
258-
let { extent: crsExtent } = crs;
258+
let { lngLatExtent: crsExtent } = crs;
259259
if (!crsExtent) {
260260
crsExtent = [-180, -85.05119, 180, 85.05119];
261261
}

src/maplibregl/overlay/GraticuleLayer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export class GraticuleLayer {
267267

268268
getDefaultExtent(extent, map = this.map) {
269269
const crs = (map.getCRS && map.getCRS()) || {};
270-
let { extent: crsExtent } = crs;
270+
let { lngLatExtent: crsExtent } = crs;
271271
if (!crsExtent) {
272272
crsExtent = [-180, -85.05119, 180, 85.05119];
273273
}

test/mapboxgl/overlay/GraticuleLayerSpec.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GraticuleLayer } from '../../../src/mapboxgl/overlay/GraticuleLayer';
22
import mapboxgl from 'mapbox-gl';
3-
import { Feature } from '@supermap/iclient-common';
3+
// import { Feature } from '@supermap/iclient-common';
44
var url = GlobeParameter.ChinaURL + '/zxyTileImage.png?z={z}&x={x}&y={y}';
55

66
describe('mapboxgl_GraticuleLayer', () => {
@@ -126,6 +126,32 @@ describe('mapboxgl_GraticuleLayer', () => {
126126
expect(graticuleLayer.renderer.options.interval).toEqual(5);
127127
});
128128

129+
it('getDefaultExtent must return degree', () => {
130+
map.getCRS = () => {
131+
return {
132+
extent: [
133+
-20037508.3427892,
134+
-20037508.3427892,
135+
20037508.3427892,
136+
20037508.3427892
137+
],
138+
lngLatExtent: [
139+
-179.99999999999963,
140+
-85.05112877980658,
141+
179.99999999999963,
142+
85.05112877980656
143+
]
144+
};
145+
};
146+
var extent = graticuleLayer.getDefaultExtent();
147+
expect(extent).toEqual([
148+
-179.99999999999963,
149+
-85.05112877980658,
150+
179.99999999999963,
151+
85.05112877980656
152+
]);
153+
});
154+
129155
it('_calcInterval', () => {
130156
const interval = map.getZoom();
131157
const calcInterval = map => {

test/maplibregl/overlay/GraticuleLayerSpec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,32 @@ describe('maplibregl_GraticuleLayer', () => {
8484
expect(visible).toBe('visible');
8585
});
8686

87+
it('getDefaultExtent must return degree', () => {
88+
map.getCRS = () => {
89+
return {
90+
extent: [
91+
-20037508.3427892,
92+
-20037508.3427892,
93+
20037508.3427892,
94+
20037508.3427892
95+
],
96+
lngLatExtent: [
97+
-179.99999999999963,
98+
-85.05112877980658,
99+
179.99999999999963,
100+
85.05112877980656
101+
]
102+
};
103+
};
104+
var extent = graticuleLayer.getDefaultExtent();
105+
expect(extent).toEqual([
106+
-179.99999999999963,
107+
-85.05112877980658,
108+
179.99999999999963,
109+
85.05112877980656
110+
]);
111+
});
112+
87113
it('setMinZoom', () => {
88114
graticuleLayer.setMinZoom(0);
89115
expect(graticuleLayer.options.minZoom).toEqual(0);

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