How to get the latitude and longitude of location where user taps on the map in android

前端 未结 4 794
后悔当初
后悔当初 2020-12-22 03:41

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 locatio

4条回答
  •  独厮守ぢ
    2020-12-22 04:43

    Try the following.

    Write a class which derives from the Overlay class and override the onTap() method. Then you can add your overlay to the your MapView. A GeoPoint object, which represents the position of you tap, is passed to the onTap() method when you tab somewhere on the map.

    OR

    The modern answer here, using Android Maps v2, is to use OnMapClickListener, which gives you the LatLng of a tap on the map.

提交回复
热议问题