Topic: How to know when map has been loaded and drawn?

Hi Guys!
I wanted to know if there is a method or an event that tells me exactly when the map is loaded or completely drawn on the map,
the problem is that on my pc it takes 1 second for example, but on my cell phone it takes 3 seconds, what I need to do is
once fully loaded instantiate markers and do route calculations. I'm using a google custom provider and the map is based on
textures. TY!

Re: How to know when map has been loaded and drawn?

Hello.

Something like:

using System.Collections;
using UnityEngine;

public class CheckFullLoadedExample:MonoBehaviour
{
    private bool isTilesLoaded;
    private bool isRouteFound;
    private IEnumerator timeoutRoutine;

    private void Start()
    {
        OnlineMapsTile.OnAllTilesLoaded += OnAllTilesLoaded;
        OnlineMapsGoogleDirections.Find("Los Angeles", "San Francisco").OnComplete += OnGoogleDirectionsComplete;

        // Time out if something wrong.
        // Strongly recommended.
        timeoutRoutine = FailedTimeout();
        StartCoroutine(timeoutRoutine);
    }

    private IEnumerator FailedTimeout()
    {
        yield return new WaitForSeconds(10);

        Debug.Log("Failed");
    }

    private void OnGoogleDirectionsComplete(string response)
    {
        // Parse response
        // ...

        Debug.Log("Route found");
        isRouteFound = true;
        CheckFullLoaded();
    }

    private void OnAllTilesLoaded()
    {
        Debug.Log("All tiles loaded");
        OnlineMapsTile.OnAllTilesLoaded -= OnAllTilesLoaded;
        isTilesLoaded = true;
        CheckFullLoaded();
    }

    private void CheckFullLoaded()
    {
        if (isRouteFound && isTilesLoaded)
        {
            StopCoroutine(timeoutRoutine);
            Debug.Log("Full loaded");
            OnlineMaps.instance.OnMapUpdated += OnMapUpdated;
            OnlineMaps.instance.Redraw();
        }
    }

    private void OnMapUpdated()
    {
        OnlineMaps.instance.OnMapUpdated -= OnMapUpdated;
        Debug.Log("The map is fully loaded and drawn.");
    }
}
Kind Regards,
Infinity Code Team.

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

Re: How to know when map has been loaded and drawn?

Really thanks Alex!