You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
843 B
33 lines
843 B
namespace Mapbox.Unity.Map
|
|
{
|
|
using System.Collections;
|
|
using Mapbox.Unity.Location;
|
|
using UnityEngine;
|
|
|
|
public class InitializeMapWithLocationProvider : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
AbstractMap _map;
|
|
|
|
ILocationProvider _locationProvider;
|
|
|
|
private void Awake()
|
|
{
|
|
// Prevent double initialization of the map.
|
|
_map.InitializeOnStart = false;
|
|
}
|
|
|
|
protected virtual IEnumerator Start()
|
|
{
|
|
yield return null;
|
|
_locationProvider = LocationProviderFactory.Instance.DefaultLocationProvider;
|
|
_locationProvider.OnLocationUpdated += LocationProvider_OnLocationUpdated; ;
|
|
}
|
|
|
|
void LocationProvider_OnLocationUpdated(Unity.Location.Location location)
|
|
{
|
|
_locationProvider.OnLocationUpdated -= LocationProvider_OnLocationUpdated;
|
|
_map.Initialize(location.LatitudeLongitude, _map.AbsoluteZoom);
|
|
}
|
|
}
|
|
}
|
|
|