HOW do you determine Map feature type?

Dear Experts,

I have a map with FeatureCollection including : Markers and Polygons.

HOW TO (when traversing FeatureCollection of this map) to differentiate action based on feature type. Speed is important here as collection can be big.
Any help appreciated.

You didn't show an example of your FeatureCollection. If you did you would notice parts of the json uses a keyword polygon and it probably named each of them if only by a number suffix. Similarly Makers are id'ed as marker

This snippet might be of uses. It tells the app to differentiate (color them differently as needed) the individual polygons.

So you might make a List of Polygons and then traverse the JSON list.

1 Like

Would this help?

It takes advantage of the new EVERY blocks, which can be used to test component types at run time.

1 Like


(I missed a few map subcomponent types)

1 Like

Thanks @ABG - always fast and helpful !
You inspired me to see if I can loop through every Polygon, as I have just single map on that screen.
Function for Markers goes by every Marker.
IMHO these 2 loops are simpler and not slower.
Works!
for_each_every_polygon
In the meantime I've created sample extension using getClass().getSimpleName() to see if it is an option - works too (I wish there is built-in appinventor method available for any component and variable...).

Thanks again

Thanks @SteveJG. I try to avoid traversing/looking up 2 lists for performance in this case.