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
UIScreen.main will always return a UIScreen instance that corresponds to the iPhone's built-in display.
If your CarPlay-capable app is a Navigation app (and therefore receives a CPWindow to draw your map content into), you can get the UIScreen for the CarPlay display through your CPTemplateApplicationScene:
Describe the solution you'd like
Don't use the mainScreen, but use the screen where the map is drawn on (and maybe fallback to main if none is given).
The dev forum describes the solution like:
let carPlayScreen = templateApplicationScene.carWindow.screen
Describe alternatives you've considered
I assume there is also a way to get the screen from the view tree / hierarchy?
Alternatively it could also work that implementers pass a scale from the outside into MlnMapview?
Additional context
In our case, the CarPlay map is rendered too large proportionally to the screen size. So there is less area covered.
The text was updated successfully, but these errors were encountered:
// Set the correct scale of the map
let carPlayScreen = self.templateApplicationScene?.carWindow.screen
if let scale = carPlayScreen?.scale {
mapView.contentScaleFactor = scale
}
Doesn't this scales the map on UIKit level, means after the map content was rendered? The metal rendering does not respect the contentScaleFactor of UIKit and therefore takes the wrong scaleFactor. This could lead to wrong sizes and unneeded performance overhead (if I am not completely wrong)
Is your feature request related to a problem? Please describe.
Maplibre-Native calculates the scaleFactor like this:
maplibre-native/platform/ios/src/MLNMapView+Metal.mm
Line 39 in a8f4f70
As far as I understand, this can lead to issues if your phone has a different scale than your CarPlay screen.
As described in the apple dev forum:
Describe the solution you'd like
Don't use the mainScreen, but use the screen where the map is drawn on (and maybe fallback to main if none is given).
The dev forum describes the solution like:
let carPlayScreen = templateApplicationScene.carWindow.screen
Describe alternatives you've considered
I assume there is also a way to get the screen from the view tree / hierarchy?
Alternatively it could also work that implementers pass a scale from the outside into MlnMapview?
Additional context
In our case, the CarPlay map is rendered too large proportionally to the screen size. So there is less area covered.
The text was updated successfully, but these errors were encountered: