fromString static method

LatLong fromString(
  1. String latLonString
)

Parses a LatLong from a string with latitude and longitude values.

Supports multiple separators: comma (,), semicolon (;), colon (:), and whitespace. The format should be "latitude,longitude" or similar with supported separators.

latLonString String containing the coordinate values Returns a new LatLong parsed from the string Throws Exception if the string format is invalid

Implementation

static LatLong fromString(String latLonString) {
  List<String> split = latLonString.split("[,;:\\s]");
  if (split.length != 2) throw Exception("cannot read coordinate, not a valid format");
  double latitude = double.parse(split[0]);
  double longitude = double.parse(split[1]);
  return LatLong(latitude, longitude);
}