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

[FEATURE REQUEST] Get location by current location #131

Open
bhanuka96 opened this issue Aug 11, 2021 · 2 comments
Open

[FEATURE REQUEST] Get location by current location #131

bhanuka96 opened this issue Aug 11, 2021 · 2 comments

Comments

@bhanuka96
Copy link

Is there any way to get location by current lat and lng?

like this,

PlacesDetailsResponse detail = await places.getDetailsByLatLng(Location(lat: lat, lng: lng));

@HugoSart
Copy link

I also need this. Would be good to have an implementation for the Google Current Place API. There are both Android and iOS native SDKs, why don't we have a Flutter version too?

@bhanuka96
Copy link
Author

@HugoSart Get location details by current LatLng

  Future<GooglePlaceModel> getPlaceByLatLng(double lat, double lng) async {
    try {
      final response = await _dio.get('https://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$lng&key=${env.googleKey}');
      if (response.data != null) {
        return GooglePlaceModel.fromJson(response.data);
      } else {
        return null;
      }
    } catch (e) {
      print('Error place : $e');
      return null;
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants