Skip to content

Commit 5232a6f

Browse files
[fix]经纬网setExtent setInterval报错 review by qiw
1 parent 4ec5619 commit 5232a6f

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/mapboxgl/overlay/GraticuleLayer.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,7 @@ export class GraticuleLayer {
198198
*/
199199
setExtent(extent) {
200200
this.options.extent = this.getDefaultExtent(extent, this.map);
201-
// this.features = this._getGraticuleFeatures();
202-
this.updateGraticuleLayer();
203-
this.renderer._drawLabel();
201+
this.renderer.setExtent(extent);
204202
}
205203

206204
/**
@@ -328,7 +326,7 @@ export class GraticuleLayer {
328326
}
329327
}
330328

331-
updateGraticuleLayer(features = this.features) {
329+
updateGraticuleLayer(features = this.renderer.features) {
332330
if (this.map.getSource(this.sourceId)) {
333331
const geoJSONData = {
334332
type: 'FeatureCollection',

src/maplibregl/overlay/GraticuleLayer.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ export class GraticuleLayer {
210210
*/
211211
setExtent(extent) {
212212
this.options.extent = this.getDefaultExtent(extent, this.map);
213-
// this.features = this._getGraticuleFeatures();
214-
this.updateGraticuleLayer();
215-
this.renderer._drawLabel();
213+
this.renderer.setExtent(extent);
216214
}
217215

218216
/**
@@ -306,7 +304,7 @@ export class GraticuleLayer {
306304
}
307305
}
308306

309-
updateGraticuleLayer(features = this.features) {
307+
updateGraticuleLayer(features = this.renderer.features) {
310308
if (this.map.getSource(this.sourceId)) {
311309
const geoJSONData = {
312310
type: 'FeatureCollection',

test/mapboxgl/overlay/GraticuleLayerSpec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,14 @@ describe('mapboxgl_GraticuleLayer', () => {
9999

100100
it('setExtent', () => {
101101
try {
102+
expect(graticuleLayer.renderer.features.length).toEqual(56);
102103
graticuleLayer.setExtent([
103104
[0, 0],
104105
[50, 50]
105106
]);
106107
expect(graticuleLayer.options.extent[0]).toEqual(0);
107108
expect(graticuleLayer.options.extent[3]).toEqual(50);
109+
expect(graticuleLayer.renderer.features.length).toEqual(12);
108110
} catch (e) {
109111
expect(false).toBeTruthy();
110112
console.log(e);

test/maplibregl/overlay/GraticuleLayerSpec.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ describe('maplibregl_GraticuleLayer', () => {
1919
style: {
2020
version: 8,
2121
sources: {
22-
// 'raster-tiles': {
23-
// type: 'raster',
24-
// tiles: [url],
25-
// tileSize: 256
26-
// }
22+
'raster-tiles': {
23+
type: 'raster',
24+
tiles: [url],
25+
tileSize: 256
26+
}
2727
},
2828
layers: [
29-
// {
30-
// id: 'simple-tiles',
31-
// type: 'raster',
32-
// source: 'raster-tiles',
33-
// minzoom: 0,
34-
// maxzoom: 22
35-
// }
29+
{
30+
id: 'simple-tiles',
31+
type: 'raster',
32+
source: 'raster-tiles',
33+
minzoom: 0,
34+
maxzoom: 22
35+
}
3636
]
3737
},
3838
center: [112, 37.94],
@@ -125,14 +125,16 @@ describe('maplibregl_GraticuleLayer', () => {
125125
expect(graticuleLayer.options.showLabel).toEqual(false);
126126
});
127127

128-
xit('setExtent', () => {
128+
it('setExtent', () => {
129129
try{
130+
expect(graticuleLayer.renderer.features.length).toEqual(56);
130131
graticuleLayer.setExtent([
131132
[0, 0],
132133
[50, 50]
133134
]);
134135
expect(graticuleLayer.options.extent[0]).toEqual(0);
135136
expect(graticuleLayer.options.extent[3]).toEqual(50);
137+
expect(graticuleLayer.renderer.features.length).toEqual(12);
136138
} catch (e) {
137139
expect(false).toBeTruthy();
138140
console.log(e);
@@ -154,7 +156,7 @@ describe('maplibregl_GraticuleLayer', () => {
154156
expect(graticuleLayer.options.latLabelStyle.textSize).toEqual('12px');
155157
});
156158

157-
xit('setIntervals', () => {
159+
it('setIntervals', () => {
158160
try{
159161
graticuleLayer.setIntervals(5);
160162
expect(graticuleLayer.renderer.options.interval).toEqual(5);

0 commit comments

Comments
 (0)