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?
Solved! Go to Solution.
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.
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]}")
}
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.
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.
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
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 😉