Class LocationProviderFactory
Singleton factory to allow easy access to various LocationProviders. This is meant to be attached to a game object.
Inheritance
MonoBehaviour
LocationProviderFactory
Namespace:Mapbox.Unity.Location
Assembly:cs.temp.dll.dll
Syntax
public class LocationProviderFactory : MonoBehaviour
Fields
mapManager
Declaration
public AbstractMap mapManager
Field Value
Type | Description |
---|---|
AbstractMap |
Properties
DefaultLocationProvider
The default location provider. Outside of the editor, this will be a DeviceLocationProvider. In the Unity editor, this will be an EditorLocationProvider
Declaration
public ILocationProvider DefaultLocationProvider { get; set; }
Property Value
Type | Description |
---|---|
ILocationProvider |
Examples
Fetch location to set a transform's position:
void Update()
{
var locationProvider = LocationProviderFactory.Instance.DefaultLocationProvider;
transform.position = Conversions.GeoToWorldPosition(locationProvider.Location,
MapController.ReferenceTileRect.Center,
MapController.WorldScaleFactor).ToVector3xz();
}
DeviceLocationProvider
Returns the serialized DeviceLocationProvider
Declaration
public ILocationProvider DeviceLocationProvider { get; }
Property Value
Type | Description |
---|---|
ILocationProvider |
EditorLocationProvider
Returns the serialized EditorLocationProvider.
Declaration
public ILocationProvider EditorLocationProvider { get; }
Property Value
Type | Description |
---|---|
ILocationProvider |
Instance
Declaration
public static LocationProviderFactory Instance { get; }
Property Value
Type | Description |
---|---|
LocationProviderFactory |
TransformLocationProvider
Returns the serialized TransformLocationProvider.
Declaration
public ILocationProvider TransformLocationProvider { get; }
Property Value
Type | Description |
---|---|
ILocationProvider |
Methods
Awake()
Create singleton instance and inject the DefaultLocationProvider upon initialization of this component.
Declaration
protected virtual void Awake()