Options
All
  • Public
  • Public/Protected
  • All
Menu

A LatLng is a point in geographical coordinates: latitude and longitude.

  • Latitude ranges between -90 and 90 degrees, inclusive. Values above or below this range will be clamped to the range [-90, 90]. This means that if the value specified is less than -90, it will be set to -90. And if the value is greater than 90, it will be set to 90.
  • Longitude ranges between -180 and 180 degrees, inclusive. Values above or below this range will be wrapped so that they fall within the range. For example, a value of -190 will be converted to 170. A value of 190 will be converted to -170. This reflects the fact that longitudes wrap around the globe.

Although the default map projection associates longitude with the x-coordinate of the map, and latitude with the y-coordinate, the latitude coordinate is always written first, followed by the longitude. Notice that you cannot modify the coordinates of a LatLng. If you want to compute another point, you have to create a new one.

example
Most methods that accept LatLng objects also accept a LatLngLiteral object, so that the following are equivalent: map.setCenter(new google.maps.LatLng(-34, 151)); map.setCenter({lat: -34, lng: 151});
example
The constructor also accepts literal objects, and converts them to instances of LatLng: myLatLng = new google.maps.LatLng({lat: -34, lng: 151});
see

Maps JavaScript API

Hierarchy

  • LatLng

Index

Constructors

constructor

  • new LatLng(lat: number, lng: number, noWrap?: boolean): LatLng
  • new LatLng(literal: LatLngLiteral, noWrap?: boolean): LatLng
  • Creates a LatLng object representing a geographic point. Note the ordering of latitude and longitude.

    see

    Maps JavaScript API

    Parameters

    • lat: number

      Latitude is specified in degrees within the range [-90, 90].

    • lng: number

      Longitude is specified in degrees within the range [-180, 180].

    • Optional noWrap: boolean

      Set noWrap to true to enable values outside of this range.

    Returns LatLng

  • Creates a LatLng object representing a geographic point.

    see

    Maps JavaScript API

    Parameters

    • literal: LatLngLiteral

      Object literal.

    • Optional noWrap: boolean

      Set noWrap to true to enable values outside of this range.

    Returns LatLng

Methods

equals

  • equals(other: LatLng): boolean

lat

  • lat(): number

lng

  • lng(): number

toJSON

toString

  • toString(): string

toUrlValue

  • toUrlValue(precision?: number): string
  • Returns a string of the form "lat,lng" for this LatLng. We round the lat/lng values to 6 decimal places by default.

    see

    Maps JavaScript API

    Parameters

    • Optional precision: number

    Returns string

Generated using TypeDoc