Display Popup for Features within a Polygon

135
2
Jump to solution
2 weeks ago
Justin_Greco
Occasional Contributor II

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.

 

 

0 Kudos
1 Solution

Accepted Solutions
Ting
by Esri Contributor
Esri Contributor

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

View solution in original post

0 Kudos
2 Replies
Ting
by Esri Contributor
Esri Contributor

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

0 Kudos
Justin_Greco
Occasional Contributor II

Thank you, I just need to construct the popup.

0 Kudos