LngLat class

A LngLat object represents a given longitude and latitude coordinate, measured in degrees.

Mapbox GL uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON.

Note that any Mapbox GL method that accepts a LngLat object as an argument or option can also accept an Array of two numbers and will perform an implicit conversion. This flexible type is documented as {@link LngLatLike}.

@param {number} lng Longitude, measured in degrees. @param {number} lat Latitude, measured in degrees. @example var ll = new mapboxgl.LngLat(-73.9749, 40.7736); @see Get coordinates of the mouse pointer @see Display a popup @see Highlight features within a bounding box @see Create a timeline animation

Constructors

LngLat(num lng, num lat)
factory
LngLat.fromJsObject(LngLatJsImpl jsObject)
Creates a new LngLat from a jsObject.

Properties

hashCode int
The hash code for this object.
no setterinherited
jsObject → LngLatJsImpl
JS object.
finalinherited
lat num
no setter
lng num
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toArray() List<num>
Returns the coordinates represented as an array of two numbers.
toBounds(num radius) LngLatBounds
Returns a LngLatBounds from the coordinates extended by a given radius. The returned LngLatBounds completely contains the radius.
toString() String
Returns the coordinates represent as a string.
override
wrap() LngLat
Returns a new LngLat object whose longitude is wrapped to the range (-180, 180).

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

convert(dynamic input) LngLat
Converts an array of two numbers or an object with lng and lat or lon and lat properties to a LngLat object.