How do I change Polygon Color?

¿Could I change polygon color? I have an app, and users ask some questions. It uses polygons I did manually for all states/provinces of a country, and shows them to the user. I want to change polygon's color if user ask well, but I don't know how to do it. Sorry if I wasn't clear. Thanks in advance.

Welcome Volkarian.

Yes. The color of Map polygons and the polygons in a Canvas can be changed to whatever you need.

Here are several tutorials that might show what you to do to change a Map polygon's color

These examples will not show you exactly what you need to do in your app; they show different methods for changing a polygon's color. One of the methods should work for your Project.

You can possibly change the color of all the polygons in your app to another color by using the Any component blocks and looping over a List of the polygons.

If you write a more detailed explanation about what you want to do, someone can provide more specific advice. You might wish to share your Project aia or a Block image.

1 Like

Well, thanks for helping me and for giving me advices, SteveJG. I have read each tutorial, but I don't find my solution. Plus, you told me I could upload images, so I did it. I will explain my project in detail.
a) My app have some objects, a map where there are polygons, and where user ask some question about capitals. This is what user see.

b) List of Components:


c) Blocks


The app has 24 polygons which represent provinces. In each polygon, its attribute "TITLE" is full with the name of Province. All provinces have default color (red), and when user clicks on them, the name of the province appears in its infobox. So, what I'd like to do is when user ask question like: "Capital of x Province: y", and if ask it well, the name of x Province make polygon related to it change its color (blue or green).
I hope I haven't misled purpose of threads, nor I haven't broken any rules of it.
Thanks again SteveJG and all of you guys for reading my post.
See you.

Something like this ?

StateQuiz.aia (11.9 KB)


Without your Project aia or the Argentina json file I can not tell you specifically what to do. You want to click on one of the Province polygons, then ask ask for the user to name the capital (from a List?) and if correct to change the color of that Province's polygon. It is possible. You might use similar code that changes the polygon in the above example and an if..else if statement.

Hi SteveJG
Thank you for helping me by second time. Well, I want to use parts of QuizMe app and State Geography Quiz with Map Component app from Tutorials. Good news, I solved json file using a page where I drew all provinces, ergo, I can read all provinces without use polygon component.
I'm gonna try to solve the other problem, which is when user ask well, change polygon's color due to the right answer. Only I request, Is there any chances of keeping this thread open, please? I be able to inform all of you, if I could solve the 2nd problem.
Thanks again.
See you.

1 Like

It will not close until you mark it solved. :slight_smile: Good luck with your app.

Hi there,
¿Is there some way of catching the number of polygon from a polygon index, when polygons are inside of Feature Collection? My problem to solve, if you could help me, please, is:
a) User ask question number 1, from a question list;
b) Catch polygon's number inside of Feature Collection (like position, 1st polygon, 2nd polygon, etc);
c) If user ask well, match polygon's position with question number, and then change polygon's color.
I did some logic comparisons over and over again, but the functionality still don't work.
Thanks in advance.

One way is discussed in Post #2 that might work with your data set. You should be able to produce a List of Polygons; you already have that List
polyNames :slight_smile: . Each is usually posted in their order of occurrence.

The original question was answered. For subsequent advice, please start a new topic as your questions are not related to the topic.

That is answered in post #4.

Hi again,
Well, this is what I understood:

a) Loop in Polygon List;
b) if UserResponse in RtaText.text is equals to item of PolygonList, change Polygon Color.

Is that right, or Would I need other variable / component / block?

Thanks Steve.

If all that is in the FeatureCollection are polygons, the code looks right. Did you try it. It is easy to test. Press the SubmitButton and all the polygons should turn grey.

Yes you should be able to do that. Remember, you care putting together a List of polygons if you do that, not their description (name). Use the DoIt debugger to find out.

You might. Test your code and find out. :astonished:

Well Steve, you gonna ban me, but I didn't work.
But, you confirm me my logic is good, it should be any wrong about other thing, not the last block I uploaded here.
Close the thread, please. Thanks again Steve, for your time and patience.
See you.

This code might help

  • Button1 will set ALL of your polygons to green color. Step # 1

  • Type name of one of your Provinces in the TextBox. Step #2 . Make sure you type exactly what the province name is (e.g. Buenos_Aires ; not Buenos Aires ) in the polygon List]

    To work with your json, set the States2 List to these values (use your Provinces names, not my state names)


  • Step # 3. Turns state of Maine red and indicates the name in the TitleBar.

These hints should allow you to do what YOU want to do.

1 Like

Hi SteveJG,
Finally it works, it works. Thank you very much, man. Now, I want to put a list (like ListView) where user see all provinces, and choose the right one and do the same thing. But, this is for another thread, and in this time, it's up to me to do that job.
Thank you so much again, for your response and your time.
Until next time, Steve.

1 Like

Hi guys,
Is there any chance I could modify thread title, please? Instead of "Change Polygon Color", "How Do I Change Polygon Color". I read a post, and I needed to type the last title, not the first. Sorry for that. Have all of you a nice week!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.