Zoom with expand to extent

228
0
04-16-2019 08:47 AM
MOHAMED_ARAFATHMOHAMED_ISMAIL
New Contributor

Zoom functionality with expand is not working on first time. After second click , it zooms to the extent correctly. below is my code.

public zoomToFeature() {
let extent = this.getExtent();
if (extent) {
extent.spatialReference = this.module.currentMapView.extent.spatialReference;
extent = extent.expand(1.25);

this.module.currentMapView.setExtent(extent, true)
.then(result => {
const isPointFeature = extent.xmax === extent.xmin;
if (isPointFeature) {
this.module.currentMapView.zoomToClosestScale();
}
});
}
}

public getExtent(): Extent {
if (this.selectedFeature)
return graphicsUtils.graphicsExtent([this.selectedFeature]);
return null;
}

Any suggestions or working code is welcome. Thanks in advance.

0 Kudos
0 Replies