@@ -322,33 +322,27 @@ 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
+ that . isHaveGraticule = mapInfo . grid && mapInfo . grid . graticule ;
326
326
327
327
if ( mapInfo . baseLayer && mapInfo . baseLayer . layerType === 'MAPBOXSTYLE' ) {
328
328
// 添加矢量瓦片服务作为底图
329
329
that . addMVTMapLayer ( mapInfo , mapInfo . baseLayer , 0 ) . then ( ( ) => {
330
330
that . createView ( mapInfo ) ;
331
- if ( ! isHaveGraticule && ( ! mapInfo . layers || mapInfo . layers . length === 0 ) ) {
331
+ if ( ! mapInfo . layers || mapInfo . layers . length === 0 ) {
332
332
that . sendMapToUser ( 0 ) ;
333
333
} else {
334
334
that . addLayers ( mapInfo ) ;
335
335
}
336
+ that . addGraticule ( mapInfo ) ;
336
337
} ) ;
337
338
} else {
338
339
await that . addBaseMap ( mapInfo ) ;
339
- if ( ! isHaveGraticule && ( ! mapInfo . layers || mapInfo . layers . length === 0 ) ) {
340
+ if ( ! mapInfo . layers || mapInfo . layers . length === 0 ) {
340
341
that . sendMapToUser ( 0 ) ;
341
342
} else {
342
343
that . addLayers ( mapInfo ) ;
343
344
}
344
- }
345
-
346
- // 经纬网
347
- if ( isHaveGraticule ) {
348
- that . createGraticuleLayer ( mapInfo . grid . graticule ) ;
349
- that . layerAdded ++ ;
350
- const lens = mapInfo . layers ? mapInfo . layers . length : 0 ;
351
- that . sendMapToUser ( lens + 1 ) ;
345
+ that . addGraticule ( mapInfo ) ;
352
346
}
353
347
} else {
354
348
// 不支持的坐标系
@@ -2023,7 +2017,8 @@ export class WebMap extends Observable {
2023
2017
* @param {number } layersLen - 叠加图层总数
2024
2018
*/
2025
2019
sendMapToUser ( layersLen ) {
2026
- if ( this . layerAdded === layersLen && this . successCallback ) {
2020
+ const lens = this . isHaveGraticule ? layersLen + 1 : layersLen ;
2021
+ if ( this . layerAdded === lens && this . successCallback ) {
2027
2022
this . successCallback ( this . map , this . mapParams , this . layers , this . baseLayer ) ;
2028
2023
}
2029
2024
}
@@ -4718,6 +4713,21 @@ export class WebMap extends Observable {
4718
4713
return + version [ 1 ] ;
4719
4714
}
4720
4715
4716
+ /**
4717
+ * @private
4718
+ * @function ol.supermap.WebMap.prototype.addGraticule
4719
+ * @description 创建经纬网
4720
+ * @param {object } mapInfo - 地图信息
4721
+ */
4722
+ addGraticule ( mapInfo ) {
4723
+ if ( this . isHaveGraticule ) {
4724
+ this . createGraticuleLayer ( mapInfo . grid . graticule ) ;
4725
+ this . layerAdded ++ ;
4726
+ const lens = mapInfo . layers ? mapInfo . layers . length : 0 ;
4727
+ this . sendMapToUser ( lens ) ;
4728
+ }
4729
+ }
4730
+
4721
4731
/**
4722
4732
* @private
4723
4733
* @function ol.supermap.WebMap.prototype.createGraticuleLayer
0 commit comments