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.