Select to view content in your preferred language

Issue with Popups in ArcGIS Swift SDK 200.x for Webmap Configured on ArcGIS Enterprise Portal

521
10
08-29-2024 06:32 AM
mmoosbac94
Emerging Contributor

Hi everyone,

I have a question regarding displaying popups in a webmap configured on ArcGIS Enterprise Portal, specifically using the ArcGIS Swift SDK 200.x. We followed the tutorial provided here: https://developers.arcgis.com/swift/sample-code/show-popup/, and while showing the popup itself is working fine, we are encountering some issues with configuring the popups for layer features within the webmap.

No matter what configurations we make for a popup (with "list of field attributes") in the ArcGIS Enterprise Portal, they seem to be ignored in the iOS app. However, the configurations work correctly in the web viewer. Does anyone have any ideas why this might not work out of the box in the iOS app? Could this be a bug?

Additionally, a "Fields" dropdown always appears for the attributes. Is there a way to remove this dropdown and display the attributes directly without it or do we have to implement custom solution for that?

Thanks!
Marvin

 

0 Kudos
10 Replies
Destiny_Hochhalter
Esri Contributor

Hi Marvin,

How is the popup sourced or created? If the popup is created with a geoElement then a list of field attributes shown in the `PopupView` is the expected behavior.

The popup can be configured to not show a list of field attributes by using a popup definition. The popup definition defines the elements in a popup such as the text description and media such as images and charts. Here are some examples of how to construct a popup with a popup definition.

 

 

// Using a geoElement.
let popupDefinition = PopupDefinition(geoElement: geoElement)
let popup = Popup(geoElement: geoElement, definition: popupDefinition)

// Using a feature's table.
if let arcGISFeature = feature.element as? ArcGISFeature {
     try await arcGISFeature.load()
     let popupDefinition = arcGISFeature.table?.popupDefinition ?? PopupDefinition(geoElement: arcGISFeature)
     let popup = Popup(geoElement: arcGISFeature, definition: popupDefinition)
}

 

 




0 Kudos
mmoosbac94
Emerging Contributor

Hi @Destiny_Hochhalter,

Thank you for your reply. To clarify, we do not create the popup directly. Instead, we follow the tutorial mentioned earlier. We generate the popup by identifying a layer feature using proxy.identifyLayers and then accessing the popup through identifyResult.first?.popups.first. We then pass this popup into a PopupView.

However, the issue we're encountering is that the popup does not display as configured in ArcGIS Enterprise Portal. Specifically, the configured fields are ignored, and the popup consistently appears as a dropdown list rather than the expected format shown in the Map Viewer in the Portal. Should it not adapt the format configured in ArcGIS Enterprise?

0 Kudos
Destiny_Hochhalter
Esri Contributor

Hi Marvin,

Thanks for clarifying. Can you confirm if the layer you retrieved the popup for (identifyResult.first?.popups.first) is the layer you defined the popup on? If the layer does not match, then you can alternatively use the proxy identify method for the specific layer: identify(on: screenPoint: tolerance: returnPopupsOnly: maximumResults).

For fields the Toolkit `PopupView` displays a disclosure control to the right and allows the user to collapse or expand the display of the fields. This UI can only be customized by modifying the Toolkit's code.

0 Kudos
mmoosbac94
Emerging Contributor

Hi @Destiny_Hochhalter,

yes, we can confirm that. We are already using the identify(on: screenPoint) method. When I configure the popup of the the layer to not use "A list of attributed fields" but "A custom attribute display", I can change the content of the popup.

But for "A list of attributed fields" the selected field attributes are not returned correctly. When I use "identifiedLayerResult.popups.first" to get the popup and then use "popup.geoElement.attributes.keys" all attribute keys are returned (sometimes even keys are missing). So it is a weird behaviour. Do you know how I can get only the in ArcGIS Enterprise selected / configured attribute fields for a popup?

But thanks for the information that we need to modify the Toolkit's code to remove the fields dropdown. Or maybe we build our own solution / popup with the selected attribute fields when we are able to get them correctly.

___

Update:

We would be able to get only the configured field attributes of a popup when we first filter all visible (configured) fields of popup-definition and the compare it against all the attributes of the popup:

 

let identifiedLayerResult

         if let fields = identifiedLayerResult.popups.first?.definition.fields {

                     let visibleFields = fields.filter { $0.isVisible }

                    visibleFields.forEach { field in

                        print("VisibleFields: \(field.fieldName) + \(field)")

                    }

          }

                let attributes = identifiedLayerResult.popups.first?.geoElement.attributes

                attributes?.forEach { attribute in

                    print("AllAttributes: \(attribute.key) : \(attribute.value)")

                }

 



Do you thinks its a valid approach to get around this issue? Because otherwise we are not able to show the configured field attributes only?

0 Kudos
Destiny_Hochhalter
Esri Contributor

Hi @mmoosbac94,

Thanks for the update. I'm not sure if the popup definition fields and popup geoElement attributes are guaranteed to match, but I will look into this and give you an update. 

Have you tried creating a new popup using the popup definition? This shouldn't be necessary, but if creating a new popup using the popup definition results in a different PopupView result then there could be a bug. Also, if you can provide screenshots of the PopupView expected and actual results that could be helpful.

let newPopup = Popup(geoElement: popup.geoElement, definition: popup.definition)

 

0 Kudos
mmoosbac94
Emerging Contributor

Hi @Destiny_Hochhalter,

first to your question: Have you tried creating a new popup using the popup definition?

Yes, we have already tried this approach because it's necessary for our workflow. We retrieve a feature from a feature table in ArcGIS Enterprise using query parameters, and then use the feature table’s "popupDefinition" to create a popup. However, the result is still an incorrect popup. It seems that the "isVisible" parameter for the popup fields is being ignored. As mentioned earlier, when I use the approach described above, it appears to work correctly.

I can give you an example for the expected popup: In the "Pop-Up Content" section in ArcGIS Enterprise we have selected three fields to show up in the popup. Our expectation would be to just see this three fields in a popup in the iOS-App. In the portal's mapviewer its working fine, so we just see the configured fields. But in our iOS-App if we now e.g. select a feature of the specific layer on the map, then we still see all fields of this layer although we configured it in the portal. So the fields configuration seem to be ignored with the Swift-SDK. Hope it helps.

0 Kudos
Destiny_Hochhalter
Esri Contributor

Thanks for clarifying @mmoosbac94 ,

I logged a Swift Toolkit issue here. The `PopupView` does not use the `popupElement.fields` to populate the view so the field visibility is ignored. This is a bug since the `PopupView` appearance should be consistent with how the popup is authored on ArcGIS Enterprise.

0 Kudos
DiveshGoyal
Esri Regular Contributor

@mmoosbac94 What version of ArcGIS Enterprise are you using?
To help us reproduce the issue, can you provide a json or a screenshot of the popup definition you have configured in the webmap?

0 Kudos
mmoosbac94
Emerging Contributor

Hi @DiveshGoyal We are using ArcGIS Enterprise version 10.91.

Bildschirmfoto 2024-09-23 um 09.37.17.pngBildschirmfoto 2024-09-23 um 09.37.33.png

0 Kudos