Search code examples
flutterdartgeolocation

Flutter geolocator plugin Geolocator().placemarkFromAddress() and Geolocator().placemarkFromCoordinates() do not work


I am trying to search an address and then trying to get position of that location by Geolocator and then trying to set camera position to this position but it does not work.

I find out some exceptions for two methods of Geolocator. All others methods of Geolodator work fine for me:

1. Geolocator().placemarkFromAddress() shows:

PlatformException(ERROR_GEOCODING_ADDRESS, Service not Available, null)

2. Geolocator().placemarkFromCoordinates() shows:

PlatformException(ERROR_GEOCODING_COORDINATES, Service not Available, null)


Here Code that I am trying:

try {
  List<Placemark> placemark = await Geolocator().placemarkFromAddress(searchAddress);
  Placemark newPlace = placemark[0];
  controller.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
     target: LatLng(newPlace.position.latitude,newPlace.position.longitude),
     zoom: 15.0,
  )));
}catch(e){
   print(e);
}

Solution

  • placemarkFromCoordinates has been moved from plugin geolocator to geocoding , just add plugin geocoding in pubspec.yaml and user placemarkFromCoordinates