Skip to content

Commit f657662

Browse files
dserebriakovgithub-actions[bot]
authored andcommitted
[MAPSNAT-2285] Propagate scale factor param to platform SDKs
GitOrigin-RevId: c78091ceb8359e063c994d37caf3974ee9f6ce4a
1 parent dab84e3 commit f657662

File tree

6 files changed

+36
-8
lines changed

6 files changed

+36
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Mapbox welcomes participation and contributions from everyone.
66

77
## 11.16.0-beta.1 - 23 September, 2025
88

9+
* Added experimental `scaleFactor` param to `MapOptions`, `MapSnapshotOptions` for scaling icons and texts.
910
* Added support for `LandmarkIcons` featureset in Mapbox Standard Style. The `LandmarkIcons` featureset allows querying and configuring landmark building icons that appear on the map. Access landmark properties including landmarkId, name, type, and localized names through the `StandardLandmarkIconsFeature` class.
1011
* Enhanced `MapStyle.standard()` and `MapStyle.standardSatellite()` with new configuration parameters for color customization, landmark icons visibility, point-of-interest styling, road appearance, and administrative boundaries.
1112
* Expose `LineLayer.lineCutoutFadeWidth` to control route line cutout fade width.

Sources/MapboxMaps/Foundation/Extensions/Core/MapOptions.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ extension MapOptions {
4141
/// - size: Size of the map, if nil (the default), a minimal default size will be used.
4242
/// - pixelRatio: Pixel scale of the map view; default is the main screen's native scale.
4343
/// - glyphsRasterizationOptions: A `GlyphsRasterizationOptions` object.
44+
/// - scaleFactor: Scale factor to scale Map icons and texts; default is `1.0`.
4445
public convenience init(constrainMode: ConstrainMode = .heightOnly,
4546
viewportMode: ViewportMode = .default,
4647
orientation: NorthOrientation = .upwards,
4748
crossSourceCollisions: Bool = true,
4849
size: CGSize? = nil,
4950
pixelRatio: CGFloat? = nil,
50-
glyphsRasterizationOptions: GlyphsRasterizationOptions = GlyphsRasterizationOptions(fontFamilies: [])) {
51+
glyphsRasterizationOptions: GlyphsRasterizationOptions = GlyphsRasterizationOptions(fontFamilies: []),
52+
scaleFactor: CGFloat = 1.0) {
5153

5254
let mbmSize: Size?
5355

@@ -64,7 +66,8 @@ extension MapOptions {
6466
crossSourceCollisions: crossSourceCollisions.NSNumber,
6567
size: mbmSize,
6668
pixelRatio: Float(pixelRatio ?? ScreenShim.nativeScale),
67-
glyphsRasterizationOptions: glyphsRasterizationOptions)
69+
glyphsRasterizationOptions: glyphsRasterizationOptions,
70+
scaleFactor: Float(scaleFactor))
6871
}
6972

7073
/// The map constrain mode. This can be used to limit the map to wrap around
@@ -110,6 +113,12 @@ extension MapOptions {
110113
return CGSize(width: Double(size.width), height: Double(size.height))
111114
}
112115

116+
/// Scale factor to scale map icons and texts. Default is `1.0`.
117+
@_spi(Experimental)
118+
public var scaleFactor: CGFloat {
119+
return CGFloat(__scaleFactor)
120+
}
121+
113122
public override func isEqual(_ object: Any?) -> Bool {
114123
guard let other = object as? MapOptions else {
115124
return false
@@ -126,7 +135,8 @@ extension MapOptions {
126135
(crossSourceCollisions == other.crossSourceCollisions) &&
127136
(size == other.size) &&
128137
(pixelRatio == other.pixelRatio) &&
129-
(glyphsRasterizationOptions == other.glyphsRasterizationOptions)
138+
(glyphsRasterizationOptions == other.glyphsRasterizationOptions) &&
139+
(scaleFactor == other.scaleFactor)
130140
}
131141

132142
open override var hash: Int {
@@ -137,6 +147,7 @@ extension MapOptions {
137147
hasher.combine(crossSourceCollisions)
138148
hasher.combine(pixelRatio)
139149
hasher.combine(glyphsRasterizationOptions)
150+
hasher.combine(scaleFactor)
140151
return hasher.finalize()
141152
}
142153
}

Sources/MapboxMaps/Foundation/Extensions/Core/MapSnapshotOptions.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ public struct MapSnapshotOptions: Sendable {
1010
/// By default, `GlyphsRasterizationOptions` will use `.ideographsRasterizedLocally`
1111
public var glyphsRasterizationOptions: GlyphsRasterizationOptions
1212

13+
/// Scale factor to scale map shapshot icons and texts. Default is `1.0`.
14+
@_spi(Experimental)
15+
public var scaleFactor: CGFloat
16+
1317
/// Flag that determines if the logo should be shown on the snapshot
1418
public var showsLogo: Bool
1519

@@ -25,12 +29,15 @@ public struct MapSnapshotOptions: Sendable {
2529
/// `.ideographsRasterizedLocally`
2630
/// - showsLogo: Flag that determines if the logo should be shown on the snapshot
2731
/// - showsAttribution: Flag that determines if attribution should be shown on the snapshot
32+
/// - scaleFactor: Scale factor to scale map snapshot icons and texts. Default is `1.0`.
2833
public init(size: CGSize,
2934
pixelRatio: CGFloat,
3035
glyphsRasterizationOptions: GlyphsRasterizationOptions = GlyphsRasterizationOptions(),
3136
showsLogo: Bool = true,
32-
showsAttribution: Bool = true) {
37+
showsAttribution: Bool = true,
38+
scaleFactor: CGFloat = 1.0) {
3339
precondition(pixelRatio > 0)
40+
precondition(scaleFactor > 0)
3441
precondition(size.width * pixelRatio <= 8192, "Width or scale too great.")
3542
precondition(size.height * pixelRatio <= 8192, "Height or scale too great.")
3643

@@ -39,14 +46,16 @@ public struct MapSnapshotOptions: Sendable {
3946
self.glyphsRasterizationOptions = glyphsRasterizationOptions
4047
self.showsLogo = showsLogo
4148
self.showsAttribution = showsAttribution
49+
self.scaleFactor = scaleFactor
4250
}
4351
}
4452

4553
extension MapSnapshotOptions {
4654
internal init(_ objcValue: CoreMapSnapshotOptions) {
4755
self.init(size: CGSize(objcValue.__size),
4856
pixelRatio: CGFloat(objcValue.pixelRatio),
49-
glyphsRasterizationOptions: objcValue.glyphsRasterizationOptions ?? GlyphsRasterizationOptions())
57+
glyphsRasterizationOptions: objcValue.glyphsRasterizationOptions ?? GlyphsRasterizationOptions(),
58+
scaleFactor: CGFloat(objcValue.__scaleFactor))
5059
}
5160
}
5261

@@ -56,6 +65,7 @@ extension CoreMapSnapshotOptions {
5665

5766
self.init(__size: Size(width: Float(size.width), height: Float(size.height)),
5867
pixelRatio: Float(swiftValue.pixelRatio),
59-
glyphsRasterizationOptions: swiftValue.glyphsRasterizationOptions)
68+
glyphsRasterizationOptions: swiftValue.glyphsRasterizationOptions,
69+
scaleFactor: Float(swiftValue.scaleFactor))
6070
}
6171
}

Sources/MapboxMaps/Foundation/MapInitOptions.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ extension MapInitOptions {
102102
crossSourceCollisions: mapOptions.__crossSourceCollisions,
103103
size: Size(width: Float(bounds.width), height: Float(bounds.height)),
104104
pixelRatio: mapOptions.pixelRatio,
105-
glyphsRasterizationOptions: mapOptions.glyphsRasterizationOptions)
105+
glyphsRasterizationOptions: mapOptions.glyphsRasterizationOptions,
106+
scaleFactor: mapOptions.__scaleFactor)
106107

107108
// Use the overriding style URI if provided (currently from IB)
108109
let resolvedStyleURI = overridingStyleURI.map { StyleURI(url: $0) } ?? styleURI

Tests/MapboxMapsTests/Foundation/MapboxMapTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ final class MapboxMapTests: XCTestCase {
5656
crossSourceCollisions: mapInitOptions.mapOptions.crossSourceCollisions.NSNumber,
5757
size: mapInitOptions.mapOptions.size.map(Size.init),
5858
pixelRatio: mapInitOptions.mapOptions.pixelRatio,
59-
glyphsRasterizationOptions: nil) // __map.getOptions() always returns nil for glyphsRasterizationOptions
59+
glyphsRasterizationOptions: nil, // __map.getOptions() always returns nil for glyphsRasterizationOptions
60+
scaleFactor: 1.0)
6061

6162
let actualMapOptions = mapboxMap.options
6263

scripts/api-compatibility-check/breakage_allowlist.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,3 +2186,7 @@ Func MapStyle.standard(theme:lightPreset:font:showPointOfInterestLabels:showTran
21862186
Func MapStyle.standard(theme:lightPreset:font:showPointOfInterestLabels:showTransitLabels:showPlaceLabels:showRoadLabels:showPedestrianRoads:show3dObjects:colorBuildingHighlight:colorBuildingSelect:colorMotorways:colorPlaceLabelHighlight:colorPlaceLabelSelect:colorRoads:colorTrunks:showLandmarkIcons:themeData:) has parameter 9 type change from MapboxMaps.StyleColor? to MapboxMaps.StandardBackgroundPointOfInterestLabels?
21872187
Func MapStyle.standardSatellite(lightPreset:font:showPointOfInterestLabels:showTransitLabels:showPlaceLabels:showRoadLabels:showRoadsAndTransit:showPedestrianRoads:colorMotorways:colorPlaceLabelHighlight:colorPlaceLabelSelect:colorRoads:colorTrunks:) has parameter 10 type change from MapboxMaps.StyleColor? to MapboxMaps.StandardColorModePointOfInterestLabels?
21882188
Func MapStyle.standardSatellite(lightPreset:font:showPointOfInterestLabels:showTransitLabels:showPlaceLabels:showRoadLabels:showRoadsAndTransit:showPedestrianRoads:colorMotorways:colorPlaceLabelHighlight:colorPlaceLabelSelect:colorRoads:colorTrunks:) has parameter 8 type change from MapboxMaps.StyleColor? to MapboxMaps.StandardBackgroundPointOfInterestLabels?
2189+
2190+
/* Removed Decls */
2191+
Constructor MapOptions.init(constrainMode:viewportMode:orientation:crossSourceCollisions:size:pixelRatio:glyphsRasterizationOptions:) has been removed
2192+
Constructor MapSnapshotOptions.init(size:pixelRatio:glyphsRasterizationOptions:showsLogo:showsAttribution:) has been removed

0 commit comments

Comments
 (0)