Class LatLng

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(latitude: number, longitude: number): LatLng

Creates an object representing a geographical point with the given latitude and longitude.

Parameters

  • latitude: number
  • longitude: number

Returns

LatLng

constructor(coords: Array<number>): LatLng

Creates an object representing a geographical point with the given latitude and longitude.

Parameters

  • coords: Array<number>

Returns

LatLng

Properties

public static DEG_TO_RAD: number

A multiplier for converting degrees into radians.

Value: Math.PI / 180.

public static MAX_MARGIN: number

Max margin of error for the equality check.

Value: 1.0E-9.

public static RAD_TO_DEG: number

A multiplier for converting radians into degrees.

Value: 180 / Math.PI.

public lat: number

Latitude in degrees.

public lng: number

Longitude in degrees.

Methods

public distanceTo(otherLatlng: LatLng): number

Returns the distance (in meters) to the given LatLng calculated using the Haversine formula. See description on wikipedia

Parameters

Returns

number

public equals(otherLatlng: LatLng): boolean

Returns true if the given LatLng point is at the same position (within a small margin of error).

Parameters

Returns

boolean

public toString(): string

Returns a string representation of the point (for debugging purposes).

Returns

string

public wrap(left: number, right: number): LatLng

Returns a new LatLng object with the longitude wrapped around left and right boundaries (-180 to 180 by default).

Parameters

  • left: number
  • right: number

Returns

LatLng