Search code examples
osmdroid

Osmdroid - Marker - increase selection area to get the InfoWindow


When selecting a Marker an InfoWindow pops up.

Sometimes the selection of a Marker is difficult. Especially when the map is rotating in the direction of navigation.

How can I increase the 'touch circle' so that selection is easier?

Update: I have to change the hitTest() for the Marker by subclassing.

I would like to check whether the 'hit' (or touch) was within a circle of X pixels around the point of the Marker. The icon will rotate while I navigate, so I guess I don't use the icon.

How can I do that?

public boolean hitTest(final MotionEvent event, final MapView mapView){
    final Projection pj = mapView.getProjection();
    pj.toPixels(mPosition, mPositionPixels);
    // Does mPositionPixels contains the x, y of the Marker? 
    // Should I draw a Rect around this point, or could it be a circle?
    // How can I check whether the event.getX(), event.getY() is a hit? 
    return hit;
}

Solution

  • Method proposed by spy is feasible.

    You can also create your icon bitmap with an area of transparent pixels around. This is a very simple way to increase its touch area.