Class AbstractMap
Abstract map.
This is the main monobehavior which controls the map. It controls the visualization of map data.
Abstract map encapsulates the image, terrain and vector sources and provides a centralized interface to control the visualization of the map.
Inheritance
MonoBehaviour
AbstractMap
Namespace:Mapbox.Unity.Map
Assembly:cs.temp.dll.dll
Syntax
public class AbstractMap : MonoBehaviour, IMap
Fields
_cachedPosition
Declaration
protected Vector3 _cachedPosition
Field Value
_cachedRotation
Declaration
protected Quaternion _cachedRotation
Field Value
Type |
Description |
Quaternion |
|
_cachedScale
Declaration
protected Vector3 _cachedScale
Field Value
_centerLatitudeLongitude
Declaration
protected Vector2d _centerLatitudeLongitude
Field Value
Type |
Description |
Vector2d |
|
_centerMercator
Declaration
protected Vector2d _centerMercator
Field Value
Type |
Description |
Vector2d |
|
_currentExtent
Declaration
protected HashSet<UnwrappedTileId> _currentExtent
Field Value
Type |
Description |
HashSet<UnwrappedTileId> |
|
_fileSource
Declaration
protected MapboxAccess _fileSource
Field Value
_imagery
Declaration
protected ImageryLayer _imagery
Field Value
_initialZoom
Declaration
protected int _initialZoom
Field Value
Type |
Description |
System.Int32 |
|
_mapScaleFactor
Declaration
protected Vector3 _mapScaleFactor
Field Value
_mapVisualizer
Declaration
protected AbstractMapVisualizer _mapVisualizer
Field Value
_previewOptions
Declaration
protected EditorPreviewOptions _previewOptions
Field Value
_terrain
Declaration
protected TerrainLayer _terrain
Field Value
_tileProvider
Declaration
protected AbstractTileProvider _tileProvider
Field Value
Type |
Description |
AbstractTileProvider |
|
_unityTileSize
Declaration
protected float _unityTileSize
Field Value
Type |
Description |
System.Single |
|
_vectorData
Declaration
protected VectorLayer _vectorData
Field Value
_worldHeightFixed
Declaration
protected bool _worldHeightFixed
Field Value
Type |
Description |
System.Boolean |
|
_worldRelativeScale
Declaration
protected float _worldRelativeScale
Field Value
Type |
Description |
System.Single |
|
Properties
AbsoluteZoom
Gets the absolute zoom of the tiles being currently rendered.
Zoom
Declaration
public int AbsoluteZoom { get; }
Property Value
Type |
Description |
System.Int32 |
The absolute zoom.
|
CenterLatitudeLongitude
Declaration
public Vector2d CenterLatitudeLongitude { get; }
Property Value
Type |
Description |
Vector2d |
|
CenterMercator
Declaration
public Vector2d CenterMercator { get; }
Property Value
Type |
Description |
Vector2d |
|
CurrentExtent
Declaration
public HashSet<UnwrappedTileId> CurrentExtent { get; }
Property Value
Type |
Description |
HashSet<UnwrappedTileId> |
|
ExtentCalculatorType
Declaration
public Type ExtentCalculatorType { get; }
Property Value
Type |
Description |
System.Type |
|
ImageLayer
Options to control the imagery component of the map.
Declaration
[NodeEditorElement("Layers")]
public IImageryLayer ImageLayer { get; }
Property Value
InitializeOnStart
Setting to trigger map initialization in Unity's Start method.
if set to false, Initialize method should be called explicitly to initialize the map.
Declaration
public bool InitializeOnStart { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
InitialZoom
Gets the initial zoom at which the map was initialized.
This parameter is useful in calculating the scale of the tiles and the map.
Declaration
public int InitialZoom { get; }
Property Value
Type |
Description |
System.Int32 |
The initial zoom.
|
IsAccessTokenValid
Declaration
public bool IsAccessTokenValid { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsEditorPreviewEnabled
Declaration
public bool IsEditorPreviewEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
LoadingTexture
Gets the loading texture used as a placeholder while the image tile is loading.
Declaration
public Texture2D LoadingTexture { get; }
Property Value
Type |
Description |
Texture2D |
The loading texture.
|
MapVisualizer
Declaration
public AbstractMapVisualizer MapVisualizer { get; set; }
Property Value
Options
The map options.
Options to control the behaviour of the map like location,extent, scale and placement.
Declaration
public MapOptions Options { get; set; }
Property Value
Root
Declaration
public Transform Root { get; }
Property Value
Type |
Description |
Transform |
|
Terrain
Options to control the terrain/ elevation component of the map.
Declaration
[NodeEditorElement("Layers")]
public ITerrainLayer Terrain { get; }
Property Value
TileMaterial
Gets the tile material used for map tiles.
Declaration
public Material TileMaterial { get; }
Property Value
Type |
Description |
Material |
The tile material.
|
TileProvider
Declaration
public AbstractTileProvider TileProvider { get; set; }
Property Value
Type |
Description |
AbstractTileProvider |
|
UnityTileSize
Declaration
public float UnityTileSize { get; }
Property Value
Type |
Description |
System.Single |
|
VectorData
The vector data.
Options to control the vector data component of the map.
Adds a vector source and visualizers to define the rendering behaviour of vector data layers.
Declaration
[NodeEditorElement("Layers")]
public IVectorDataLayer VectorData { get; }
Property Value
WorldRelativeScale
Declaration
public float WorldRelativeScale { get; }
Property Value
Type |
Description |
System.Single |
|
Zoom
Gets the current zoom value of the map.
Use AbsoluteZoom
to get the zoom level of the tileset.
AbsoluteZoom
Declaration
public float Zoom { get; }
Property Value
Type |
Description |
System.Single |
The zoom.
|
Methods
Awake()
Declaration
protected virtual void Awake()
DestroyChildObjects()
Declaration
public void DestroyChildObjects()
DestroyTileProvider()
Declaration
public void DestroyTileProvider()
DisableEditorPreview()
Declaration
public void DisableEditorPreview()
EnableEditorPreview()
Declaration
public void EnableEditorPreview()
GeoToWorldPosition(Vector2d, Boolean)
Converts a latitude longitude into map space position.
Declaration
public virtual Vector3 GeoToWorldPosition(Vector2d latitudeLongitude, bool queryHeight = true)
Parameters
Type |
Name |
Description |
Vector2d |
latitudeLongitude |
Latitude longitude.
|
System.Boolean |
queryHeight |
If set to true will return the terrain height(in Unity units) at that point.
|
Returns
Type |
Description |
Vector3 |
Position in map space.
|
Initialize(Vector2d, Int32)
Initialize the map using the specified latLon and zoom.
Map will automatically get initialized in the Start
method.
Use this method to explicitly initialize the map and disable intialize on Start
Declaration
public virtual void Initialize(Vector2d latLon, int zoom)
Parameters
Type |
Name |
Description |
Vector2d |
latLon |
Lat lon.
|
System.Int32 |
zoom |
Zoom.
|
InitializeMap(MapOptions)
Initializes the map using the mapOptions.
Declaration
protected virtual void InitializeMap(MapOptions options)
Parameters
OnDestroy()
Declaration
protected virtual void OnDestroy()
QueryElevationAtInternal(Vector2d, out Single)
Declaration
protected virtual float QueryElevationAtInternal(Vector2d latlong, out float tileScale)
Parameters
Type |
Name |
Description |
Vector2d |
latlong |
|
System.Single |
tileScale |
|
Returns
Type |
Description |
System.Single |
|
QueryElevationInMetersAt(Vector2d)
Queries the real world elevation data in Meters at a given latitude longitude.
Declaration
public virtual float QueryElevationInMetersAt(Vector2d latlong)
Parameters
Type |
Name |
Description |
Vector2d |
latlong |
Latlong.
|
Returns
Type |
Description |
System.Single |
The height data.
|
QueryElevationInUnityUnitsAt(Vector2d)
Queries the real world elevation data in Unity units at a given latitude longitude.
Declaration
public virtual float QueryElevationInUnityUnitsAt(Vector2d latlong)
Parameters
Type |
Name |
Description |
Vector2d |
latlong |
Latlong.
|
Returns
Type |
Description |
System.Single |
The height data.
|
ResetMap()
Resets the map.
Use this method to reset the map.
Declaration
SendInitialized()
Declaration
protected void SendInitialized()
SetCenterLatitudeLongitude(Vector2d)
Declaration
public virtual void SetCenterLatitudeLongitude(Vector2d centerLatitudeLongitude)
Parameters
Type |
Name |
Description |
Vector2d |
centerLatitudeLongitude |
|
SetCenterMercator(Vector2d)
Declaration
public virtual void SetCenterMercator(Vector2d centerMercator)
Parameters
Type |
Name |
Description |
Vector2d |
centerMercator |
|
SetExtent(MapExtentType, ExtentOptions)
Sets the extent type and parameters to control the maps extent.
Declaration
public virtual void SetExtent(MapExtentType extentType, ExtentOptions extentOptions = null)
Parameters
SetExtentOptions(ExtentOptions)
Set parameters for current extent calculator strategy.
Declaration
public virtual void SetExtentOptions(ExtentOptions extentOptions)
Parameters
Type |
Name |
Description |
ExtentOptions |
extentOptions |
Parameters to control the map extent.
|
SetLoadingTexture(Texture2D)
Declaration
public virtual void SetLoadingTexture(Texture2D loadingTexture)
Parameters
Type |
Name |
Description |
Texture2D |
loadingTexture |
|
SetPlacementType(MapPlacementType)
Sets the positions of the map's root transform.
Use placementType = MapPlacementType.AtTileCenter
to place map root at the center of tile containing the latitude,longitude.
Use placementType = MapPlacementType.AtLocationCenter
to place map root at the latitude,longitude.
Declaration
public virtual void SetPlacementType(MapPlacementType placementType)
Parameters
SetTileMaterial(Material)
Declaration
public virtual void SetTileMaterial(Material tileMaterial)
Parameters
Type |
Name |
Description |
Material |
tileMaterial |
|
SetupAccess()
Declaration
protected IEnumerator SetupAccess()
Returns
Type |
Description |
System.Collections.IEnumerator |
|
SetUpMap()
Sets up map.
This method uses the mapOptions and layer properties to setup the map to be rendered.
Override SetUpMap
to write custom behavior to map setup.
Declaration
protected virtual void SetUpMap()
SetWorldRelativeScale(Single)
Declaration
public virtual void SetWorldRelativeScale(float scale)
Parameters
Type |
Name |
Description |
System.Single |
scale |
|
SetZoom(Single)
Declaration
public void SetZoom(float zoom)
Parameters
Type |
Name |
Description |
System.Single |
zoom |
|
SnapMapToZero(Boolean)
Translates map root by the terrain elevation at the center geo location.
Use this method with TerrainWithElevation
Declaration
public virtual void SnapMapToZero(bool active)
Parameters
Type |
Name |
Description |
System.Boolean |
active |
If set to true active.
|
Start()
Declaration
protected virtual void Start()
TileProvider_OnTileAdded(UnwrappedTileId)
Declaration
protected virtual void TileProvider_OnTileAdded(UnwrappedTileId tileId)
Parameters
Type |
Name |
Description |
UnwrappedTileId |
tileId |
|
TileProvider_OnTileRemoved(UnwrappedTileId)
Declaration
protected virtual void TileProvider_OnTileRemoved(UnwrappedTileId tileId)
Parameters
Type |
Name |
Description |
UnwrappedTileId |
tileId |
|
TileProvider_OnTileRepositioned(UnwrappedTileId)
Declaration
protected virtual void TileProvider_OnTileRepositioned(UnwrappedTileId tileId)
Parameters
Type |
Name |
Description |
UnwrappedTileId |
tileId |
|
Update()
Declaration
protected virtual void Update()
UpdateMap()
Declaration
public virtual void UpdateMap()
UpdateMap(Single)
Declaration
public virtual void UpdateMap(float zoom)
Parameters
Type |
Name |
Description |
System.Single |
zoom |
|
UpdateMap(Vector2d)
Declaration
public virtual void UpdateMap(Vector2d latLon)
Parameters
Type |
Name |
Description |
Vector2d |
latLon |
|
UpdateMap(Vector2d, Single)
Updates the map.
Use this method to update the location of the map.
Update method should be used when panning, zooming or changing location of the map.
This method avoid startup delays that might occur on re-initializing the map.
Declaration
public virtual void UpdateMap(Vector2d latLon, float zoom)
Parameters
Type |
Name |
Description |
Vector2d |
latLon |
LatitudeLongitude.
|
System.Single |
zoom |
Zoom level.
|
UseCustomScale(Single)
Sets the map to use custom scale for map tiles.
Declaration
public virtual void UseCustomScale(float tileSizeInUnityUnits)
Parameters
Type |
Name |
Description |
System.Single |
tileSizeInUnityUnits |
Tile size in unity units to scale each Web Mercator tile.
|
UseWorldScale()
Sets the map to use real world scale for map tile.
Use world scale for AR use cases or applications that need true world scale.
Declaration
public virtual void UseWorldScale()
WorldToGeoPosition(Vector3)
Converts a position in map space into a laitude longitude.
Declaration
public virtual Vector2d WorldToGeoPosition(Vector3 realworldPoint)
Parameters
Type |
Name |
Description |
Vector3 |
realworldPoint |
Realworld point.
|
Returns
Type |
Description |
Vector2d |
Position in Latitude longitude.
|
Events
OnEditorPreviewDisabled
Event delegate, gets called when map preview is disabled
Declaration
public event Action OnEditorPreviewDisabled
Event Type
Type |
Description |
System.Action |
|
OnEditorPreviewEnabled
Event delegate, gets called when map preview is enabled
Declaration
public event Action OnEditorPreviewEnabled
Event Type
Type |
Description |
System.Action |
|
OnInitialized
Event delegate, gets called after map is initialized
OnUpdated
Declaration
public event Action OnInitialized
Event Type
Type |
Description |
System.Action |
|
OnMapRedrawn
Declaration
public event Action OnMapRedrawn
Event Type
Type |
Description |
System.Action |
|
OnTileFinished
Event delegate, gets called when a tile is completed.
Declaration
public event Action<UnityTile> OnTileFinished
Event Type
OnTilesDisposing
Event delegate, gets called before a tile is getting recycled.
Declaration
public event Action<List<UnwrappedTileId>> OnTilesDisposing
Event Type
Type |
Description |
System.Action<System.Collections.Generic.List<UnwrappedTileId>> |
|
OnTilesStarting
Event delegate, gets called when new tiles coordinates are registered.
Declaration
public event Action<List<UnwrappedTileId>> OnTilesStarting
Event Type
Type |
Description |
System.Action<System.Collections.Generic.List<UnwrappedTileId>> |
|
OnUpdated
Event delegate, gets called after map is updated.
UpdateMap
will trigger this event.
OnInitialized
Declaration
public event Action OnUpdated
Event Type
Type |
Description |
System.Action |
|