Skip to content

Commit bcd5faa

Browse files
pengdevgithub-actions[bot]
authored andcommitted
[MAPSAND-2541] Clarify scale/pixel density docs for addStyleImage and addImage (#10400)
### Summary Fixes https://mapbox.atlassian.net/browse/MAPSAND-2541 - Updated `@param scale` KDoc in `addStyleImage` to explain pixel density semantics with a concrete example - Added pixel density explanation paragraphs to all 4 `addImage` overloads in `MapboxStyleManager.kt` ### Problem The `scale` parameter in `addStyleImage` was documented only as "A scale factor for the image," giving no indication of how scale affects rendering. Similarly, `addImage` overloads had no documentation explaining how pixel dimensions relate to display size, causing developer confusion when images appear at unexpected sizes. ### Solution Clarify that `scale` represents pixel density: image pixel dimensions are divided by the scale value to determine display size in dp. For `addImage`, document that pixel dimensions are assumed to match device screen density, and point users to `addStyleImage` when custom density is needed. ### Key Changes - **`MapboxStyleManager.kt` — `addStyleImage`**: `@param scale` updated from "A scale factor for the image" to full pixel density explanation with 100x100 @ scale=2.0 → 50x50dp example - **`Style.kt` — `addStyleImage`**: Same `@param scale` clarification applied - **`MapboxStyleManager.kt` — `addImage` (×4 overloads)**: Added paragraph explaining dimensions assumed to match device screen density, with reference to `addStyleImage` for custom density ### Validation - [x] Documentation-only change — no behavioral or API surface changes - [x] Verified wording is consistent across all affected overloads - [x] Confirm generated KDoc output renders correctly cc @mapbox/maps-android GitOrigin-RevId: bb6f72c95065ad19163d733caad2bfa12e71a1fb
1 parent 6a42c1c commit bcd5faa

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

maps-sdk/src/main/java/com/mapbox/maps/Style.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,9 @@ class Style internal constructor(
779779
* See [https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern)
780780
*
781781
* @param imageId ID of the image.
782-
* @param scale Scale factor for the image.
782+
* @param scale The pixel density of the provided image. The image's pixel dimensions are divided
783+
* by this value to determine its display size in density-independent pixels. For example, a
784+
* 100x100 pixel image with scale=2.0 will be displayed as 50x50 density-independent pixels.
783785
* @param image Pixel data of the image.
784786
* @param sdf Option to treat whether image is SDF(signed distance field) or not.
785787
* @param stretchX An array of two-element arrays, consisting of two numbers that represent

sdk-base/src/main/java/com/mapbox/maps/MapboxStyleManager.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,9 @@ open class MapboxStyleManager @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
12161216
* [`text-field`](https://www.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-text-field) properties.
12171217
*
12181218
* @param imageId An identifier of the image.
1219-
* @param scale A scale factor for the image.
1219+
* @param scale The pixel density of the provided image. The image's pixel dimensions are divided
1220+
* by this value to determine its display size in density-independent pixels. For example, a
1221+
* 100x100 pixel image with scale=2.0 will be displayed as 50x50 density-independent pixels.
12201222
* @param image A pixel data of the image.
12211223
* @param sdf An option to treat whether image is SDF(signed distance field) or not.
12221224
* @param stretchX An array of two-element arrays, consisting of two numbers that represent
@@ -1541,6 +1543,10 @@ open class MapboxStyleManager @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
15411543
* See [https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern)
15421544
* See [https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern)
15431545
*
1546+
* The image's pixel dimensions are assumed to match the device's screen density. They are divided
1547+
* by the screen density to determine the display size in density-independent pixels. To add an
1548+
* image with a different density, use [addStyleImage] with an explicit scale parameter.
1549+
*
15441550
* @param imageId ID of the image.
15451551
* @param image Pixel data of the image.
15461552
* @param sdf Option to treat whether image is SDF(signed distance field) or not.
@@ -1566,6 +1572,10 @@ open class MapboxStyleManager @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
15661572
* See [https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern)
15671573
* See [https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern)
15681574
*
1575+
* The image's pixel dimensions are assumed to match the device's screen density. They are divided
1576+
* by the screen density to determine the display size in density-independent pixels. To add an
1577+
* image with a different density, use [addStyleImage] with an explicit scale parameter.
1578+
*
15691579
* @param imageId ID of the image.
15701580
* @param image Pixel data of the image.
15711581
*
@@ -1588,6 +1598,10 @@ open class MapboxStyleManager @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
15881598
* See [https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern)
15891599
* See [https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern)
15901600
*
1601+
* The bitmap's pixel dimensions are assumed to match the device's screen density. They are divided
1602+
* by the screen density to determine the display size in density-independent pixels. To add an
1603+
* image with a different density, use [addStyleImage] with an explicit scale parameter.
1604+
*
15911605
* @param imageId ID of the image.
15921606
* @param bitmap The bitmap image.
15931607
* @param sdf Option to treat whether image is SDF(signed distance field) or not.
@@ -1619,6 +1633,10 @@ open class MapboxStyleManager @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
16191633
* See [https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern)
16201634
* See [https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern)
16211635
*
1636+
* The bitmap's pixel dimensions are assumed to match the device's screen density. They are divided
1637+
* by the screen density to determine the display size in density-independent pixels. To add an
1638+
* image with a different density, use [addStyleImage] with an explicit scale parameter.
1639+
*
16221640
* @param imageId ID of the image.
16231641
* @param bitmap The bitmap image.
16241642
*

0 commit comments

Comments
 (0)