1

I am currently using OSMdroid.
I want to be able to mark (with the touch screen) certain points on my map.
The first option is to use long clicks. the problem is that my system recognizes scrolls as long clicks. The second option is to use double tab. This has the effect of changing the zoom level.

I want to be able to distinguish between long clicks and scrolls. is there a simple way to do this?

There are some suggetions in the following link:
However, I am not sure that these suggestions can be implemented with OSMdroid.

Thanks in advance!

Ariel

Community
  • 1
  • 1
Ariel
  • 206
  • 1
  • 4
  • 10
  • Suggestions in the link are good. I have the onTouchListener tdirectly to the mapView myself and just override doubletap – Ifor Aug 07 '12 at 07:53

2 Answers2

1

Note that this method will only allow a single touch event.

Your activity needs to implements MapEventsReceiver.

You then need to add A MapEventsOverlay to the mapwith:

//Handling Map events
MapEventsOverlay mapEventsOverlay = new MapEventsOverlay(this, this);
map.getOverlays().add(0, mapEventsOverlay); //inserted at the "bottom" of all overlays

Documented in the OSMDroidBonus Pack Tutorial

tread
  • 10,133
  • 17
  • 95
  • 170
0

When I wanted to add some touch functionality to OsmMap, I also found that tap and scroll and such were already used.

So I made all my gestures require longpress with three fingers to start. The gestures were long press with three fingers then slide left or right or long press with three fingers then fling up. That way my gestures did not interfere with any normal map gestures.

My app also had to consume touch events after it detected the three finger longpress. Otherwise, the osm gestures and my gestures would compete causing weird scrolling and zooming.

This requires adding a special Overlay and code like this:

@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView)
{
    boolean detected = false;
    if (myGestureDetector.onTouchEvent(event))
    {
        detected = true;
    }

    if (myGestureDetector.isTouchEventActive())
    {
        Log.d(D_LOG, "TOUCH EVENT ACTIVE DRAIN IT");
        detected = true;
    }

    return detected;
}
gregm
  • 12,019
  • 7
  • 56
  • 78