How to detect long click on GoogleMap marker

痞子三分冷 提交于 2020-03-06 08:35:36

问题


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)


回答1:


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




回答2:


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

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



来源:https://stackoverflow.com/questions/17372179/how-to-detect-long-click-on-googlemap-marker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!