Search Widget Zoom Issue with Feature Layer Esri JS API 4.x

01-22-2020 08:09 AM
Occasional Contributor III

I am encountering a quirk or potential issue with the Search widget using the JS API 4.x  My search widget includes a geocoding service and feature layer source.

I have set a zoomScale property for both sources.  When searching against the geocoding service, the scale is being honored (I believe).  But when searching against the feature layer, it is not.

I am aware that I could use the goToOverride method to resolve this.  However, it is my opinion that the widget is not working properly.  Any help is appreciated.

I have a demo at

Sample searches:

  • 15 W High Street, Carlisle
  • New Courthouse
  • 321 Gettysburg Pike, Mechanicsburg
  • MDJ 09-3-01
0 Kudos
2 Replies
by Esri Contributor
Esri Contributor

Hi Patrick,


I was able to reproduce the issue so I went ahead and logged a defect.

  • BUG-000129390: The ZoomScale property fails to set zoom scale for the selected search result from LayerSearchSource.


As you have probably already found, a possible workaround would be to set view.scale in a select-result event. For example:


searchWidget.on("select-result"function () {
                            scale: 500000


Apologies for the inconvenience!


Esri Support Services

0 Kudos
Occasional Contributor III

Thanks for the response. I ended up using the goTo() method for the map view object within the search-complete event of the Search widget.

// set map view during search complete event
searchWidget.on('search-complete', function(response) {
// latitude of result
const latitude = response.results[0].results[0];
// longitude to result
const longitude = response.results[0].results[0];

// set map view to result coordinates
center: [longitude, latitude],
zoom: 17