2

I want to Implement on Long Click on Google Map Api v2 in android. So far what i have gone through is only we can handle Marker Click events. so what i want to ask is is there any way we can perform Long Click on Google Map Markers. Plus it would be a great plus if i can get MotionEvent from Marker. also is there any way we can even perform on Touch Event on Markers that can too solve my problem.

I want to get MotionEvent from Long Click or On Touch any thing can solve my problem.

Umer Kiani
  • 3,783
  • 5
  • 36
  • 63
  • 2
    Possible duplicate of [Setting a LongClickListener on a map Marker](http://stackoverflow.com/questions/15391665/setting-a-longclicklistener-on-a-map-marker) – Sree Dec 16 '15 at 09:09

1 Answers1

1
private GoogleMap googleMap;
Marker marker = null;

    googleMap.setOnMapLongClickListener(new OnMapLongClickListener() {

                    @Override
                    public void onMapLongClick(LatLng arg0) {
                        // TODO Auto-generated method stub
                        if(marker != null) {
                            marker.remove();
                        }
                        MarkerOptions markerOption = new MarkerOptions();
                        markerOption.position(arg0).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
                        marker = googleMap.addMarker(markerOption);

                    }
                });

Click listener for marker.

googleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {

            @Override
            public void onInfoWindowClick(Marker marker) {
                String infoTitle = marker.getTitle();
                // Do anything you want.    
            }
        });
Chirag Savsani
  • 6,020
  • 4
  • 38
  • 74