@@ -322,30 +322,31 @@ export class WebMap extends Observable {
322
322
// title: mapInfo.title,
323
323
// description: mapInfo.description
324
324
// }; //存储地图的名称以及描述等信息,返回给用户
325
+ const isHaveGraticule = mapInfo . grid && mapInfo . grid . graticule ;
325
326
326
327
if ( mapInfo . baseLayer && mapInfo . baseLayer . layerType === 'MAPBOXSTYLE' ) {
327
328
// 添加矢量瓦片服务作为底图
328
329
that . addMVTMapLayer ( mapInfo , mapInfo . baseLayer , 0 ) . then ( ( ) => {
329
330
that . createView ( mapInfo ) ;
330
- if ( ! mapInfo . layers || mapInfo . layers . length === 0 ) {
331
+ if ( ! isHaveGraticule && ( ! mapInfo . layers || mapInfo . layers . length === 0 ) ) {
331
332
that . sendMapToUser ( 0 ) ;
332
333
} else {
333
334
that . addLayers ( mapInfo ) ;
334
335
}
335
336
} ) ;
336
337
} else {
337
338
await that . addBaseMap ( mapInfo ) ;
338
- if ( ! mapInfo . layers || mapInfo . layers . length === 0 ) {
339
+ if ( ! isHaveGraticule && ( ! mapInfo . layers || mapInfo . layers . length === 0 ) ) {
339
340
that . sendMapToUser ( 0 ) ;
340
341
} else {
341
342
that . addLayers ( mapInfo ) ;
342
343
}
343
344
}
344
345
345
346
// 经纬网
346
- if ( mapInfo . grid && mapInfo . grid . graticule ) {
347
+ if ( isHaveGraticule ) {
347
348
that . createGraticuleLayer ( mapInfo . grid . graticule ) ;
348
- that . isAdded ++ ;
349
+ that . layerAdded ++ ;
349
350
const lens = mapInfo . layers ? mapInfo . layers . length : 0 ;
350
351
that . sendMapToUser ( lens + 1 ) ;
351
352
}
@@ -4727,12 +4728,11 @@ export class WebMap extends Observable {
4727
4728
createGraticuleLayer ( layerInfo ) {
4728
4729
const { strokeColor, strokeWidth, lineDash, extent, visible, interval, lonLabelStyle, latLabelStyle } = layerInfo ;
4729
4730
const epsgCode = this . baseProjection ;
4730
- // 除以下坐标系外,添加经纬网需要设置extent、worldExtent
4731
- if ( ! [ 'EPSG:4326' , 'EPSG:3857' ] . includes ( epsgCode ) ) {
4732
- let projection = new olProj . get ( epsgCode ) ;
4733
- projection . setExtent ( extent ) ;
4734
- projection . setWorldExtent ( olProj . transformExtent ( extent , 'EPSG:4326' , epsgCode ) ) ;
4735
- }
4731
+ // 添加经纬网需要设置extent、worldExtent
4732
+ let projection = new olProj . get ( epsgCode ) ;
4733
+ projection . setExtent ( extent ) ;
4734
+ projection . setWorldExtent ( olProj . transformExtent ( extent , 'EPSG:4326' , epsgCode ) ) ;
4735
+
4736
4736
let graticuleOptions = {
4737
4737
layerID : 'graticule_layer' ,
4738
4738
strokeStyle : new StrokeStyle ( {
0 commit comments