Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

placemarkFromAddress implementation is missing #17

Open
shkvoretz opened this issue Oct 12, 2020 · 9 comments
Open

placemarkFromAddress implementation is missing #17

shkvoretz opened this issue Oct 12, 2020 · 9 comments
Assignees
Labels
P3 Issues that we currently consider unimportant. platform: android Issue is related to the Android platform. platform: ios Issue is related to the iOS platform type: enhancement New feature or request

Comments

@shkvoretz
Copy link

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
Copy link
Member

mvanbeusekom commented Oct 14, 2020

@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
Copy link

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
Copy link
Member

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

@mvanbeusekom
Copy link
Member

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

@flogaribal
Copy link

@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 using locationFromAddress
  • Transform Location to Placemark using placemarkFromCoordinates

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
Copy link

Is there any news about this?

@FarhanAli-98
Copy link

FarhanAli-98 commented Mar 10, 2021

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
Copy link

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 JeroenWeener added type: enhancement New feature or request P3 Issues that we currently consider unimportant. labels Sep 12, 2023
@JeroenWeener JeroenWeener added platform: android Issue is related to the Android platform. platform: ios Issue is related to the iOS platform labels Nov 16, 2023
@JeroenWeener JeroenWeener self-assigned this Nov 16, 2023
@JeroenWeener
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Issues that we currently consider unimportant. platform: android Issue is related to the Android platform. platform: ios Issue is related to the iOS platform type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants