You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Backport release/v0.19] Update examples to show scale range layer properties (#10307)
Backport 0fcfdcc9e94c885329c84adeaf678917d1295ba9 from #10276.
cc @mapbox/maps-ios
cc @mapbox/maps-android
Co-authored-by: Patrick Leonard <pjleonard37@users.noreply.github.com>
GitOrigin-RevId: 6526544a7cf2e07f30bb723e2732119d375656a3
// Custom mapping: dampens large accessibility scales
223
+
mapboxMap.symbolScaleBehavior =.system(mapping:{ systemScale in
117
224
switch systemScale {
118
225
case..<1.0:
119
226
return systemScale *1.1 // Boost small scales by 10%
120
227
case1.0...1.3:
121
228
return systemScale // Keep medium scales unchanged
122
229
default:
123
-
return1.3+(systemScale -1.3)*0.4 // Dampen large scales (max ~1.6x)
230
+
return1.3+(systemScale -1.3)*0.4 // Dampen large scales
124
231
}
125
232
})
126
233
}
127
234
}
128
235
}
129
236
237
+
privatestructAccessibilityScaleInfoView:View{
238
+
varbody:someView{
239
+
ScrollView{
240
+
VStack(alignment:.leading, spacing:16){
241
+
Text("Accessibility Scale Example")
242
+
.font(.headline)
243
+
244
+
Text("This example demonstrates how to control symbol scaling for accessibility using the Maps SDK.")
245
+
.font(.subheadline)
246
+
247
+
VStack(alignment:.leading, spacing:12){
248
+
Group{
249
+
Text("Scale Factor")
250
+
.font(.subheadline.bold())
251
+
Text("Adjusts the global scale factor for all symbol layers on the map using the `symbolScaleBehavior` property. This affects both system map labels and custom annotations.")
252
+
.font(.footnote)
253
+
254
+
(Text("• ")+ Text("Fixed").bold()+ Text(": Manual control with a slider"))
255
+
.font(.footnote)
256
+
(Text("• ")+ Text("System").bold()+ Text(": Automatically scales based on the device's accessibility text size setting (Settings → Accessibility → Display & Text Size → Larger Accessibility Sizes)"))
257
+
.font(.footnote)
258
+
(Text("• ")+ Text("Custom").bold()+ Text(": Uses a custom mapping function to modify system scale values (e.g., dampen large scales)"))
259
+
.font(.footnote)
260
+
}
261
+
262
+
Divider()
263
+
264
+
Group{
265
+
Text("Icon Size Scale Range")
266
+
.font(.subheadline.bold())
267
+
Text("Sets the minimum and maximum scaling limits for icons using the `icon-size-scale-range` layout property. This only affects the custom blue annotations in this example.")
268
+
.font(.footnote)
269
+
270
+
Text("Example: Setting `[1.0, 1.0]` prevents icons from scaling regardless of the scale factor value.")
271
+
.font(.footnote)
272
+
.italic()
273
+
}
274
+
275
+
Divider()
276
+
277
+
Group{
278
+
Text("Text Size Scale Range")
279
+
.font(.subheadline.bold())
280
+
Text("Sets the minimum and maximum scaling limits for text using the `text-size-scale-range` layout property. This only affects the custom blue text labels in this example.")
281
+
.font(.footnote)
282
+
283
+
Text("Example: Setting `[0.5, 3.0]` allows text to scale from half size to triple size based on the scale factor.")
284
+
.font(.footnote)
285
+
.italic()
286
+
}
287
+
}
288
+
289
+
Divider()
290
+
291
+
Text("Try experimenting with different combinations:")
292
+
.font(.subheadline.bold())
293
+
294
+
Text("• Set scale factor to 2.0 with icon range [1.0, 1.0] to see text scale while icons stay the same size")
295
+
.font(.footnote)
296
+
Text("• Switch to System mode and change your device's text size in Settings to see automatic scaling")
297
+
.font(.footnote)
298
+
Text("• Use Custom mode to see how mapping functions can dampen extreme scale values")
0 commit comments