Skip to content

Commit

Permalink
修复地图预览错误
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Mar 25, 2024
1 parent 8866e99 commit 1c0f7cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 126,928 deletions.
11 changes: 2 additions & 9 deletions src/mapboxgl/web-map/WebMapV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
private _sourceListModel: SourceListModel;

private _legendList: any;

private _handleDataflowFeaturesCallback: Function;

private _initDataflowLayerCallback: Function;
Expand All @@ -109,7 +110,7 @@
private _layerTimerList: Array<any> = [];

private checkSameLayer: boolean;
// 可感知图层集合

private _appreciableLayers: Array<any> = [];

private _mapInfo: Object;
Expand All @@ -127,8 +128,6 @@
super(id, options, mapOptions);
if (typeof id === 'string' || typeof id === 'number') {
this.mapId = id;
} else if (id !== null && typeof id === 'object') {
this.webMapInfo = id;
}
if (!this.mapId && !mapOptions.center && !mapOptions.zoom) {
mapOptions.center = [0, 0];
Expand All @@ -153,10 +152,6 @@
this._taskID = new Date();
this._getMapInfo(this._mapInfo, this._taskID);
}

public getAppreciableLayers() {
return this._appreciableLayers;
}

public getLegendInfo() {
return this._legendList;
Expand Down Expand Up @@ -2692,9 +2687,7 @@

cleanWebMap() {
if (this.map) {
this.triggerEvent('beforeremovemap', {});
this.stopCanvg();
this.map.remove();
this.map = null;
this._legendList = [];
this._sourceListModel = null;
Expand Down
27 changes: 14 additions & 13 deletions src/mapboxgl/web-map/WebMapViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ export default class WebMapViewModel extends Events {

baseProjection: string;

_version: string;

protected _taskID: Date;

private _sourceListModel: SourceListModel;
Expand Down Expand Up @@ -149,7 +147,6 @@ export default class WebMapViewModel extends Events {
this._appreciableLayers = [];
this.webMapService = new WebMapService(id, options);
this.mapOptions = mapOptions;
this.options = options;
this.eventTypes = [
'getmapinfofailed',
'crsnotsupport',
Expand Down Expand Up @@ -393,8 +390,8 @@ export default class WebMapViewModel extends Events {
withCredentials: this.withCredentials,
target: this.target,
mapInfo
});
this._registerWebMapV2Events(webMapHandler);
}, this.mapOptions, this.map, this.layerFilter);
this._registerV2Events(webMapHandler);
return webMapHandler;
}

Expand Down Expand Up @@ -449,16 +446,16 @@ export default class WebMapViewModel extends Events {
server: this.serverUrl,
withCredentials: this.withCredentials,
target: this.target
});
this._registerWebMapEvents(webMapHandler);
}, this.mapOptions);
this._registerV3Events(webMapHandler);
webMapHandler.createWebMap({
...mapInfo,
layers: typeof this.layerFilter === 'function' ? mapInfo.layers.filter(this.layerFilter) : mapInfo.layers
}, this.map);
return webMapHandler;
}

_registerWebMapV2Events(webMapHandler): void {
_registerV2Events(webMapHandler): void {
if (!webMapHandler) {
return;
}
Expand All @@ -484,7 +481,7 @@ export default class WebMapViewModel extends Events {
});
}

_registerWebMapEvents(webMapHandler): void {
_registerV3Events(webMapHandler): void {
if (!webMapHandler) {
return;
}
Expand Down Expand Up @@ -513,7 +510,6 @@ export default class WebMapViewModel extends Events {
}

_getMapInfo(mapInfo, _taskID?) {
this._version = mapInfo.version;
this._handler = +mapInfo.version.split('.')[0] === 3 ? this._createWebMapV3(mapInfo) : this._createWebMapV2(mapInfo);
}

Expand Down Expand Up @@ -545,13 +541,20 @@ export default class WebMapViewModel extends Events {
}

cleanWebMap() {
if (this._handler) {
// @ts-ignore
this._handler.cleanWebMap && this._handler.cleanWebMap();
}
if (this.map) {
this.triggerEvent('beforeremovemap', {});
// this.stopCanvg();
this.map.remove();
this.map = null;
this._sourceListModel = null;
this._appreciableLayers = [];
if (this.mapOptions) {
this.mapOptions.zoom = null;
this.mapOptions.center = null;
}
}
}

Expand All @@ -570,7 +573,5 @@ export default class WebMapViewModel extends Events {
public updateOverlayLayer(layerInfo: any, features: any, mergeByField?: string) {
// @ts-ignore
this._handler.updateOverlayLayer && this._handler.updateOverlayLayer(layerInfo, features, mergeByField);


}
}
Loading

0 comments on commit 1c0f7cc

Please sign in to comment.