Select to view content in your preferred language

Attributes of a feature get lost when added to a FeatureCollectionTable

639
5
Jump to solution
05-31-2023 07:45 AM
padmalcom
Occasional Contributor

Hi, I create a FeatureCollectionTable and add features using table.createFeatures(attributes, point). I'm adding attributes so that I can identify the features when they are clicked in the map.

attributes.put("id", poiId)
attributes.put("title", poiTitle)

 Then I add the features and the table to a FeatureCollection that I display on a map. I can now select the feature on the map and see that this is exactly the feature I placed (I only have one, so I'm sure it is the one) but the attributes are gone. I only have one attribute attached to this feature and it is called "ObjectID".

Can you give me a hint what's going on here?

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

Hi.

How are you creating the FeatureCollectionTable? When you create it, you need to specify the fields you expect it to store on all features. If you didn't specify a "title" field, then it won't be part of the created feature.

A FeatureCollectionTable has a defined schema that determines the geometry type and attributes (fields) that can be stored for any Feature. Fields can be optional (nullable), of course. See the FeatureCollectionTable constructor, and Field class.

View solution in original post

0 Kudos
5 Replies
padmalcom
Occasional Contributor

Okay I found out, that the attribute is lost right after calling createFeature. This is a bug, right?

attributes["id"] = poiId
attributes["title"] = poiTitle

val addedFeature = currentTable.createFeature(attributes, point)
addedFeature.attributes.keys.map {
Log.d("Attribute check for $it: ${addedFeature.attributes[it]}")
}

 

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Hi.

How are you creating the FeatureCollectionTable? When you create it, you need to specify the fields you expect it to store on all features. If you didn't specify a "title" field, then it won't be part of the created feature.

A FeatureCollectionTable has a defined schema that determines the geometry type and attributes (fields) that can be stored for any Feature. Fields can be optional (nullable), of course. See the FeatureCollectionTable constructor, and Field class.

0 Kudos
padmalcom
Occasional Contributor

Hi @Nicholas-Furness, thanks for your reply. Adding the fields "id" and "title" helped, my attributes don't disappear anymore. Nevertheless, I'd question the api design and I'd at least expect a log message that an attribute appears that is missing a field definition. For me, furthermore, is not clear what a field actually is since there is no real documentation in the Maps SDK.

0 Kudos
DavidCasillas
New Contributor II

@padmalcom 

I'm having issues selecting a feature from a FeatureCollectionLayer. It seems you figured it out. Can you share with me here: forum 

Thank you,

Dave

0 Kudos
padmalcom
Occasional Contributor

Hi @DavidCasillas, sorry for the late reply, I wasn't logged in for a while. Seems that you figured out searching the sub layers - that took me some hours, too. Not very intuitive 😉

0 Kudos