Topic: Know when OnlineMaps fully loaded texture

Hello,

I was working on a project that uses Online Maps to load OnlineMaps Tileset given world coordinates to take pictures with Render Cameras setup in my Unity scene.

My main issue is that I need to wait for the Map texture to be fully loaded (not partially or not loaded with grey colour displayed) and take 3 pictures for different camera rects, but I cannot find the correct event that tells me when the OnlineMaps texture is fully loaded.

I tried:
OnlineMaps.OnMapUpdated
OnlineMapsTileManager.OnTileLoaded
OnlineMapsTile.OnAllTilesLoaded

But none served me since they triggered but the texture was not ready. I also tried this solution:
https://infinity-code.com/atlas/online- … STile.html
But seems that I am working with a OnlineMaps TileSet, so this is not valid to check full map texture.

I tried using async methods with unity but sometimes it takes the wrong picture since the map texture loading time may vary.

Could you please help me on this matter? My purpose is to create some kind of coroutine to  check everytime the map texture is fully loaded to take the picture, redraw map, take second picture, redraw,...

Best regards!

Re: Know when OnlineMaps fully loaded texture

Hello.

OnlineMapsTile.OnAllTilesLoaded is called when all tiles are loaded, but before the map has been redrawn.
So when OnAllTilesLoaded is called subscribe to OnlineMaps.OnMapUpdated and take your screenshots in that event.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Know when OnlineMaps fully loaded texture

Alex Vertax wrote:

Hello.

OnlineMapsTile.OnAllTilesLoaded is called when all tiles are loaded, but before the map has been redrawn.
So when OnAllTilesLoaded is called subscribe to OnlineMaps.OnMapUpdated and take your screenshots in that event.

Hi! First of all thank you for answering.

I tried what you suggested but OnlineMapsTile.OnAllTilesLoaded is not being called when I set up coordinates with  m_mapTile.map.SetPositionAndZoom(long, lat, zoom). It only triggers when I change the coordinates drastically through editor.

Is there any way to force all tiles to load after setting coordinates and zoom?

Thank you,
BR.

Re: Know when OnlineMaps fully loaded texture

I made a simple script to test it:

using UnityEngine;

public class TestAllTilesLoaded : MonoBehaviour
{
    private void OnGUI()
    {
        if (GUILayout.Button("Randomize"))
        {
            double lng = Random.Range(-180f, 180f);
            double lat = Random.Range(-80, 80);
            float zoom = Random.Range(3f, 10f);
            OnlineMaps.instance.SetPositionAndZoom(lng, lat, zoom);
        }
    }

    private void Start()
    {
        OnlineMapsTile.OnAllTilesLoaded += OnAllTilesLoaded;
    }

    private void OnAllTilesLoaded()
    {
        Debug.Log("OnAllTilesLoaded");
        OnlineMaps.instance.OnMapUpdated += OnMapUpdated;
    }

    private void OnMapUpdated()
    {
        Debug.Log("OnMapUpdated");
        OnlineMaps.instance.OnMapUpdated -= OnMapUpdated;
    }
}

Here is a video of the result:
https://www.dropbox.com/s/gtd6bdee7wlus … d.mp4?dl=0
As you can see the events are being called.

Maybe in your case you change the location in such a way that you still have all the tiles loaded?!
After changing the position, subscribe to OnlineMaps.OnLateUpdateAfter, loop through all the tiles (OnlineMapsTileManager.tiles) and check their status.
If all of them are already loaded, then OnAllTilesLoaded will not be called, since nothing was loaded.
In this case, you don't have to wait for this event and can simply perform your actions.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Know when OnlineMaps fully loaded texture

Hi Alex,

First of all, thank you for taking the time to elaborate the video and script. Very welcome!

As you suggested, my script was not changing map coordinates drastically, so OnlineMapsTile.OnAllTilesLoaded was not being called. At that point I just take the pictures in OnMapUpdated as it is. It is also valid if I change map provider, so covers everything!

Thank you!
BR.