Select to view content in your preferred language

Javascript 4.11 - Hightlight and zoom to feature extent

2293
1
06-06-2019 01:28 PM
KateCarlson
Frequent Contributor

Hello-  Looking for some expertise on the Javascript API.  As of now my application uses the address search widget to find a location, if the location intersects the feature layer (polygons) a pop-up will appear with information.  I would also like that feature to be highlighted and zoom to extent. I feel like this should be obvious, I have been looking through the help documentation and perhaps I am not asking the right questions.  Anyone have ideas on how to achieve this, what functions and methods to use?

Thanks!

Kate

Tags (1)
0 Kudos
1 Reply
DavidWilson3
Regular Contributor

Hi Kate,

For the highlighting I am confused because if you have a popup on that feature it should be highlighted by default, perhaps you can look into highlightOptions, or looking at this Esri sample code on highlighting: 

ArcGIS API for JavaScript Sandbox 

As for the extent view.goTo() accepts an Extent: 

MapView | ArcGIS API for JavaScript 4.11 

You should be able to pass the extent of the feature through view.goTo().

Take note that if you pass in an Extent as the target geometry, the .goTo() method will zoom to the nearest LOD of the basemap.

Extent also has an expand() method:

Extent | ArcGIS API for JavaScript 4.11 

0 Kudos