From f43c2f8b1dfa2b5586b7e8c48572a7c02eb30391 Mon Sep 17 00:00:00 2001 From: Yann Pringault Date: Tue, 4 Aug 2026 12:38:05 +0200 Subject: [PATCH] fix(android): honor LocationPuck `scale` for the default puck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `scale` is documented as supporting zoom expressions, and it works on iOS, but on Android it is silently ignored unless you also supply custom puck images. RNMBXNativeUserLocation._apply() branches on `images.isEmpty()`. The custom-images branch passes `scaleExpression = scale?.toJson()`, but the default branch calls makeDefaultLocationPuck2D(), which never received the scale at all. iOS has no such split: RNMBXNativeUserLocation.swift builds the configuration (defaulting it when no images are supplied) and then applies `scale` unconditionally afterwards. So an app using the stock puck — the common case — gets a marker fixed at one screen size while everything else on the map scales with zoom. This threads an optional `scaleExpression` through the default builder. LocationPuck2D already accepts it alongside drawables (the same shape LocationComponentManager uses), the new parameter is defaulted, and makeDefaultLocationPuck2D has a single call site, so no other behaviour changes and the stock puck keeps its platform look. Verified on an Android device against a reproducer: a MapView with `` and no puck images. Before, the puck stays one size at every zoom; after, it scales, matching the same code running on iOS. --- .../location/RNMBXNativeUserLocation.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocation.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocation.kt index f9af8bdefd..f84bdeb05c 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocation.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocation.kt @@ -128,7 +128,11 @@ class RNMBXNativeUserLocation(context: Context) : AbstractMapFeature(context), O if (visible) { if (images.isEmpty()) { location2.locationPuck = - makeDefaultLocationPuck2D(mContext, androidRenderMode ?: RenderMode.NORMAL) + makeDefaultLocationPuck2D( + mContext, + androidRenderMode ?: RenderMode.NORMAL, + scale?.toJson() + ) } else { location2.locationPuck = LocationPuck2D( topImage = images[PuckImagePart.TOP], @@ -279,7 +283,11 @@ class RNMBXNativeUserLocation(context: Context) : AbstractMapFeature(context), O } } -fun makeDefaultLocationPuck2D(context: Context, renderMode: RenderMode): LocationPuck2D { +fun makeDefaultLocationPuck2D( + context: Context, + renderMode: RenderMode, + scaleExpression: String? = null +): LocationPuck2D { return LocationPuck2D( topImage = AppCompatResourcesV11.getDrawableImageHolder( context, @@ -296,6 +304,7 @@ fun makeDefaultLocationPuck2D(context: Context, renderMode: RenderMode): Locatio shadowImage = AppCompatResourcesV11.getDrawableImageHolder( context, LR.drawable.mapbox_user_icon_shadow - ) + ), + scaleExpression = scaleExpression ); } \ No newline at end of file