Skip to content

Commit 9d193da

Browse files
committed
[bug] MVT底图添加经纬网分享界面控制台报错
review by zhaoq
1 parent a04b6a3 commit 9d193da

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -322,33 +322,27 @@ export class WebMap extends Observable {
322322
// title: mapInfo.title,
323323
// description: mapInfo.description
324324
// }; //存储地图的名称以及描述等信息,返回给用户
325-
const isHaveGraticule = mapInfo.grid && mapInfo.grid.graticule;
325+
that.isHaveGraticule = mapInfo.grid && mapInfo.grid.graticule;
326326

327327
if (mapInfo.baseLayer && mapInfo.baseLayer.layerType === 'MAPBOXSTYLE') {
328328
// 添加矢量瓦片服务作为底图
329329
that.addMVTMapLayer(mapInfo, mapInfo.baseLayer, 0).then(() => {
330330
that.createView(mapInfo);
331-
if (!isHaveGraticule && (!mapInfo.layers || mapInfo.layers.length === 0)) {
331+
if (!mapInfo.layers || mapInfo.layers.length === 0) {
332332
that.sendMapToUser(0);
333333
} else {
334334
that.addLayers(mapInfo);
335335
}
336+
that.addGraticule(mapInfo);
336337
});
337338
} else {
338339
await that.addBaseMap(mapInfo);
339-
if (!isHaveGraticule && (!mapInfo.layers || mapInfo.layers.length === 0)) {
340+
if (!mapInfo.layers || mapInfo.layers.length === 0) {
340341
that.sendMapToUser(0);
341342
} else {
342343
that.addLayers(mapInfo);
343344
}
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);
352346
}
353347
} else {
354348
// 不支持的坐标系
@@ -2023,7 +2017,8 @@ export class WebMap extends Observable {
20232017
* @param {number} layersLen - 叠加图层总数
20242018
*/
20252019
sendMapToUser(layersLen) {
2026-
if (this.layerAdded === layersLen && this.successCallback) {
2020+
const lens = this.isHaveGraticule ? layersLen + 1 : layersLen;
2021+
if (this.layerAdded === lens && this.successCallback) {
20272022
this.successCallback(this.map, this.mapParams, this.layers, this.baseLayer);
20282023
}
20292024
}
@@ -4718,6 +4713,21 @@ export class WebMap extends Observable {
47184713
return +version[1];
47194714
}
47204715

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+
47214731
/**
47224732
* @private
47234733
* @function ol.supermap.WebMap.prototype.createGraticuleLayer

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