1

In my app I have a MapFragment.

I do

map = mapFragment.getMap();

and after that add a marker in the event

onMapClick(LatLng point){
    ...

    map.addMarker(new MarkerOptions()
    .position(point)
    .title(txt));

    ...
}

All this works perfectly. What I need is to know when the user keep long click on the marker I put on the map.

I made some handmade calculations in

onMapLongClick(LatLng point){
...

if((Math.abs(mrkrPos.latitude-point.latitude)<0.0005)&&(Math.abs(mrkrPos.longitude-point.longitude)<0.0005))

...
}

but this isn't obviously a fine way to do it, and it isn't very accurate (only works when zoom camera is at high levels on map)

rickymarchiori
  • 103
  • 2
  • 13
  • Are you ok with the possibility to differentiate between `onMarkerClick` and `onMarkerLongClick` when user lifts up their finger or you need it to be fired after e.g. 400 ms pressing the `Marker`? – MaciejGórski Jun 29 '13 at 21:14
  • Use javascript for this.... http://stackoverflow.com/questions/2625210/long-press-in-javascript – Premshankar Tiwari Jul 02 '13 at 06:05
  • Basically you can use the OnMarkerDragListener [Check my workaround][1] [1]: http://stackoverflow.com/questions/15391665/setting-a-longclicklistener-on-a-map-marker – DanihelSan Jan 29 '14 at 22:01

2 Answers2

0

There is currently no long Click Listener for markers. see my question about this from a while ago

Community
  • 1
  • 1
tyczj
  • 71,600
  • 54
  • 194
  • 296
0

Hey take a look at the solution i have given in other thread.

https://stackoverflow.com/a/42885588/3779042

Community
  • 1
  • 1
jknair0
  • 1,194
  • 13
  • 24