Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have encounter a solution through <strong>OSMBonusPack</strong> library.</p> <p>The object <code>MapsEventsReceiver</code> grants you a simple way to handle map's gestures. You have to override <code>singleTapUpHelper</code> and <code>longPressHelper</code> methods and create a new overlay with this handler.</p> <p>Here's the code:</p> <pre><code>MapEventsReceiver mReceive = new MapEventsReceiver() { @Override public boolean singleTapUpHelper(IGeoPoint arg0) { Log.d("debug", "Single tap helper"); //your onSingleTap logic here return false; } @Override public boolean longPressHelper(IGeoPoint arg0) { Log.d("debug", "LongPressHelper"); //your onLongPress logic here setMarker(arg0); return false; } }; //Creating a handle overlay to capture the gestures MapEventsOverlay OverlayEventos = new MapEventsOverlay(getBaseContext(), mReceive); map.getOverlays().add(OverlayEventos); //Refreshing the map to draw the new overlay map.invalidate(); //I use this method to set the marker on touchPoint protected void setMarker(IGeoPoint arg0) { touchPoint = (GeoPoint) arg0; targetPoint = touchPoint; path.addPoint(targetPoint); //Listener to handle item's(markers) events myOnItemGestureListener = new OnItemGestureListener&lt;OverlayItem&gt;() { @Override public boolean onItemLongPress(int arg0, OverlayItem arg1) { Log.d("debug", "Testing long tap on item"); //your item onLongPress logic here return false; } @Override public boolean onItemSingleTapUp(int index, OverlayItem item) { Log.d("debug", "Testing single tap on item"); //your item onSingleTap logic here return true; } }; itemarray.add(new OverlayItem("Marker " + cnt, "Info about marker " + cnt, touchPoint)); ItemizedOverlayWithFocus&lt;OverlayItem&gt; overlayDeItems = new ItemizedOverlayWithFocus&lt;OverlayItem&gt;(getBaseContext(), itemarray, myOnItemGestureListener); map.getOverlays().add(overlayDeItems); overlayDeItems.setFocusItemsOnTap(true); map.invalidate(); itemarray = new ArrayList&lt;OverlayItem&gt;(); cnt++; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload