Skip to content

Commit

Permalink
fix 切换map报错 review by songym
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Sep 1, 2023
1 parent 85eed0d commit 3c4b221
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/common/web-map/WebMapBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export default abstract class WebMapBase extends Events {
this.webMapInfo = mapId;
}
this.webMapService.setMapId(mapId);
if (!mapId) {
return;
}
setTimeout(() => {
this._initWebMap();
}, 0);
Expand Down
16 changes: 7 additions & 9 deletions src/mapboxgl/web-map/WebMapViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,15 @@ export default class WebMapViewModel extends WebMapBase {

public setStyle(style): void {
if (this.map) {
if (style && style.layers && style.layers.length > 0) {
setTimeout(() => {
this.triggerEvent('addlayerssucceeded', {
map: this.map,
mapparams: {},
layers: []
});
}, 0);
}
this.mapOptions.style = style;
style && this.map.setStyle(style);
if (style && style.layers && style.layers.length > 0) {
this.triggerEvent('addlayerssucceeded', {
map: this.map,
mapparams: {},
layers: []
});
}
}
}

Expand Down

0 comments on commit 3c4b221

Please sign in to comment.