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
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
I've set a background colour on my MGLMapView, to the background of the Streets style, so it looks a little less jarring when loading. However, it still flashes black while loading the map for the first time. It'd be great if it could keep the background colour until the style is fully loaded.
The fix in #3096 only takes effect if you set MGLMapView.opaque = NO; otherwise, UIKit considers the behavior to be undefined if the map view fails to draw its entire bounds. So setting opaque = NO is the recommended way to deal with the black flash.
isOpaque should be false by default since that is the behavior of almost all UIKit views since iOS 7 almost four years ago. The black flash alone is why my boss decided that we would use Google Maps instead. :P
As of the iOS 10 SDK, UIView.isOpaque is true by default, and so is MKMapView.isOpaque.
The black flash you’re seeing is more likely the style’s background layer being rendered before the other layers come in, since the other layers likely require fetching vector tiles. (This is the phase in which MapKit would render a graticule: see #119.)
The background color of a style usually matches the color of land, although Mapbox Satellite and Satellite Streets have black as their background color. You can configure the background color by customizing a style in Mapbox Studio or, as of the upcoming Mapbox iOS SDK v3.4.0 beta, by modifying (mapView.style.layers.last as? MGLBackgroundStyleLayer)?.backgroundColor inside MGLMapViewDelegate.mapView(_:didFinishLoadingStyle:).
If you’re seeing a noticeable black flash despite the style’s background color being set to something lighter, I agree that we should revisit this issue and find a better solution.
UIView, probably, the majority of UIKit, certainly not. It is easy enough to test, almost all of my apps are clear background views (UILabel, UITableView, UIButton, UI*) and I get no black flashes due to opaqueness being true.
The black flash you’re seeing is more likely the style’s background layer being rendered before the other layers come in, since the other layers likely require fetching vector tiles. (This is the phase in which MapKit would render a graticule: see #119.)
I set isOpaque to false and the black flash stopped…
I don’t mean to be stubborn; just wondering whether we’re missing something that allows MapKit to default to being opaque but still avoid the black flash. I’ve opened #7256 to track defaulting isOpaque to NO, as you’ve requested.
Activity
1ec5 commentedon Nov 23, 2015
This would be fixed by #3096 I believe.
tomtaylor commentedon Nov 23, 2015
Ah ha, thanks.
abpopov commentedon Dec 9, 2015
I solve this by this code
mapView.layer.backgroundColor =[[UIColor clearColor] CGColor];
friedbunny commentedon Jan 15, 2016
Fixed by #3096.
1ec5 commentedon Jan 15, 2016
The fix in #3096 only takes effect if you set
MGLMapView.opaque = NO; otherwise, UIKit considers the behavior to be undefined if the map view fails to draw its entire bounds. So settingopaque = NOis the recommended way to deal with the black flash.Fix MGLMapView black flicker during initial loading.
mxcl commentedon Nov 30, 2016
isOpaqueshould befalseby default since that is the behavior of almost all UIKit views since iOS 7 almost four years ago. The black flash alone is why my boss decided that we would use Google Maps instead. :P1ec5 commentedon Nov 30, 2016
As of the iOS 10 SDK,
UIView.isOpaqueistrueby default, and so isMKMapView.isOpaque.The black flash you’re seeing is more likely the style’s background layer being rendered before the other layers come in, since the other layers likely require fetching vector tiles. (This is the phase in which MapKit would render a graticule: see #119.)
The background color of a style usually matches the color of land, although Mapbox Satellite and Satellite Streets have black as their background color. You can configure the background color by customizing a style in Mapbox Studio or, as of the upcoming Mapbox iOS SDK v3.4.0 beta, by modifying
(mapView.style.layers.last as? MGLBackgroundStyleLayer)?.backgroundColorinsideMGLMapViewDelegate.mapView(_:didFinishLoadingStyle:).If you’re seeing a noticeable black flash despite the style’s background color being set to something lighter, I agree that we should revisit this issue and find a better solution.
mxcl commentedon Dec 1, 2016
UIView, probably, the majority of UIKit, certainly not. It is easy enough to test, almost all of my apps are clear background views (UILabel, UITableView, UIButton, UI*) and I get no black flashes due to opaqueness being true.I set
isOpaqueto false and the black flash stopped…1ec5 commentedon Dec 1, 2016
I don’t mean to be stubborn; just wondering whether we’re missing something that allows MapKit to default to being opaque but still avoid the black flash. I’ve opened #7256 to track defaulting
isOpaquetoNO, as you’ve requested.