Skip to content

Commit

Permalink
Refresh layer after source changed
Browse files Browse the repository at this point in the history
  • Loading branch information
MikesWei committed Jul 5, 2020
1 parent f380c4c commit 8773ba6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions App/demo/customImageryLayer/Vector2RasterImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class Vector2RasterImageryProvider extends ComputeImageryProvider {
get source() {
return this._source;
}
//范围比较大的数据,不推荐更新此属性,建议新建图层,避免切换过程中由于cesium重构影像调度树而卡顿
set source(newSource) {
if (!newSource) {
console.warn('newSource is required.');
Expand All @@ -226,17 +227,17 @@ class Vector2RasterImageryProvider extends ComputeImageryProvider {
this.source = geojson;
});
} else {
try {


this.freeResource();
this._source = newSource;
this._setFromGeojson(newSource);
this._ready && this._reload && this._reload();
} catch (e) {
console.error(e);

this.freeResource();
this._source = newSource;
this._setFromGeojson(newSource);
if (this._frameState) {
var scene = this._frameState.camera._scene;
var layerIndex = this._imageryLayer._layerIndex;
scene.imageryLayers.remove(this._imageryLayer,false);
scene.imageryLayers.add(this._imageryLayer, layerIndex);
}

}
}

Expand Down

0 comments on commit 8773ba6

Please sign in to comment.