In my Android application, I'm using google maps v2 to show map by getting the latitute and longitude of the device's current location And I'm showing pin on that location.
Now when user clicks or taps on any other location on the map, then I have to get that points latitude and longitude and i have to set the pin at that location.
Could you please tell me how get the latitude and longitude of the user taps/clicks location.
An example of what i use. Change it accordingly for your needs. I use it with long press.
map.setOnMapLongClickListener(new OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng point) {
map.addMarker(new MarkerOptions().position(point).title("Custom location").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));enter code here
}
});
the LatLng point contains the coordinated of the longpress
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments