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.

Most methods that accept LatLng objects also accept a google.maps.LatLngLiteral object, so that the following are equivalent:

 map.setCenter(new
google.maps.LatLng(-34, 151));
map.setCenter({lat: -34, lng: 151});

The constructor also accepts google.maps.LatLngLiteral and LatLng objects. If a LatLng instance is passed to the constructor, a copy is created.

The possible calls to the constructor are below:

 new google.maps.LatLng(-34, 151);
new google.maps.LatLng(-34, 151, true);
new google.maps.LatLng({lat: -34, lng: 151});
new google.maps.LatLng({lat: -34, lng: 151}, true);
new google.maps.LatLng(new google.maps.LatLng(-34, 151));
new google.maps.LatLng(new google.maps.LatLng(-34, 151), true);

Access by calling const {LatLng} = await google.maps.importLibrary("core"). See https://developers.google.com/maps/documentation/javascript/libraries.

Hierarchy

  • LatLng

Index

Constructors

  • new LatLng(latOrLatLngOrLatLngLiteral: number | LatLng | LatLngLiteral, lngOrNoClampNoWrap?: null | number | boolean, noClampNoWrap?: boolean): LatLng
  • 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.

    Most methods that accept LatLng objects also accept a google.maps.LatLngLiteral object, so that the following are equivalent:

     map.setCenter(new google.maps.LatLng(-34, 151));
    map.setCenter({lat: -34, lng: 151});

    The constructor also

    accepts google.maps.LatLngLiteral and LatLng objects. If a LatLng instance is passed to the constructor, a copy is created.

    The possible calls to the constructor are below:

     new google.maps.LatLng(-34, 151);
    new google.maps.LatLng(-34, 151, true);
    new google.maps.LatLng({lat: -34, lng: 151});
    new google.maps.LatLng({lat: -34, lng: 151}, true);
    new google.maps.LatLng(new google.maps.LatLng(-34, 151));
    new google.maps.LatLng(new google.maps.LatLng(-34, 151), true);

    Access by calling const {LatLng} = await google.maps.importLibrary("core"). See https://developers.google.com/maps/documentation/javascript/libraries.

    Parameters

    • latOrLatLngOrLatLngLiteral: number | LatLng | LatLngLiteral
    • Optional lngOrNoClampNoWrap: null | number | boolean
    • Optional noClampNoWrap: boolean

    Returns LatLng

Methods

  • equals(other: null | LatLng): boolean
  • Comparison function.

    Parameters

    Returns boolean

  • lat(): number
  • Returns the latitude in degrees.

    Returns number

  • lng(): number
  • Returns the longitude in degrees.

    Returns number

  • Converts to JSON representation. This function is intended to be used via JSON.stringify.

    Returns LatLngLiteral

  • toString(): string
  • Converts to string representation.

    Returns string

  • 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.

    Parameters

    • Optional precision: number

    Returns string

Generated using TypeDoc