Author Topic: Custom City button with label  (Read 71 times)

z79422957

  • Newbie
  • *
  • Posts: 3
    • View Profile
Custom City button with label
« on: July 17, 2021, 06:41:55 AM »
Hi,I've seen the demo tutorial,but I need your help with a few questions:

(1) Just show a few country Labels that I want to show. At present, there are hundreds of them. I may only show 20.

(2) I want to customize a few cities on the earth. Only New York, Paris, Tokyo, Hong Kong, Beijing and so on are displayed on the earth. They are like a button that displays the text label instead of a circular dot. a bit like a country label.

(3) When the user clicks the city button, its event will be triggered.

Thank you Very much. :)

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7097
    • View Profile
Re: Custom City button with label
« Reply #1 on: July 18, 2021, 07:46:55 PM »
Which asset do you refer: 2D Edition or Globe?

z79422957

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Custom City button with label
« Reply #2 on: July 19, 2021, 06:40:27 AM »
World Map Globe Edition 2,The purchase time is 2021 / 7 / 16.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7097
    • View Profile
Re: Custom City button with label
« Reply #3 on: July 19, 2021, 01:05:32 PM »
(1) Use the country.labelVisible to determine if that country label will be visible or not. You can iterate the countries array (map.countries) and set it to false for rest of countries. Call RedrawMapLabels() to refresh them.

(2) You could use the example code from demo scene 1 which shows the USA States Names but using the city locations. Example:

Code
            map.showCities = false;
            int citiyCount = map.cities.Count;
            for (int p = 0; p < cityCount; p++) {
                City city = map.cities[p];
                if (city.name.Equals("New York")) {
                    Color color = new Color(Random.value, Random.value, Random.value);
                    map.AddText(city.name, city.localPosition, color);
                }
            }

(3) Create a script and add the method you want to be called. In the UI Button component, wire the onclick event to that script/method in the usual way.



z79422957

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Custom City button with label
« Reply #4 on: July 20, 2021, 09:42:41 AM »
Thank you for your reply.I will try it after.