Select to view content in your preferred language

AGSField alias / AGSPopupField visible: differences between Runtime and Map Viewer

828
5
03-22-2022 05:28 AM
JanWinter
Emerging Contributor

I'm currently working on presenting detail information on instances of AGSFeature of a Web Map and am having difficulties presenting the data similar to the Map Viewer of the portal or the ESRI Explorer app.

The feature data has field aliases for certain fields and it is defined to show only some of the properties. When I click on the Web Map in the portal I get a callout with customized field aliases and only those fields defined to show are being presented. Same in ESRI Explorer app.

When I try to present the data in my own app the customized aliases of the fields are not showing up (they're the same as field.name).

Eg. simplified data:

 

[
 { name: "PROP_A", alias: "beautiful title", visible: true, value: "some value" },
 { name: "PROP_B", alias: "PROP_B", visible: false, value: "some other value" }
]

 

 

In Map Viewer / ESRI Explorer the callout says: "beautiful title": "some value".

When I load an AGSPopup it says: "PROP_A": "some value", "PROP_B": "some other value".

 

 

First I get the features:

 

func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
 arcgisMapView.identifyLayers(atScreenPoint: point, tolerance: 12, returnPopupsOnly: false, maximumResultsPerLayer: 10) { (results: [AGSIdentifyLayerResult]?, error: Error?) in {
               var features = [AGSArcGISFeature]()
            results?.forEach { result in
                if let theFeatures = result.geoElements as? [AGSArcGISFeature] {
                    features.append(contentsOf: theFeatures)
                }
                if !result.sublayerResults.isEmpty {
                    result.sublayerResults.forEach { subResult in
                        if let subFeatures = subResult.geoElements as? [AGSArcGISFeature] {
                            features.append(contentsOf: subFeatures)
                        }
                    }
                }
            }

 

 

I'm wondering why result never has any popups populated. But never mind I create the popups myself:

 

 

// either simple
let popup = AGSPopup(geoElement: feature)

// alternatively with popupdefinition:
let popupDefinition = AGSPopupDefinition(geoElement: feature)
// or
let popupDefinition = AGSPopupDefinition(popupSource: feature.featureTable)

let popup = AGSPopup(geoElement: feature, popupDefinition: popupDefinition)

let popupsVC = AGSPopupsViewController(popups: [popup], containerStyle: .navigationController)

 

 

When I present the popupsVC all fields are shown and no field alias is being used. Why is that? I also tried loading the feature before creating the popup, but no difference.

 

ESRI Explorer App / Map Viewer show the data perfectly (only the fields that shall be visible with a "beautiful" alias)... Any hints?

0 Kudos
5 Replies
Nicholas-Furness
Esri Regular Contributor

Hi,

If you're working with a Web Map that has popups defined, your should really read the popup definitions from the AGSIdentifyLayerResults you get back where possible. You say it's empty, but if the Web Map has popups defined, it should not be so I'd like to dig into that a bit more.

What does the `popups` array on each AGSIdentifyLayersResult contain? 

Could you try setting returnPopupsOnly to true on the identify call? That will make sure that layers that do not have popups defined are not included in the results you get back, in case you are accidentally looking at the wrong layer (perhaps the web map has multiple similar layers but only popups defined on one of them?).

Thanks!

0 Kudos
JanWinter
Emerging Contributor

Hi Nicholas,

thanks for digging into that with me.

I'm not the creator of the map and also not into what can and can't be done when creating them. I'm just consuming the data (Web Maps and Mobile Map Packages) and try to provide a similar experience as within the Portal Web App (or the ESRI Explorer App).

So when I open one of the Web Maps in ESRI Portal and look into the data I see that there are some pre-selected properties, that also have some customized aliases:

image.png

Tapping onto one of the features I see, that ESRI Portal gives me the pre-selected props with the customized alias titles (I'm also wondering where the title Spree comes from).

Screenshot 2022-03-18 at 16.04.37.png

Now in Runtime iOS SDK: if I create a new `AGSPopover` from the selected feature and feed that into `AGSPopupsViewController` via

let popups = didTapFeatures.compactMap { AGSPopup(geoElement: $0) }
let popupsVC = AGSPopupsViewController(popups: popups, containerStyle: .navigationController)
self?.present(popupsVC, animated: true, completion: nil)

I get this (ie no customized aliases and also too many entries):

IMG_0316.PNG

ESRI Explorer App of course shows the same as the portal (ie customized alias + only selected entries).

So to answer your initial question:

`results` consists of 1 `AGSIdentifyLayersResult`, with 0 geoElements, 0 popups, 1 subLayerResults and the subLayerResult consists of 1 geoElement, 0 popups, 0 subLayerResults. GeoElement is of type `AGSArcGISFeature`. So there are no popups, which is why I create the `AGSPopup` from the geoelement... Setting `returnPopupsOnly` to true of course results in 1 results, with 0 of everything (geoElements, popups, subLayerResults).

I tried that on various Web Maps / Mobile Map Packages and always the same: ESRI Portal / ESRI Explorer App shows nice simplified popups, with my request I get 0 popups and creating the `AGSPopup` from the features myself returns in un-customized too-much-data popups...

Any hints?

 

 

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Thanks for the additional info.

From your screenshot of the portal map viewer, I wonder if the layer has a popup defined, and this is just a question of default behavior when a popup is NOT defined. The title "Spree" probably comes from the service's displayField property.

Can you check and see if there is actually an explicitly defined popup in the web map?

0 Kudos
JanWinter
Emerging Contributor

They creator of the maps / packages says popups are defined for the map not for the layer, if that helps in any way? Map is being created with ArcGIS Pro...

Somehow ESRI Explorer App manages to extract the appropriate data (which I believe is being done with Runtime iOS SDK, too), so the question is which tree to climb in the dense forest of ESRI possibilities...

Best of course would be to have such a feature in arcgis runtime toolkit ios similar to the legendVC...

 

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Runtime can certainly honor defined popups and is supposed to, so at this point we would need to see the web map. You say that you saw this behavior on many web maps, so is there one you can share?

Otherwise, you could use https://assistant.esri-ps.com/signin to get to the JSON data of the web map and DM me that to take a look.

Thank you!

0 Kudos