Repository navigation
feat(android): support MapView compassImage - #4399
Merged
Merged
Conversation
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
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4170
compassImagewas 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'sImageManager, 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
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)The existing Map > Ornaments example already cycles
compassImagethroughcompass1/compass2/ unset. iOS code is unchanged.Screenshot OR Video
Tested on an Android 14 emulator with the Ornaments example, compass visible:
compassImage="compass1", the default Mapbox compass is shown.compass1andcompass2are shown and rotate with the map. This also works when the prop is set at mount, and after switching to the Dark style.Component to reproduce the issue you're fixing
The Map > Ornaments example: enable the compass, then tap "Image".