Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Google Maps API has provided awesome functionalities for android users, Like Search places, Pick address by tapping on map, Distance and time duration between two coordinates on the map.
In this blog, we are going to see how we can get the address of a location by dragging the map marker to that location.
So, let’s start with the first step. Declaring the dependencies related to maps.
Now, let’s move to the layout changes. We would need to add a map fragment in the layout file according to the design needed.
Then we need to declare the permissions related to the location and also need to check the permission at run time in devices above or equal to Android M.
Now obtain SupportMapFragment and get notified when the map is ready by overriding OnMapReadyCallback
Now let’s override the onMapReady function
In the next step, we will be adding a listener for the marker dragging. You can add this in onMapReady function. And with this, we can get the Address object when the marker dragging is ended by the user in onMarkerDragEnd method.
By following these steps you can get an address of a location by dragging the marker to that location.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Example: static final LatLng PERTH = new LatLng(-31.90, 115.86); Marker perth = mMap.addMarker(new MarkerOptions().position(PERTH).draggable(true));
Reference: https://developers.google.com/maps/documentation/android-sdk/marker#make_a_marker_draggable
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.