flutter-geocoding
flutter-geocoding copied to clipboard
placemarkFromAddress implementation is missing
placemarkFromAddress was supposed to be moved from geolocator plugin starting with v6 and it did disappear, but it has never been implemented in geocoding plugin.
Documentation on Flutter website for the plugin is of very poor quality e.g. one of examples refers to placemarkFromAddress, but the code is for locationFromAddress. Also hyperlinks to Apple and Android documentation do not point to anything
I need to be able to feed a string with an address and get back matches and that's what placemarkFromAddress was for.
@DominicOcean with the migration of the geocoding features from the geolocator plugin into the geocoding plugin the placemarkFromAddress
method has been renamed to the more appropriate locationFromAddress
method.
To use it you can give it an address (in string format) and you'll receive back the coordinates found matching the string. I am not sure what you mean with the "Documentation on the Flutter website". The documentation of the geocoding plugin seems to mention the correct functionality: https://pub.dev/packages/geocoding
I having problems getting the Position from the Location, in the previous version placemarkFromAddress[0].position was the method to call the Position but now it is a Location.
@victor045, what is the exact problem you are having? Can't simply get the coordinates from the returned instance of the Location
class?
P.S. I just merged a PR (#21) which contains an update for the documentation. I completely looked over it.
@victor045, what is the exact problem you are having? Can't simply get the coordinates from the returned instance of the
Location
class?
Hi!
I think what @victor045 is saying is that before,, with geolocator
package, using the method placemarkFromAddress
you could get a Placemark directly from a given string address.
With this new update we need to:
- Transform given string address to a
Location
usinglocationFromAddress
- Transform
Location
toPlacemark
usingplacemarkFromCoordinates
Moreover in the Placemark
class, we do not have access to coordinates anymore. There is not any position
field as there was before update. That means that given a Placemark we need to query for its coordinates instead of getting them directly from the structure.
Here is a quick example that compares both solution: OLD WAY
final List<Placemark> places = await _geoLocator.placemarkFromAddress(
value,
localeIdentifier: _appBloc.lastLocaleValue.toString(),
);
if (places != null && places.isNotEmpty) {
_citySuggestionsController.sink.add(places.toSet().toList());
}
NEW WAY
final List<Location> locations = await locationFromAddress(
value,
localeIdentifier: _appBloc.lastLocaleValue.toString(),
);
if (locations == null || locations.isEmpty) {
return;
}
final Location firstLocation = locations.first;
final List<Placemark> places = await placemarkFromCoordinates(
firstLocation.latitude,
firstLocation.longitude,
);
if (places != null && places.isNotEmpty) {
_citySuggestionsController.sink.add(places.toSet().toList());
}
I do not know if there are any reasons about this changes, it seems weird to me but I might have missed some limitations/issues with the old way.
Glad to hear about your opinion
Is there any news about this?
Geolocator().placemarkFromAddress is not working this method same like and provide accurate latitude and longitude of any address and mark and also set camera position on your searching place.
setState(() { GeocodingPlatform.instance .locationFromAddress(SearchAddress) .then((result) { lat = result[0].latitude; long = result[0].longitude; }).then((value) { _markers.add(Marker( markerId: MarkerId("Devex"), position: LatLng(lat, long), icon: greenLocationIcon, infoWindow: InfoWindow(title: "Search Result"))); CameraUpdate camera = CameraUpdate.newLatLngZoom(LatLng(lat, long), 15); _controller.animateCamera(camera).catchError((e) {}); }); });
Is there any news about this?
Geolocator().placemarkFromAddress is not working this method same like and provide accurate latitude and longitude of any address and mark and also set camera position on your searching place. setState(() { GeocodingPlatform.instance .locationFromAddress(SearchAddress) .then((result) { lat = result[0].latitude; long = result[0].longitude; }).then((value) { _markers.add(Marker( markerId: MarkerId("Devex"), position: LatLng(lat, long), icon: greenLocationIcon, infoWindow: InfoWindow(title: "Search Result"))); CameraUpdate camera = CameraUpdate.newLatLngZoom(LatLng(lat, long), 15); _controller.animateCamera(camera).catchError((e) {}); }); });
FYI: The platform interface and Android packages have been updated to include this functionality. Once the iOS implementation is finished we can go ahead and hook it up to the geocoding
package and make this feature available.