3

I am trying to make an app that once the user taps on a map it gets the coordinates of that specific point.

Among others I have also read that: Get coordinates on tapping map in android

It seems like the most relevant post but what I want to do is to be able to tap anywhere on the map not on an marker/overlay item. In fact I want to create a marker in that specific point that the user tapped and get the coordinates of it.

Is that possible?

peterh
  • 11,875
  • 18
  • 85
  • 108
mixkat
  • 3,883
  • 10
  • 40
  • 58

1 Answers1

0

Should be trivial with a little bit of math. You can use getLatitudeSpan() and getLongitudeSpan() to get the extents of the visible map, and getMapCenter() to see the center point. Just map that to the coordinates of the touch event.

EDIT: Mark, as always, has an even more elegant solution.

EboMike
  • 76,846
  • 14
  • 164
  • 167