Coordinates.cs
Coordinates class is widely used inside by GO Map to wrap GPS coordinates and converting them to and from Vector3 coordinates.
It offers a series of useful methods to work with geographic data, use it if you want to add any Location logic to your app.
This is how you convert a lat lon to vector3 and place objects on map!
Coordinates coordinates = new Coordinates (lat, lng,0);
gameobject.transform.localPosition = coordinates.convertCoordinateToVector(0);
And vice versa, this is how you get a GPS coordinates from a Vector3
Coordinates currentLocation = Coordinates.convertVectorToCoordinates (gameobject.transform.position);
Also from a Coordinate you can always get the center coordinate of the tile it’s contained, given the current zoomlevel:
Coordinates tileCenter = someCoordinate.tileCenter(zoomLevel);
And the tile coordinates (column, row) as well:
Vector2 tileCoords = someCoordinate.tileCoordinates(zoomLevel);
There are many useful methods in the coordinates class, basically anything you need for your GPS based project:
Constructors
public Coordinates (double latitude, double longitude
public Coordinates (double latitude, double longitude, double altitude
public Coordinates (LocationInfo location
public Coordinates (Vector2 tileCoords,int zoom)
public Coordinates (string s)
Conversions
public void updateLocation (LocationInfo location
public float gpsAngle(float longitude_o, float latitude_o)
public float DistanceFromPoint(Coordinates pt)
public double DistanceFromOtherGPSCoordinate (Coordinates targetCoordinates)
public Vector3 convertCoordinateToVector ()
public Vector3 convertCoordinateToVector (float y)
public Vector2 convertCoordinateToVector2D ()
public bool isEqualToCoordinate(Coordinates coordinate
public bool Equals(Coordinates coordinate)
public bool isZeroCoordinates ()
public double intervalBetweenTimestamps (Coordinates coordinate)
TilesCoordinates
public Vector2 tileCoordinates (int zoom)
public Coordinates tileCenter (int zoom)
public Coordinates tileOrigin (int zoom)
public float diagonalLenght (int zoom)
public float tileSize (int zoom)
public List tileVertices (int zoom)
public List adiacentNTiles (int zoom, int buffer
public List subTiles (Vector2 tileCoords)
Utils
public string description ()
public string toLatLongString()
Static
public static Coordinates convertVectorToCoordinates (Vector3 vector)
public static void setWorldOrigin (Coordinates originCoords,float worldScale)
public static Coordinates getWorldOrigin ()
public static double getCurrentTimestamp()