Skip to content

feat(PointAnnotation): add iconOpacity and iconSize - #4466

Open
hazel-wl wants to merge 1 commit into
rnmapbox:mainfrom
wanderlog:hazel/upstream-point-annotation-icon-opacity-size
Open

hazel-wl wants to merge 1 commit into
rnmapbox:mainfrom
wanderlog:hazel/upstream-point-annotation-icon-opacity-size

Conversation

@hazel-wl

@hazel-wl hazel-wl commented Dec 1, 2026

Copy link
Copy Markdown

Description

Added iconOpacity and iconSize to PointAnnotation, which set the annotation's opacity and scale.

Motivation

  • Apps can't fade or scale a PointAnnotation without changing its children, which takes a new snapshot of them
  • iconOpacity and iconSize set the annotation's opacity and scale directly, so apps can change them cheaply
    • For example, we animate these two props in our app
  • iconSize scales around anchor, so the anchor stays on coordinate

Changes

  • New props: iconOpacity and iconSize on PointAnnotation and its native spec. Both default to 1.
  • Native: on both platforms, they set the annotation's iconOpacity and iconSize, and keep its image
    • Both platforms skip values that haven't changed, since each update syncs the annotations' GeoJSON source
    • On Android, makeMarker creates the annotation with the current values. Mapbox also scales icon-offset, which holds the anchor, by icon-size.
  • Example: a "Point Annotation Opacity and Size" scene with buttons that change the annotation's opacity and size

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)

Testing

  • Ran yarn type:check, yarn lint and yarn generate
  • Opened Annotations → Point Annotation Opacity and Size in the example app, on an iOS 26.5 simulator and an Android emulator
    • Before: opacity 0.6 and size 1.5 have no effect
    • After: opacity 0.6 makes the annotation see-through, and sizes 1.5 and 0.5 scale it with its bottom edge (the anchor) staying on the coordinate
    • On iOS, I also checked an annotation that mounts with opacity 0.6 and size 1.5, and it shows both from the start

Screenshot OR Video

Before After
iOS icon-before-2-opacity-0 6icon-before-3-size-1 5 icon-after-1-defaulticon-after-2-opacity-0 6icon-after-3-size-1 5icon-after-4-size-0 5
Android android-icon-before-2-opacity-0 6android-icon-before-3-size-1 5 android-icon-after-1-defaultandroid-icon-after-2-opacity-0 6android-icon-after-3-size-1 5android-icon-after-4-size-0 5

Changes the existing annotation's icon-opacity and icon-size without
taking a new snapshot of its children, so they're cheap to animate.
Adds the Point Annotation Opacity and Size example.

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.

1 participant