Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PopupViewer sample: check all results for popups before building new one #511

Merged
merged 3 commits into from
Jul 11, 2023

Conversation

mstefarov
Copy link
Collaborator

Sample change only

When testing PopupViewer sample with different maps, I noticed that our example often returns different results from the AGOL web viewer — and different from what I expected the behavior to be.

Our existing code checks each result for popups but then immediately goes into fallback code and builds a popup from a GeoElement. This means we never get around to check sublayer results, or check the second result.

In contrast, the AGOL map viewer first checks ALL results/sublayers for directly-returned popups, and only then starts looking at GeoElements. I implemented similar behavior by splitting GetPopup into two methods groups: GetPopup (recursively checks for popups only) and BuildPopupFromGeoElement (recursively checks for geoelements and popup definitions).


Example of a webmap where this can be seen: https://maps.arcgis.com/apps/mapviewer/index.html?webmap=df8bcc10430f48878b01c96e907a1fc3

In AGOL clicking on a warning zone shows its proper popup:

2023-04-12_113256 msedge

In current toolkit sample, it shows a basic generated popup for the "US States" polygon (which happens to be the first GeoElement in results):

2023-04-12_113605

With this PR, we now match AGOL behavior:
2023-04-12_113724

@mstefarov mstefarov merged commit 5db7706 into main Jul 11, 2023
@mstefarov mstefarov deleted the matvei/popup-sample branch July 11, 2023 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants