Skip to content

feat(android): support MapView compassImage - #4399

Merged
mfazekas merged 1 commit into
mainfrom
feat/android-compass-image
Oct 25, 2026
Merged

mfazekas merged 1 commit into
mainfrom
feat/android-compass-image

Conversation

@mfazekas

Copy link
Copy Markdown
Contributor

Description

Fixes #4170

compassImage was a no-op on Android. It now resolves the style image with the given id and sets it as the compass image through the compass plugin (compass.updateSettings { image = ImageHolder.from(bitmap) }). It subscribes to the map's ImageManager, so images that <Images> adds or finishes downloading later, or re-adds after a style reload, are picked up. When the prop is cleared, or the id isn't in the style, the default Mapbox compass is restored.

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

The existing Map > Ornaments example already cycles compassImage through compass1 / compass2 / unset. iOS code is unchanged.

Screenshot OR Video

Tested on an Android 14 emulator with the Ornaments example, compass visible:

  1. Before: with compassImage="compass1", the default Mapbox compass is shown.
  2. After: compass1 and compass2 are shown and rotate with the map. This also works when the prop is set at mount, and after switching to the Dark style.
  3. After: setting an id that doesn't exist, or clearing the prop, shows the default compass. No crash.

Component to reproduce the issue you're fixing

The Map > Ornaments example: enable the compass, then tap "Image".

<MapView compassEnabled compassImage="compass1">
  <Images images={{ compass1: require('../../assets/compass1.png') }} />
</MapView>

Resolve the compass image from the style image with the given id, update it
when Images adds or reloads it, and restore the default compass when the
prop is cleared.

Fixes #4170
@mfazekas
mfazekas merged commit 4044c69 into main Oct 25, 2026
10 checks passed
@mfazekas
mfazekas deleted the feat/android-compass-image branch October 25, 2026 21:00

This branch was previously deployed

1 inactive deployment
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.

[Bug]: CompassImage not working

1 participant