parseLatitudeLongitude method

Geolocation? parseLatitudeLongitude(
  1. dynamic node
)

Implementation

Geolocation? parseLatitudeLongitude(dynamic node) {
  if (node is Map) {
    var latitudeEntry = findKeyEntry(node, ['latitude']);
    var longitudeEntry = findKeyEntry(node, ['longitude']);

    if (latitudeEntry != null && longitudeEntry != null) {
      var lat = latitudeEntry.value;
      var long = longitudeEntry.value;

      if (lat is num && long is num) {
        return Geolocation(lat, long);
      } else if (lat is String && long is String) {
        var lat2 = Geolocation.parseLatitudeOrLongitudeValue(lat)!;
        var long2 = Geolocation.parseLatitudeOrLongitudeValue(long)!;
        return Geolocation(lat2, long2);
      }
    }
  } else if (node is String) {
    return Geolocation.fromCoords(node, true);
  }

  return null;
}