The only way to access the popups for a feature (that I am aware of) is using the identify method, which will only accept a screen point. I have a use case where I want to display a popup for features that are located within a polygon. The only way I can think of doing this is querying each feature layer, then using the centroid of the results to do an identify on the same feature layer. Is there a better way to do this?
Also it appears that identify only works on visible layers. In this case, the layers would not be visible.
Solved! Go to Solution.
Can you clarify more on what you want achieve? By saying
I have a use case where I want to display a popup for features that are located within a polygon.
Is the goal to show popups only for features inside a polygon?
Popups can be constructed from a feature and a popup definition, with this initializer .init(geoElement:definition:)
The popup definition can be found on a feature layer, if it is defined when it is created in Pro or Online.
To query the features within a polygon, you can use QueryParameters with the geometry property.
So (presumably) the workflow can be
- Query all the layers (visible and invisible) to get all features within a polygon
- Get popup definitions from each layer
- Display whichever feature's popups you want
Can you clarify more on what you want achieve? By saying
I have a use case where I want to display a popup for features that are located within a polygon.
Is the goal to show popups only for features inside a polygon?
Popups can be constructed from a feature and a popup definition, with this initializer .init(geoElement:definition:)
The popup definition can be found on a feature layer, if it is defined when it is created in Pro or Online.
To query the features within a polygon, you can use QueryParameters with the geometry property.
So (presumably) the workflow can be
- Query all the layers (visible and invisible) to get all features within a polygon
- Get popup definitions from each layer
- Display whichever feature's popups you want
Thank you, I just need to construct the popup.