reverseGeocoding method
Rever geocoding, returns name of the location that corresponds to the latitude and longitude given
Implementation
Future<String> reverseGeocoding({
/// [latitude] is the latitude of the location, in decimal degrees
required double latitude,
/// [longitude] is the longitude of the location, in decimal degrees
required double longitude,
/// [flags] is the flags of the request, by default it is 1255211008
/// For more information about the flags, refer to https://sdk.wialon.com/wiki/en/sidebar/remoteapi/apiref/requests/address
int flags = 1255211008,
}) async {
final Map<String, double> coordinates = {'lon': longitude, 'lat': latitude};
Uri parsedHost = Uri.parse(host);
Uri url = Uri.parse(
"https://geocode-maps.wialon.com/${parsedHost.host}/gis_geocode?"
"coords=[${jsonEncode(coordinates)}]"
"&flags=$flags"
"&uid=$_userId",
);
try {
final response = await http.post(url);
final result = jsonDecode(response.body);
if (result is Map) {
throw WialonError(code: result['error']);
}
if (result.isEmpty) {
return 'N/A';
}
return result.first;
} catch (e) {
throw SdkException(message: "Internal error: $e");
}
}