0

I need to open Google Map from my application, select a location, get its details like lat, long, address, etc and send this data back to my application. I am not sure how to proceed. Need some insight.

I am able to open Map via intent, but not sure how to send back selected location back to my app.

UPDATE I got what I wanted but not able to integrate it :(
Place Picker

following Place Picker Example but this is also closing after launching. I have created my Places API key and added to manifest file. I am also requesting for permission on API 23.

Thanks

Abhinav Tyagi
  • 5,158
  • 3
  • 30
  • 60

1 Answers1

0

The Google Maps App does not handle the action that you want, but you can add the map to your application using the Google Maps Android API.

Once you instanciate the map you can set a GoogleMap.OnMapClickListener on it:

googleMap.setOnMapClickListener(new OnMapClickListener() {
        @Override
        public void onMapClick(LatLng clickPos) {
            // Here you have the user click
        }
    });

If you need to find the address (or most probable addresses) for that coordinates, then you can use a Geocoder to find it:

Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(clickPos.latitude, clickpos.longitude, 1);

The Address object will give you all the available information for that coordinate.

Alan Wink
  • 113
  • 10
  • Place Picker could help me here. Not able to integrate it. It closes as I launch it ! – Abhinav Tyagi Mar 17 '16 at 17:38
  • Are you adding ACCESS_FINE_LOCATION to your manifest? Also, if you are building with API >= 23, you need to ask for permission in [runtime](http://developer.android.com/intl/pt-br/training/permissions/requesting.html). If this is not the problem, please check and send the adb log to see what is going on. – Alan Wink Mar 17 '16 at 17:49
  • Yes, I am asking for permission – Abhinav Tyagi Mar 17 '16 at 19:07
  • So please add the code to your question, so we can check that. – Alan Wink Mar 19 '16 at 02:33
  • Solved it... Check solution here http://stackoverflow.com/questions/36077696/place-picker-closes-after-launching – Abhinav Tyagi Mar 20 '16 at 09:58