How to zoom on feature for any layer?

171
1
09-24-2021 08:20 AM
ironmaskito
New Contributor III

Is it possible to zoom in on a feature in a layer-agnostic way? I am making use of the function goTo()  which accepts as parameters Geometry, Graphic, Viewpoint, a pair of coordinates or an Object with a combination of targetcenterscale and rotation properties. I would like to center on features from layers of different types be they GeoJSON layer or WMS Layer. So far I have not found any properties in Layer that would make it possible to extract feature information that can be passed into goTo().  I can do it by targeting certain layers, for example for GeoJSON I can parse it for geometry property and pass that to goTo() or use the graphics property in GraphicsLayer. But I was wondering if it is possible to do it in a universal way for layers as some like WMSLayer lack even basic feature information. 

Tags (1)
0 Kudos
1 Reply
shaylavi
Esri Contributor

You need to understand what's under the hood to implement such behaviour. From what I know, the ability to zoom requires geometry because then the ideal extent of that geometry can be calculated.

You already know what's required by the API to zoom somewhere so I don't understand what's the actual question? why does the API doesn't automatically supports GeoJSON and other formats? or how can you implement it independently? or what's required to extract from the GeoJSON?

Shay
0 Kudos