getClosestAddressLandmark method
- required Coordinates coords,
- required int radius,
- required bool onlyCity,
Retrieves the closest address landmark to the given coordinates within a specified radius.
Parameters
coords: The geographic coordinates to search around.radius: The radius in meters within which to search for the closest address.onlyCity: Specifies whether to only search for addresses within cities.
Returns
- The closest Landmark representing the address if found, otherwise
null.
Implementation
Future<Landmark?> getClosestAddressLandmark({
required Coordinates coords,
required int radius,
required bool onlyCity,
}) async {
final String? resultString = await GemKitPlatform.instance
.getChannel(mapId: mapId)
.invokeMethod<String>(
'callObjectMethod',
jsonEncode(<String, dynamic>{
'id': _pointerId,
'class': 'MapView',
'method': 'getClosestAddress',
'args': <String, dynamic>{
'c': coords,
'radius': radius,
'onlyCity': onlyCity,
},
}),
);
if (resultString == null) {
return null;
}
final int id = jsonDecode(resultString)['result'];
if (id == -1) {
return null;
} else {
return Landmark.init(id);
}
}