Skip to content

Commit 0f5cd6c

Browse files
committed
[bug] 修复ol webmap 4326、3857也需要重新设置worldExtent
review by zhaoq
1 parent 27c7821 commit 0f5cd6c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/openlayers/mapping/WebMap.js

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

326327
if (mapInfo.baseLayer && mapInfo.baseLayer.layerType === 'MAPBOXSTYLE') {
327328
// 添加矢量瓦片服务作为底图
328329
that.addMVTMapLayer(mapInfo, mapInfo.baseLayer, 0).then(() => {
329330
that.createView(mapInfo);
330-
if (!mapInfo.layers || mapInfo.layers.length === 0) {
331+
if (!isHaveGraticule && (!mapInfo.layers || mapInfo.layers.length === 0)) {
331332
that.sendMapToUser(0);
332333
} else {
333334
that.addLayers(mapInfo);
334335
}
335336
});
336337
} else {
337338
await that.addBaseMap(mapInfo);
338-
if (!mapInfo.layers || mapInfo.layers.length === 0) {
339+
if (!isHaveGraticule && (!mapInfo.layers || mapInfo.layers.length === 0)) {
339340
that.sendMapToUser(0);
340341
} else {
341342
that.addLayers(mapInfo);
342343
}
343344
}
344345

345346
// 经纬网
346-
if(mapInfo.grid && mapInfo.grid.graticule) {
347+
if(isHaveGraticule) {
347348
that.createGraticuleLayer(mapInfo.grid.graticule);
348-
that.isAdded++;
349+
that.layerAdded++;
349350
const lens = mapInfo.layers ? mapInfo.layers.length : 0;
350351
that.sendMapToUser(lens + 1);
351352
}
@@ -4727,12 +4728,11 @@ export class WebMap extends Observable {
47274728
createGraticuleLayer(layerInfo) {
47284729
const { strokeColor, strokeWidth, lineDash, extent, visible, interval, lonLabelStyle, latLabelStyle } = layerInfo;
47294730
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+
47364736
let graticuleOptions = {
47374737
layerID: 'graticule_layer',
47384738
strokeStyle: new StrokeStyle({

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