Baseflow / flutter-geocoding

A Geocoding plugin for Flutter
https://baseflow.com
MIT License
137 stars 71 forks source link

placemarkFromAddress implementation is missing #17

Open sv-22 opened 4 years ago

sv-22 commented 4 years ago

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.

mvanbeusekom commented 4 years ago

@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

victor045 commented 4 years ago

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.

mvanbeusekom commented 4 years ago

@victor045, what is the exact problem you are having? Can't simply get the coordinates from the returned instance of the Location class?

mvanbeusekom commented 4 years ago

P.S. I just merged a PR (#21) which contains an update for the documentation. I completely looked over it.

flogaribal commented 3 years ago

@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:

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

flogaribal commented 3 years ago

Is there any news about this?

FarhanAli-98 commented 3 years ago
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) {}); }); });

FarhanAli-98 commented 3 years ago

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) {}); }); });

JeroenWeener commented 10 months ago

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.