Skip to content

Commit 8387dfd

Browse files
committed
[bug] 修复ol webmap 创建地图成功后,叠加图层异步请求的图层信息未返回。
review by zhaoq
1 parent 8de8913 commit 8387dfd

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,9 +1479,10 @@ export class WebMap extends Observable {
14791479
dataSource = layer.dataSource,
14801480
isSampleData = dataSource && dataSource.type === "SAMPLE_DATA" && !!dataSource.name; //SAMPLE_DATA是本地示例数据
14811481
if(layer.layerType === "MAPBOXSTYLE"){
1482-
that.addMVTMapLayer(mapInfo, layer, layerIndex);
1483-
that.layerAdded++;
1484-
that.sendMapToUser(len);
1482+
that.addMVTMapLayer(mapInfo, layer, layerIndex).then(result => {
1483+
that.layerAdded++;
1484+
that.sendMapToUser(len);
1485+
});
14851486
} else if ((dataSource && dataSource.serverId) || layer.layerType === "MARKER" || layer.layerType === 'HOSTED_TILE' || isSampleData) {
14861487
//数据存储到iportal上了
14871488
let dataSource = layer.dataSource,
@@ -1523,8 +1524,8 @@ export class WebMap extends Observable {
15231524
features = await that.excelData2Feature(data.content, layer);
15241525
}
15251526
} else if(data.type === 'SHP') {
1526-
let content = JSON.parse(data.content);
1527-
data.content = content.layers[0];
1527+
let content = JSON.parse(data.content);
1528+
data.content = content.layers[0];
15281529
features = that.geojsonToFeature(data.content, layer);
15291530
}
15301531
that.addLayer(layer, features, layerIndex);
@@ -1585,14 +1586,16 @@ export class WebMap extends Observable {
15851586
if (layer.layerType === "WMTS") {
15861587
that.getWmtsInfo(layer, function (layerInfo) {
15871588
that.map.addLayer(that.createBaseLayer(layerInfo, layerIndex));
1589+
that.layerAdded++;
1590+
that.sendMapToUser(len);
15881591
})
15891592
} else {
15901593
that.getLayerExtent(layer, function(layerInfo){
15911594
that.map.addLayer(that.createBaseLayer(layerInfo, layerIndex));
1595+
that.layerAdded++;
1596+
that.sendMapToUser(len);
15921597
});
15931598
}
1594-
that.layerAdded++;
1595-
that.sendMapToUser(len);
15961599
} else if (dataSource && dataSource.type === "REST_DATA") {
15971600
//从restData获取数据
15981601
that.getFeaturesFromRestData(layer, layerIndex, len);
@@ -1928,7 +1931,7 @@ export class WebMap extends Observable {
19281931
} else {
19291932
xIdx = dataMetaInfo.xIndex;
19301933
yIdx = dataMetaInfo.yIndex;
1931-
}
1934+
}
19321935
} else if (dataSource.type === 'SAMPLE_DATA') {
19331936
// 示例数据从本地拿xyField
19341937
const sampleData = SampleDataInfo.find(item => item.id === dataSource.name) || {};
@@ -1968,7 +1971,7 @@ export class WebMap extends Observable {
19681971
} else {
19691972
attributes[field] = rowDatas[j];
19701973
}
1971-
1974+
19721975
}
19731976
let feature = new Feature({
19741977
geometry: olGeom,
@@ -2650,7 +2653,7 @@ export class WebMap extends Observable {
26502653
let newStyle;
26512654
if(featureType === 'LINE' && Util.isArray(style)) {
26522655
const [outlineStyle, strokeStyle] = style;
2653-
newStyle = strokeStyle.lineDash === 'solid' ? StyleUtils.getRoadPath(strokeStyle, outlineStyle)
2656+
newStyle = strokeStyle.lineDash === 'solid' ? StyleUtils.getRoadPath(strokeStyle, outlineStyle)
26542657
: StyleUtils.getPathway(strokeStyle, outlineStyle);
26552658
} else {
26562659
newStyle = StyleUtils.toOpenLayersStyle(layerInfo.style, layerInfo.featureType);
@@ -3597,7 +3600,7 @@ export class WebMap extends Observable {
35973600
//有token之类的配置项
35983601
url = url.indexOf("?") === -1 ? `${url}?${this.credentialKey}=${this.credentialValue}` :
35993602
`${url}&${this.credentialKey}=${this.credentialValue}`;
3600-
}
3603+
}
36013604
return url;
36023605
}
36033606

@@ -4291,17 +4294,17 @@ export class WebMap extends Observable {
42914294
isSupportWebp(url, token) {
42924295
// 还需要判断浏览器
42934296
let isIE = this.isIE();
4294-
if(isIE || (this.isFirefox() && this.getFirefoxVersion() < 65) ||
4297+
if(isIE || (this.isFirefox() && this.getFirefoxVersion() < 65) ||
42954298
(this.isChrome() && this.getChromeVersion() < 32)) {
42964299
return false;
4297-
}
4300+
}
42984301
url = token ? `${url}/tileImage.webp?token=${token}` : `${url}/tileImage.webp`;
42994302
url = this.getRequestUrl(url);
43004303
return FetchRequest.get(url, null, {
43014304
withCredentials: this.withCredentials
43024305
}).then(function (response) {
43034306
if(response.status !== 200) {
4304-
throw response.status;
4307+
throw response.status;
43054308
}
43064309
return response;
43074310
}).then(() => {

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