Skip to content

Fix map panning during marker drag and support vector marker icons - #61

Merged
afarber merged 1 commit into
mainfrom
fix-marker-drag-and-resource-icons
Oct 14, 2026
Merged

afarber merged 1 commit into
mainfrom
fix-marker-drag-and-resource-icons

Conversation

@afarber

@afarber afarber commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Marker drag pans the map

OpenMapView.onTouchEvent measured the drag threshold from the previous MOVE event. While a draggable marker was pressed but not yet dragged, the event fell through to the pan code, which also reset that reference point. Each MOVE delta stayed under 10 px, so the drag rarely started and the map followed the finger instead (about 140 px in a test run).

  • The threshold is now measured from the touch-down point
  • Below the threshold the event is consumed without panning
  • The 10 px value is a shared TAP_SLOP_PX constant, also used for tap detection

fromResource() ignores vector drawables

BitmapFactory.decodeResource returns null for vector and other XML drawables, so the default pin was shown. The resource was also decoded again on every draw and hit test.

  • Resource icons are loaded with ContextCompat.getDrawable(...).toBitmap() (existing core-ktx dependency), rendered at intrinsic size
  • Decoded resource and asset icons are cached per descriptor; failed loads fall back to the default pin and are not cached

Tests

  • MarkerDragTest: small steps on a draggable marker drag it without panning, moves within the slop do nothing, a drag on empty map still pans. The first two fail without the fix.
  • MarkerIconLoadingTest: an XML drawable renders at its intrinsic size, resource bitmaps are decoded once, missing resources and assets fall back to the default pin.

- Measure the marker drag threshold from the touch-down point and do not
  pan the map while a draggable marker is pressed below the threshold
- Load fromResource() icons through Drawable so vector drawables render
  instead of falling back to the default pin
- Cache decoded resource and asset icons instead of decoding them on
  every draw
@afarber
afarber merged commit b4df3bd into main Oct 14, 2026
14 checks passed
@afarber
afarber deleted the fix-marker-drag-and-resource-icons branch October 14, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant