mapbox / mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
4.36k stars 1.33k forks source link

Automatically adapt Mapbox Streets–sourced layers for Dynamic Type #7030

Open 1ec5 opened 7 years ago

1ec5 commented 7 years ago

When a user adjusts the Dynamic Type or Accessibility Type setting in the Accessibility section of Settings, any style based on the Mapbox Streets source should automatically adjust by making the labels larger or smaller. We could make this behavior configurable for all layers, regardless of source, by having MGLStyleLayer conform to UIContentSizeCategoryAdjusting.

MGLMapView can observe UIContentSizeCategoryDidChangeNotification and respond by obtaining UIApplication.preferredContentSizeCategory, determining the identifiers of the sources whose URL matches mapbox://mapbox.mapbox-streets-v*, and adjusting the textSize of any MGLSymbolStyleLayer whose sourceIdentifier is one of those source identifiers.

Iterating over all the sources and style layers will require #6097. Discovering whether a source is Mapbox Streets will require #6584.

/ref tangrams/tangram-es#920 /cc @incanus @pveugen @boundsj @frederoni

1ec5 commented 7 years ago

This is an alternative approach to #2429 that I think would be less aggressive.

https://github.com/mapbox/mapbox-gl-native/issues/2429#issuecomment-143821971 points out that shield images would need to be scaled to fit their text. We’d have to work out how the iconTextFit property fits in with this proposal.

1ec5 commented 7 years ago

7031 would rely on a similar mechanism. I suspect localizing labels would be less cartographically disruptive than changing their size, but I think both should ultimately be the responsibility of the SDK.

kkaefer commented 7 years ago

I don't think we should implement that kind of style manipulation at an SDK level. We need that feature on Android as well and should add it to core.

1ec5 commented 7 years ago

That's true; accessibility text sizes aren't as specific to a particular source as languages are. The approach described here would require core changes, anyhow, because UIContentSizeCategoryAdjusting conformance needs to be implemented in a way that persists for the lifetime of an mbgl::style::Layer, not just an MGLStyleLayer that happens to wrap it.

felixLam commented 7 years ago

For anyone interested we have open-sourced a "simple" approach to adjusting the fonts to match the user's preferred content size: https://github.com/iosphere/ISHMapboxDynamicFontObserver

hyerra commented 6 years ago

Just double checking but is dynamic type functionality integrated into MapBox yet and if so how do we implement this on iOS?

stale[bot] commented 5 years ago

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

friedbunny commented 5 years ago

Still a thing that needs to be done, stalebot.

stale[bot] commented 5 years ago

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.