localMeterToLngLat function

LatLng localMeterToLngLat(
  1. double x,
  2. double y,
  3. LatLng center
)

Converts local meters (x, y) relative to a geographic center into lng, lat.

Implementation

LatLng localMeterToLngLat(double x, double y, LatLng center) {
  final double originLat = center.latitude;
  final double originLng = center.longitude;

  final double mPerDegLng =
      mPerDegLat * math.cos((originLat * math.pi) / 180.0);

  final double dLat = y / mPerDegLat;
  final double dLng = x / mPerDegLng;

  return LatLng(originLat + dLat, originLng + dLng);
}