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

前端 未结 4 775
后悔当初
后悔当初 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:18

    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

提交回复
热议问题