skip to Main Content

Coordinates conversion

The Conversion static class API contains useful methods that convert between map coordinates and lat/lon, as well as distances.

2D Flat Mode

In 2D Flat Mode you can convert from/to local map coordinates to world space coordinates using:

map.transform.TransformPoint(Vector3 local map coordinate)

or

map.transform.InverseTransformPoint( Vector3 world space)

Viewport Mode

In Viewport Mode you have access to: Map2DToWorldPosition, WorldToMap2DPosition and Map2DToRenderViewport methods.

map.Map2DToWorldPosition(position, height, HEIGHT_OFFSET_MODE.ABSOLUTE_CLAMPED

Returns the world position of the given map coordinate. This takes into account the viewport and ground elevation is used, unless you pass -1 to height which will assume absolute 0 height

map.Map2DToWorldPosition(Vector2 position, float height, HEIGHT_OFFSET_MODE heightOffsetMode, bool ignoreViewport)

Returns the world position of the given map coordinate. This takes into account the viewport and ground elevation is used, unless you pass -1 to height which will assume absolute 0 height. If viewport is enabled, you can use the ignoreViewport param to return the flat 2D Map position.

Use heightOffsetMode to position wisely the height:
– Absolute Altitude will return an absolute height irrespective of altitude at map point (it can cross ground)
– Absolute Clamped will return either the ground altitude or the absolute height (the greater value)
– Relative to the ground will simply add the height to the ground altitude

map.Map2DToRenderViewport(Vector2 position)

Returns a 2D coordinate compatible with wrapping mode. For instance, if current render viewport views part of the left-side map on the right side, then the returned coordinate will have an x > 0.5f

map.WorldToMap2DPosition(Vector3 position ...)

Returns a 2D coordinate compatible with wrapping mode from a world position. This method is useful to obtain the map coordinates for any gameobject positioned in space regardless of world-wrapping mode or viewport mode.

GameObjectAnimator

Using the MoveTo() method of the GameObjectAnimator as well as the AddMarker API you can add objects to the map at specific coordinates. Check Demo scene 001_Standalone for a variety of examples.
The currentMap2DLocation property of a GameObjectAnimator returns the current position in map 2d coordinates.
Back To Top