LatLng constructor

const LatLng(
  1. double latitude,
  2. double longitude
)

Creates a geographical location specified in degrees latitude and longitude.

The latitude is clamped to the inclusive interval from -90.0 to +90.0.

The longitude is normalized to the half-open interval from -180.0 (inclusive) to +180.0 (exclusive).

Implementation

const LatLng(double latitude, double longitude)
  : latitude = latitude < -90.0 ? -90.0 : (90.0 < latitude ? 90.0 : latitude),
    // Avoids normalization if possible to prevent unnecessary loss of precision
    longitude = longitude >= -180 && longitude < 180
        ? longitude
        : (longitude + 180.0) % 360.0 - 180.0;