Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[RELEASED] World Political Map - Globe Edition

Discussion in 'Assets and Asset Store' started by Kronnect, Jul 24, 2015.

  1. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Yes, the GetCityIndex method has several overloads that let you also specify the province and country for the search.
    You can also use GetCityIndexInCountry or GetCityIndexInProvince methods.
     
  2. pzy2017

    pzy2017

    Joined:
    May 9, 2019
    Posts:
    8
    Perfect. Thank you!
    Perfect. Thank you!
     
  3. pdhr

    pdhr

    Joined:
    May 13, 2019
    Posts:
    25
    Hi @Thrawn75 I recently bought this asset and like it so far, but the clipping material does not seem to work for me in my project (see image). In the demo scene it does work. The properties of the plane are exactly the same.

    Any idea what could cause this / how to fix it?
    upload_2020-3-11_16-44-24.png
     
  4. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Could be a temporary issue while not in playmode? Run the scene and see if the issue persists. The shader uses a global uniform set by the WPM script passing the globe center/radius.
     
    pdhr likes this.
  5. SNakonechnyi

    SNakonechnyi

    Joined:
    Aug 19, 2019
    Posts:
    1
    Hello!
    How can I recolor with Map Decorator regions surrounded by green circles? They relate to Italy but are not repainted
     

    Attached Files:

  6. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Use the API: map.ToggleCountrySurface("Italy", true, Color.green);
     
  7. michaeltepl

    michaeltepl

    Joined:
    Dec 26, 2013
    Posts:
    22
    Hi!
    Back to previous question from SNakonechnyi,
    method ToggleCountrySurface(string name, bool visible, Color color = new Color(), bool drawOutline = false, Color outlineColor = new Color()) has parameter drawOutline, but it seems to be working only for the first call of this method for certain country.

    For example,
    map.ToggleCountrySurface("France", true, Color.green, false); // paints France with green color without outline
    map.ToggleCountrySurface("France", true, Color.yellow, true, Color.red); // paints France in yellow, but still without outline, though parameter drawOutline was set to true

    And vice versa:
    map.ToggleCountrySurface("France", true, Color.yellow, true, Color.red); // paints France in yellow with red outline
    map.ToggleCountrySurface("France", true, Color.green, false); // paints France with green color, but outline still remains, though parameter drawOutline was set to false

    As far as I understand, outline is generated only for the first call aling with surface generation. For further calls surface is taken from the cache. I am using solid color earth style and all country painting should be done from code.

    Maybe I am missing something and there is another way to repaint country from code and control its outline?
     

    Attached Files:

  8. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    This has been changed in latest beta so further calls with different outline colors work. Also, new methods like DrawCountryOutline or ToggleCountryOutline have been added so you have finer control over the outline itself.
     
  9. michaeltepl

    michaeltepl

    Joined:
    Dec 26, 2013
    Posts:
    22
    When are you planning to release this changes (or provide with beta version)? Is there any workaround for current version of plugin?
     
  10. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    This week but you can just sign up on our support forum and send me a pm with your invoice number to get access now.
     
  11. michaeltepl

    michaeltepl

    Joined:
    Dec 26, 2013
    Posts:
    22
    Thanks! By the way, I have one more question, is there a way to use globe with separate camera and ui render texture and pass input from ui to globe?
     
  12. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Well, you can add a partial class that bridge between your UI and the internal methods to perform highlighting, rotation, etc. Basically the method you need to interface is PerformUserInteractionNormalMode(). You can also derive from WorldMapGlobe and override that method.
     
  13. michaeltepl

    michaeltepl

    Joined:
    Dec 26, 2013
    Posts:
    22
  14. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Hey, I've not reproduced this yet but if the issue is related to an execution order between EventSystem scripts and WorldMapGlobe (according to the resolution notes of the bug you refer), you may try delaying the execution of WorldMapGlobe script:
     
  15. michaeltepl

    michaeltepl

    Joined:
    Dec 26, 2013
    Posts:
    22
    Hey, finally I found the cause of the problem and its not connected with script execution order. On mobile
    IsPointerOverGameObject should be called along with check of touch phase Began (see https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.EventSystem.html), because on touch phase Ended it always returns false.
    Besides you need to check all touches that started over ui, not only touch with index 0 and store theirs ids in Hashset. Here is my suggested solution for method CheckPointerOverUI in WPMInternal.cs, where currentIgnoredFingerIDs is a hashset mentioned above:

    Code (CSharp):
    1. if (Input.touchSupported && Input.touchCount > 0)
    2.                     {
    3.                         for (int i = 0; i < Input.touchCount; i++)
    4.                         {
    5.                             Touch currTouch = Input.GetTouch(i);
    6.                             if (currTouch.phase == TouchPhase.Began && UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject(currTouch.fingerId))
    7.                             {
    8.                                 mouseIsOverUIElement = true;
    9.                                 currentIgnoredFingerIDs.Add(currTouch.fingerId);
    10.                             }
    11.                             else
    12.                             {
    13.                                 mouseIsOverUIElement = currentIgnoredFingerIDs.Contains(currTouch.fingerId);
    14.                                 if (currTouch.phase == TouchPhase.Ended || currTouch.phase == TouchPhase.Canceled)
    15.                                 {
    16.                                     currentIgnoredFingerIDs.Remove(currTouch.fingerId);
    17.                                 }
    18.                             }
    19.                         }
    20.                         return;
    21.                     }
     
    Kronnect likes this.
  16. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Thank you for the hint. We'll review it and apply it into next patch.
     
  17. michaeltepl

    michaeltepl

    Joined:
    Dec 26, 2013
    Posts:
    22
    Thanks a lot, here is the full code of this method that i am using now:
    Code (CSharp):
    1. private HashSet<int> currentIgnoredFingerIDs = new HashSet<int>();
    2.         void CheckPointerOverUI() {
    3.             // Check whether the points is on an UI element, then cancels
    4.             if (_respectOtherUI) {
    5. #if VR_EYE_RAY_CAST_SUPPORT
    6.                 if (VRCameraEyeRayCaster!=null && VRCameraEyeRayCaster.CurrentInteractible != null) {
    7.                     if (!mouseIsOverUIElement) {
    8.                         mouseIsOverUIElement = true;
    9.                         HideCountryRegionHighlight();
    10.                     }
    11.                     CheckTilt();
    12.                     return;
    13.                 }
    14. #endif
    15.                 if (UnityEngine.EventSystems.EventSystem.current != null)
    16.                 {
    17.                     // [MT] Added touch phases handling to check if touch started over UI.
    18.                     // Also added loop to check all touches, not only first
    19.                     if (Input.touchSupported && Input.touchCount > 0)
    20.                     {
    21.                         for (int i = 0; i < Input.touchCount; i++)
    22.                         {
    23.                             Touch currTouch = Input.GetTouch(i);
    24.                             if (currTouch.phase == TouchPhase.Began && UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject(currTouch.fingerId))
    25.                             {
    26.                                 mouseIsOverUIElement = true;
    27.                                 currentIgnoredFingerIDs.Add(currTouch.fingerId);
    28.                             }
    29.                             else
    30.                             {
    31.                                 mouseIsOverUIElement = currentIgnoredFingerIDs.Contains(currTouch.fingerId);
    32.                                 if (currTouch.phase == TouchPhase.Ended || currTouch.phase == TouchPhase.Canceled)
    33.                                 {
    34.                                     currentIgnoredFingerIDs.Remove(currTouch.fingerId);
    35.                                 }
    36.                             }
    37.                         }
    38.                         return;
    39.                     }
    40.                     else if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject(-1))
    41.                     {
    42.                         mouseIsOverUIElement = true;
    43.                         return;
    44.                     }
    45.                 }
    46.             }
    47.             mouseIsOverUIElement = false;
    48.         }
    Besides, I wanted to ask you how I can find you on forum to write a PM to get latest beta version
     
  18. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
  19. mananp

    mananp

    Joined:
    Nov 2, 2019
    Posts:
    2
    Hi @Thrawn75 , I recently bought your asset and this is an amazing asset,

    I am working on a project where I'm using your asset in VR, with the help of raycasting I was able to select the country and make that county highlighted but I want to add another function that when I select any country, I can see an image of that particular country in another side banner, My question is - is there any method or function in your API which can help me create an image of a country on another object banner when selected on the globe.

    Thank you
     
  20. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Hello,

    Take a look at the "Bake Texture" command (page 14 in documentation). It generates a texture with all textured countries, not just one, but you could adapt it to enclose just one single country.

    Here's another use case, but for World Map Strategy Kit in this case (posted here just for showing another different approach): https://kronnect.me/taptapgo/index.php/topic,2907.msg7243.html#msg7243

    Regards
     
  21. mananp

    mananp

    Joined:
    Nov 2, 2019
    Posts:
    2
    Kronnect likes this.
  22. pdhr

    pdhr

    Joined:
    May 13, 2019
    Posts:
    25
    This is a super delayed reply but I finally came back to this issue. Thanks for pointing to the globalVector that was used. It was simply a matter of changing the localScale reference to the global lossyScale reference when the global shader variable is assigned:

    Code (CSharp):
    1. Shader.SetGlobalVector("_WPM_GlobePos", new Vector4(t.position.x, t.position.y, t.position.z, (t.lossyScale.x * 0.5f) * (t.lossyScale.x * 0.5f)));
    Not sure if that's something that you would want to fix in general
     
    Kronnect likes this.
  23. Mandelboxed

    Mandelboxed

    Joined:
    Apr 17, 2015
    Posts:
    50
    Hi,

    I'm using this asset to highlight areas of the map at a few different points in my application, and have found that I am getting an incredible number of GC allocations when using WorldMap2D.instance.GetProvinceIndex.

    Is there any solution to this?
    upload_2020-8-13_9-13-33.png

    upload_2020-8-13_9-14-44.png

    This does not happen every time GetProvinceIndex is called, but I cannot figure out a reliable way to initialize that prevents occasional massive spikes.
     
  24. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    This is due late-loading of data. Since province data is extensive, the asset doesn't load all of them during startup. The first time you access a province, the asset fetches and decodes its region data (you can see the ReadProvincePackedString call in the profiler). That would only happen once per province and the first time that province is accessed.
     
  25. Mandelboxed

    Mandelboxed

    Joined:
    Apr 17, 2015
    Posts:
    50
    Unfortunately this is causing uncomfortable frame drops in our VR application (delays of over a second). Not all countries have equal amounts of province data. Is there an easy way to figure out which ones are most likely to be problematic and preload those?
     
  26. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Use this code to benchmark provinces loading times per country:

    Code (CSharp):
    1.             System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
    2.             for (int k = 0; k < map.countries.Length; k++) {
    3.                 long start = sw.ElapsedMilliseconds;
    4.                 Country country = map.countries[k];
    5.                 if (country.provinces == null) continue;
    6.                 for (int p = 0; p < country.provinces.Length; p++) {
    7.                     Province prov = country.provinces[p];
    8.                     if (prov.regions == null) map.ReadProvincePackedString(prov);
    9.                 }
    10.                 Debug.Log("Country " + k + " " + map.countries[k].name + " took " + (sw.ElapsedMilliseconds - start));
    11.             }
     
  27. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Also check latest beta from our support forum which comes with new memory optimizations.
     
  28. alterra_br

    alterra_br

    Joined:
    Mar 29, 2019
    Posts:
    5
    Hi!
    Can I somehow add component to country (surface) objects without changing initial asset code?
    In my case I need to catch some inputs and wont use build-in click event.
    Thanks!
     
  29. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Use this code:

    Code (CSharp):
    1. Country country = map.GetCountry("France");
    2. int countryIndex = map.GetCountryIndex(country);
    3. GameObject surf = map.ToggleCountryMainRegionSurface(countryIndex, true, Color.white);
    4.  
    5. // call this only if you don't want the surface to remain visible:
    6. map.ToggleCountryMainRegionSurface(countryIndex, false, Color.white);
    7.  
     
    alterra_br likes this.
  30. alterra_br

    alterra_br

    Joined:
    Mar 29, 2019
    Posts:
    5
    Much thanks!
    Will try it.
     
  31. pdhr

    pdhr

    Joined:
    May 13, 2019
    Posts:
    25
    @Kronnect

    I have two questions pertaining the offline downloading of tiles:

    1. Is it possible to use the offline downloaded tiles external from a built/binary application? It really inflates the size and it would be great if I could add other offline downloaded tiles post-build.

    2. The downloading itself takes absolutely ages, it downloads at something like 10 bits / second or something similar. Is that normal or is there something I can do to speed up downloading?
     
  32. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    You can use the OnTileRequest event to provide tile textures on the fly. Please check page 50 of the documentation for details (for example, you could add your event handler that reads the file from anywhere and returns it to the asset as the tile image is requested).

    Do you refer to the download assistant or the normal operation?
    The Max Concurrent Downloads and the Download Time Out settings are the options you have to force a larger number of downloads. However the default values should be fine. If you're using the tiles downloader, you may find that the server may be throttling down your requests if you don't have an API key to access it.
     
  33. pdhr

    pdhr

    Joined:
    May 13, 2019
    Posts:
    25
    Thanks for the quick reply!

    I get that, but it would be great if the *downloaded* tiles could be placed outside of the binarised .exe build, so more offline tiles can be added post build. My applications does not have guaranteed internet access, that's why I'm relying on offline tiles.

    Thanks for the tip. I am indeed referring to the download assistant. There is no Download Time Out setting as far as I can see. Also, might it be possible to process a direct download from one of these services https://wiki.openstreetmap.org/wiki/Planet.osm#Downloading ? Perhaps by first downloading from one of those sources manually and then directing the tool to the downloaded directory? That way I would not need to send thousands of API request and getting throttled. Some assistance would be greatly appreciated. Thanks!
     
  34. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Yes, that's possible. Use the tile downloader to get your tiles (or use other similar tool) and make them available to your app in a download folder. The filename of the tiles must include the zoom level, x and y, usually in the form of z?_x?_y?.png:


    Then you can use this code in your application:

    Code (CSharp):
    1. ...
    2. // Call this in Start
    3. map.OnTileRequest += Map_OnTileRequest;
    4. ...
    5.  
    6.        private bool Map_OnTileRequest(int zoomLevel, int x, int y, out Texture2D texture, out string error) {
    7.             try {
    8.                 string path = "< full or relative path including the file name with zoom level, x and y plus extension";
    9.                 byte[] bytes = System.IO.File.ReadAllBytes(path);
    10.                 texture = new Texture2D(2, 2, TextureFormat.ARGB32, false);
    11.                 texture.LoadImage(bytes);
    12.                 texture.wrapMode = TextureWrapMode.Clamp;
    13.                 error = null;
    14.                 return true;
    15.             } catch (System.Exception ex) {
    16.                 texture = null;
    17.                 error = ex.ToString();
    18.                 return false;
    19.             }
    20.         }
     
  35. XyrisKenn

    XyrisKenn

    Joined:
    Dec 8, 2015
    Posts:
    91
    Rendering bugs

    Hi - With Enviro (image attached) clouds render in front of the globe. With Overcloud, the globe is highly transparent.

    I've switched to Enviro. Might you recommend which settings to look for, to render the Globe properly in Z-depth (clouds in distance behind globe?
     

    Attached Files:

  36. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Hi,

    Try rendering the globe using a secondary camera which draws after your main camera. That should ensure the globe and all of its elements are drawn on top of any previous rendering, including enviro.
     
    XyrisKenn likes this.
  37. Malkawista

    Malkawista

    Joined:
    Aug 13, 2020
    Posts:
    1
     
  38. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    @Malkawista Hi! Thanks for contacting us. Please join our support forum or Discord (links in the signature) and we can discuss alternatives or adding a new method option.
    Regards
     
    Malkawista likes this.
  39. MatanYamin

    MatanYamin

    Joined:
    Feb 2, 2022
    Posts:
    109
    Hey, I bought your asset and the globe isn't rendering for some reason.
    I'm using Unity 3D URP 2021
    this is what I see:
    upload_2023-5-7_19-34-55.png
     
  40. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
  41. joblo_13

    joblo_13

    Joined:
    Jun 2, 2017
    Posts:
    1
    Hello. When using GoogleMapsSatelliteNoLabels, the higher resolution tiles doesn't load anymore when zooming in. Turn out, the requested tile return a 500 internal error when query. Here is an exemple of a query made by the plugin
    http://khm3.googleapis.com/kh?v=865&hl=en&z=6&x=7&y=20

    I wasn't able to find any information on this API on the internet, so I don't really know if I can change something on my end to make it work, or at least know why the API doesn't work anymore.

    Any ideas?


    Edit: Look like v=946 is working. Maybe the plugin need to be updated because the value is hardcoded
     
    Last edited: May 17, 2023
  42. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,876
    Hi, thanks for the heads up!
    It has been fixed now.

    Although it's rare, some addresses may change in the future - the default server list is fixed but you can create a custom URL choosing "Server" = "Custom" and enter the appropriate link pattern.