Topic: Unity space to world space + inverse
How can I go from Unity coordinates to real world coordinates and vice versa?
For example I want to create 1000 gameobjects and I need them to be at Lat Lng 51,-1.
You are not logged in. Please login or register.
Infinity Code Forum → Online Maps Help → Unity space to world space + inverse
How can I go from Unity coordinates to real world coordinates and vice versa?
For example I want to create 1000 gameobjects and I need them to be at Lat Lng 51,-1.
Hello.
OnlineMapsControlBase.GetScreenPosition:
Geographical coordinate to screen space.
http://infinity-code.com/doxygen/online … c82e3a5f04
OnlineMapsControlBase.GetCoords:
Screen space to geographical coordinates.
http://infinity-code.com/doxygen/online … b99f610155
OnlineMapsControlBase.GetPosition:
Converts geographical coordinate to position in the scene relative to the top-left corner of the map in map space.
http://infinity-code.com/doxygen/online … 0028781fe8
OnlineMapsTileSetControl.GetCoordsByWorldPosition:
Returns the geographical coordinates by world position.
http://infinity-code.com/doxygen/online … 7316430ad9
OnlineMapsTileSetControl.GetWorldPosition:
Converts geographical coordinates to position in world space.
http://infinity-code.com/doxygen/online … ea663abc1f
OnlineMapsTileSetControl.GetWorldPositionWithElevation:
Converts geographical coordinates to position in world space with elevation.
http://infinity-code.com/doxygen/online … 3632bad690
Consider: https://en.wikipedia.org/wiki/Decimal_degrees
Is there a double implementation? I would like centimeter level accuracy.
Yes, almost every method (where necessary) has an overload double precision.
I don't see the double implementation for these methods.
bool OnlineMapsControlBase.GetCoords (out double lng, out double lat, Vector2 position)
http://infinity-code.com/doxygen/online … 4fd5a5a0e1
bool OnlineMapsTileSetControl.GetCoordsByWorldPosition (out double lng, out double lat, Vector3 position)
http://infinity-code.com/doxygen/online … 1b58011257
Online Maps v2.3 beta (available through the built-in update):
void OnlineMapsControlBase.GetPosition(double lng, double lat, out double px, out double py)
Vector2 OnlineMapsControlBase.GetScreenPosition(double lng, double lat)
Vector3 OnlineMapsTileSetControl.GetWorldPosition(double lng, double lat)
Vector3 OnlineMapsTileSetControl.GetWorldPositionWithElevation(double lng, double lat, double tlx, double tly, double brx, double bry)
I am trying this with the tile example, trying to put in a gameobject around Brisbane.
GameObject newEntity = null;
newEntity = GameObject.Instantiate(pedTemplate);
var unityPosition = OnlineMapsControlBase.instance.GetScreenPosition(new Vector2(-27.52188f, 153.0187f));
newEntity.transform.position = unityPosition;
and
newEntity.transform.position = new Vector3(unityPosition.x, 0, unityPosition.y);
Its not putting the object in the correct place.
new Vector2 (-27.52188f, 153.0187f)
It's wrong. X - longitude, Y - latitude.
newEntity.transform.position = unityPosition;
Screen space is not equal World space.
No matter what you are using GUI, uGUI, Tileset.
It is always wrong.
For tileset use GetWorldPosition.
For the other controls: you need to convert screen position to world position.
Infinity Code Forum → Online Maps Help → Unity space to world space + inverse
Powered by PunBB, supported by Informer Technologies, Inc.