Online Maps  v3.0
OnlineMapsUtils Class Reference

Helper class, which contains all the basic methods. More...

Static Public Member Functions

static float Angle2D (Vector2 point1, Vector2 point2)
 The angle between the two points in degree. More...
 
static float Angle2D (Vector3 point1, Vector3 point2)
 The angle between the two points in degree. More...
 
static double Angle2D (double p1x, double p1y, double p2x, double p2y)
 The angle between the two points in degree. More...
 
static float Angle2D (Vector3 point1, Vector3 point2, Vector3 point3, bool unsigned=true)
 The angle between the three points in degree. More...
 
static float Angle2DRad (Vector3 point1, Vector3 point2, float offset=0)
 The angle between the two points in radians. More...
 
static float Angle2DRad (float p1x, float p1z, float p2x, float p2z, float offset=0)
 The angle between the two points in radians. More...
 
static double Clip (double n, double minValue, double maxValue)
 Clamps a value between a minimum double and maximum double value. More...
 
static List< Vector2 > DecodePolylinePoints (string encodedPoints)
 Converts Polyline to point list. More...
 
static List< OnlineMapsVector2dDecodePolylinePointsD (string encodedPoints)
 Converts Polyline to point list. More...
 
static void Destroy (UnityEngine.Object obj)
 Removes a gameobject, component or asset. More...
 
static void DestroyImmediate (UnityEngine.Object obj)
 Removes a gameobject, component or asset. More...
 
static Vector2 DistanceBetweenPoints (Vector2 point1, Vector2 point2)
 The distance between two geographical coordinates. More...
 
static void DistanceBetweenPoints (double x1, double y1, double x2, double y2, out double dx, out double dy)
 The distance between two geographical coordinates. More...
 
static void DistanceBetweenPoints (double x1, double y1, float a1, double x2, double y2, float a2, out double dx, out double dy)
 The distance between two geographical coordinates with altitude. More...
 
static double DistanceBetweenPoints (IEnumerable points, out double dx, out double dy)
 The distance between geographical coordinates. More...
 
static double DistanceBetweenPointsD (Vector2 point1, Vector2 point2)
 The distance between two geographical coordinates. More...
 
static Vector2 FixAngle (Vector2 v)
 Fix geographic coordinates. More...
 
static void FlipNegative (ref Rect r)
 Flip the negative dimensions of the rect. More...
 
static void GetCenterPointAndZoom (OnlineMapsMarkerBase[] markers, out Vector2 center, out int zoom)
 Get the center point and best zoom for the array of markers. More...
 
static void GetCenterPointAndZoom (Vector2[] positions, out Vector2 center, out int zoom)
 Get the center point and best zoom for the array of coordinates. More...
 
static void GetCoordinateInDistance (double lng, double lat, float distance, float angle, out double nlng, out double nlat)
 Given a start point, angle and distance, this will calculate the destina­tion point travelling along a (shortest distance) great circle arc. More...
 
static OnlineMapsWWW GetWWW (string url)
 Gets Webplayes safe URL. More...
 
static OnlineMapsWWW GetWWW (StringBuilder url)
 Gets Webplayes safe URL. More...
 
static Color HexToColor (string hex)
 Converts HEX string to color. More...
 
static Vector2 LatLongToMercat (float x, float y)
 Converts geographic coordinates to Mercator coordinates. More...
 
static void LatLongToMercat (ref float x, ref float y)
 Converts geographic coordinates to Mercator coordinates. More...
 
static void LatLongToMercat (ref double x, ref double y)
 Converts geographic coordinates to Mercator coordinates. More...
 
static double Magnitude (double p1x, double p1y, double p2x, double p2y)
 Returns the length of vector. More...
 
static string TileToQuadKey (int x, int y, int zoom)
 Converts tile index to quadkey. What is the tiles and quadkey, and how it works, you can read here: http://msdn.microsoft.com/en-us/library/bb259689.aspx More...
 

Public Attributes

const float angleSecond = 1 / 3600f
 Arcseconds in meters. More...
 
const int maxRaycastDistance = 100000
 Maximal distance of raycast. More...
 
const double R = 6371
 Earth radius. More...
 
const double Deg2Rad = Math.PI / 180
 Degrees-to-radians conversion constant. More...
 
const double Rad2Deg = 180 / Math.PI
 Radians-to-degrees conversion constant. More...
 
const int mb = 1024 * 1024
 Bytes per megabyte. More...
 
const float pi4 = 4 * Mathf.PI
 PI * 4 More...
 
const short tileSize = 256
 Size of the tile texture in pixels. More...
 
const long second = 10000000
 The second in ticks. More...
 
const int sqrTileSize = tileSize * tileSize
 tileSize squared, to accelerate the calculations. More...
 

Static Public Attributes

static Func< string, OnlineMapsWWWOnGetWWW
 Intercepts requests to download and allows you to create a custom query behavior. More...
 

Detailed Description

Helper class, which contains all the basic methods.

Member Function Documentation

◆ Angle2D() [1/4]

static float OnlineMapsUtils.Angle2D ( Vector2  point1,
Vector2  point2 
)
static

The angle between the two points in degree.

Parameters
point1Point 1
point2Point 2
Returns
Angle in degree

◆ Angle2D() [2/4]

static float OnlineMapsUtils.Angle2D ( Vector3  point1,
Vector3  point2 
)
static

The angle between the two points in degree.

Parameters
point1Point 1
point2Point 2
Returns
Angle in degree

◆ Angle2D() [3/4]

static double OnlineMapsUtils.Angle2D ( double  p1x,
double  p1y,
double  p2x,
double  p2y 
)
static

The angle between the two points in degree.

Parameters
p1xPoint 1 X
p1yPoint 1 Y
p2xPoint 2 X
p2yPoint 2 Y
Returns
Angle in degree

◆ Angle2D() [4/4]

static float OnlineMapsUtils.Angle2D ( Vector3  point1,
Vector3  point2,
Vector3  point3,
bool  unsigned = true 
)
static

The angle between the three points in degree.

Parameters
point1Point 1
point2Point 2
point3Point 3
unsignedReturn a positive result.
Returns
Angle in degree

◆ Angle2DRad() [1/2]

static float OnlineMapsUtils.Angle2DRad ( Vector3  point1,
Vector3  point2,
float  offset = 0 
)
static

The angle between the two points in radians.

Parameters
point1Point 1
point2Point 2
offsetResult offset in degrees.
Returns
Angle in radians

◆ Angle2DRad() [2/2]

static float OnlineMapsUtils.Angle2DRad ( float  p1x,
float  p1z,
float  p2x,
float  p2z,
float  offset = 0 
)
static

The angle between the two points in radians.

Parameters
p1xPoint 1 X
p1zPoint 1 Z
p2xPoint 2 X
p2zPoint 2 Z
offsetResult offset in degrees.
Returns
Angle in radians

◆ Clip()

static double OnlineMapsUtils.Clip ( double  n,
double  minValue,
double  maxValue 
)
static

Clamps a value between a minimum double and maximum double value.

Parameters
nValue
minValueMinimum
maxValueMaximum
Returns
Value between a minimum and maximum.

◆ DecodePolylinePoints()

static List<Vector2> OnlineMapsUtils.DecodePolylinePoints ( string  encodedPoints)
static

Converts Polyline to point list.

Parameters
encodedPointsThe encoded polyline.
Returns
A List of Vector2 points;

◆ DecodePolylinePointsD()

static List<OnlineMapsVector2d> OnlineMapsUtils.DecodePolylinePointsD ( string  encodedPoints)
static

Converts Polyline to point list.

Parameters
encodedPointsThe encoded polyline.
Returns
A List of Vector2 points;

◆ Destroy()

static void OnlineMapsUtils.Destroy ( UnityEngine.Object  obj)
static

Removes a gameobject, component or asset.

Parameters
objThe object to destroy.

◆ DestroyImmediate()

static void OnlineMapsUtils.DestroyImmediate ( UnityEngine.Object  obj)
static

Removes a gameobject, component or asset.

Parameters
objThe object to destroy.

◆ DistanceBetweenPoints() [1/4]

static Vector2 OnlineMapsUtils.DistanceBetweenPoints ( Vector2  point1,
Vector2  point2 
)
static

The distance between two geographical coordinates.

Parameters
point1Coordinate (X - Lng, Y - Lat)
point2Coordinate (X - Lng, Y - Lat)
Returns
Distance (km).

◆ DistanceBetweenPoints() [2/4]

static void OnlineMapsUtils.DistanceBetweenPoints ( double  x1,
double  y1,
double  x2,
double  y2,
out double  dx,
out double  dy 
)
static

The distance between two geographical coordinates.

Parameters
x1Longitude 1.
y1Latitude 1.
x2Longitude 2.
y2Latitude 2.
dxDistance longitude (km).
dyDistance latitude (km).

◆ DistanceBetweenPoints() [3/4]

static void OnlineMapsUtils.DistanceBetweenPoints ( double  x1,
double  y1,
float  a1,
double  x2,
double  y2,
float  a2,
out double  dx,
out double  dy 
)
static

The distance between two geographical coordinates with altitude.

Parameters
x1Longitude 1
y1Latitude 1
a1Altutude 1 (km).
x2Longitude 2
y2Latitude 2
a2Altitude 2 (km)
dxDistance longitude (km)
dyDistance latitude (km)

◆ DistanceBetweenPoints() [4/4]

static double OnlineMapsUtils.DistanceBetweenPoints ( IEnumerable  points,
out double  dx,
out double  dy 
)
static

The distance between geographical coordinates.

Parameters
pointsIEnumerate of double, float, Vector2 or Vector3
dxDistance longitude (km).
dyDistance latitude (km).
Returns
Distance (km).

◆ DistanceBetweenPointsD()

static double OnlineMapsUtils.DistanceBetweenPointsD ( Vector2  point1,
Vector2  point2 
)
static

The distance between two geographical coordinates.

Parameters
point1Coordinate (X - Lng, Y - Lat)
point2Coordinate (X - Lng, Y - Lat)
Returns
Distance (km).

◆ FixAngle()

static Vector2 OnlineMapsUtils.FixAngle ( Vector2  v)
static

Fix geographic coordinates.

Parameters
vCoordinates for fix.
Returns
Correct geographic coordinates.

◆ FlipNegative()

static void OnlineMapsUtils.FlipNegative ( ref Rect  r)
static

Flip the negative dimensions of the rect.

Parameters
rRect.

◆ GetCenterPointAndZoom() [1/2]

static void OnlineMapsUtils.GetCenterPointAndZoom ( OnlineMapsMarkerBase []  markers,
out Vector2  center,
out int  zoom 
)
static

Get the center point and best zoom for the array of markers.

Parameters
markersArray of markers.
centerCenter point.
zoomBest zoom.

◆ GetCenterPointAndZoom() [2/2]

static void OnlineMapsUtils.GetCenterPointAndZoom ( Vector2 []  positions,
out Vector2  center,
out int  zoom 
)
static

Get the center point and best zoom for the array of coordinates.

Parameters
positionsArray of coordinates
centerCenter coordinate
zoomBest zoom

◆ GetCoordinateInDistance()

static void OnlineMapsUtils.GetCoordinateInDistance ( double  lng,
double  lat,
float  distance,
float  angle,
out double  nlng,
out double  nlat 
)
static

Given a start point, angle and distance, this will calculate the destina­tion point travelling along a (shortest distance) great circle arc.

Parameters
lngLongitude of start point
latLatitude of start point
distanceDistance (km)
angleAngle, clockwise from north (degree)
nlngLongitude of destination point
nlatLatitude of destination point

◆ GetWWW() [1/2]

static OnlineMapsWWW OnlineMapsUtils.GetWWW ( string  url)
static

Gets Webplayes safe URL.

Parameters
urlOriginal URL.
Returns
Webplayer safe URL.

◆ GetWWW() [2/2]

static OnlineMapsWWW OnlineMapsUtils.GetWWW ( StringBuilder  url)
static

Gets Webplayes safe URL.

Parameters
urlOriginal URL.
Returns
Webplayer safe URL.

◆ HexToColor()

static Color OnlineMapsUtils.HexToColor ( string  hex)
static

Converts HEX string to color.

Parameters
hexHEX string
Returns
Color

◆ LatLongToMercat() [1/3]

static Vector2 OnlineMapsUtils.LatLongToMercat ( float  x,
float  y 
)
static

Converts geographic coordinates to Mercator coordinates.

Parameters
xLongitude
yLatitude
Returns
Mercator coordinates

◆ LatLongToMercat() [2/3]

static void OnlineMapsUtils.LatLongToMercat ( ref float  x,
ref float  y 
)
static

Converts geographic coordinates to Mercator coordinates.

Parameters
xLongitude
yLatitude

◆ LatLongToMercat() [3/3]

static void OnlineMapsUtils.LatLongToMercat ( ref double  x,
ref double  y 
)
static

Converts geographic coordinates to Mercator coordinates.

Parameters
xLongitude
yLatitude

◆ Magnitude()

static double OnlineMapsUtils.Magnitude ( double  p1x,
double  p1y,
double  p2x,
double  p2y 
)
static

Returns the length of vector.

Parameters
p1xPoint 1 X
p1yPoint 1 Y
p2xPoint 2 X
p2yPoint 2 Y
Returns
Length of vector

◆ TileToQuadKey()

static string OnlineMapsUtils.TileToQuadKey ( int  x,
int  y,
int  zoom 
)
static

Converts tile index to quadkey. What is the tiles and quadkey, and how it works, you can read here: http://msdn.microsoft.com/en-us/library/bb259689.aspx

Parameters
xTile X
yTile Y
zoomZoom
Returns
Quadkey

Member Data Documentation

◆ angleSecond

const float OnlineMapsUtils.angleSecond = 1 / 3600f

Arcseconds in meters.

◆ Deg2Rad

const double OnlineMapsUtils.Deg2Rad = Math.PI / 180

Degrees-to-radians conversion constant.

◆ maxRaycastDistance

const int OnlineMapsUtils.maxRaycastDistance = 100000

Maximal distance of raycast.

◆ mb

const int OnlineMapsUtils.mb = 1024 * 1024

Bytes per megabyte.

◆ OnGetWWW

Func<string, OnlineMapsWWW> OnlineMapsUtils.OnGetWWW
static

Intercepts requests to download and allows you to create a custom query behavior.

◆ pi4

const float OnlineMapsUtils.pi4 = 4 * Mathf.PI

PI * 4

◆ R

const double OnlineMapsUtils.R = 6371

Earth radius.

◆ Rad2Deg

const double OnlineMapsUtils.Rad2Deg = 180 / Math.PI

Radians-to-degrees conversion constant.

◆ second

const long OnlineMapsUtils.second = 10000000

The second in ticks.

◆ sqrTileSize

const int OnlineMapsUtils.sqrTileSize = tileSize * tileSize

tileSize squared, to accelerate the calculations.

◆ tileSize

const short OnlineMapsUtils.tileSize = 256

Size of the tile texture in pixels.