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.37k stars 1.32k forks source link

Sky and ground need distinct background colors #2190

Closed 1ec5 closed 4 years ago

1ec5 commented 9 years ago

The perspective view being added in #2116 and #2159 will constrain the pitch to 90° (at least at the mbgl level). MGLMapView currently constrains it further to 60° to avoid showing the horizon, but we’d like to use a limit that varies by zoom level (altitude) for consistency with MapKit. At the lowest altitude, about 7 stories up, MapKit shows an idyllic blue sky:

sky

By contrast, Mapbox GL uses the background color, which for most maps will be similar to the ground color. It should be possible to style a second background color that represents the “room in which the map is floating”, so to speak.

/ref #119, #1210 /cc @ansis @incanus

incanus commented 9 years ago

Do you see this happening at the platform level @1ec5? Like, could this just be a subview of the MGLMapView behind the GLKView?

1ec5 commented 9 years ago

The GLKView draws inside its entire bounds, doesn’t it?

incanus commented 9 years ago

Yes, but we might be able to make part of it transparent? Not sure.

ljbade commented 9 years ago

Shouldn't this be styleable, e.g. night vs daytime maps

1ec5 commented 8 years ago

A common workaround seen in navigation applications is to fake the presence of a sky by overlaying a view with a linear gradient from opaque blue at the top to clear at the bottom. However, the effect is artificial at best, because it violates the user’s sense of horizon.

Another workaround, more common in games, is to simulate poor visibility with a fog effect. It’s basically the same as the previous workaround, except using opaque gray and a steeper gradient. Neither of these workarounds will work once we have 3D extrusion (#6745), because the extruded geometries will be truncated at the simulated horizon.

As @incanus indicated in https://github.com/mapbox/mapbox-gl-native/issues/2190#issuecomment-135511297, it may be possible to make MGLMapView’s layer non-opaque, taking advantage of #3096, then place a view with the desired background color behind the MGLMapView. However, this would have to happen on a per-application basis, because styles themselves can have transparent backgrounds for other reasons.

1ec5 commented 8 years ago

we’d like to use a limit that varies by zoom level (altitude) for consistency with MapKit

6908

1ec5 commented 8 years ago

it may be possible to make MGLMapView’s layer non-opaque, taking advantage of #3096, then place a view with the desired background color behind the MGLMapView

No, that won’t work, because – as I originally described above – the sky and ground are rendered using the same background style layer. If you make the background style layer transparent and slide a blue view beneath the map view, the ground becomes blue too.

mdakram commented 7 years ago

Any update on this?

ansis commented 7 years ago

@mdakram nope, we haven't fixed the things blocking us from allowing the map to be pitched far enough to have the sky show (level-of-detail loading, antialiasing issues, etc).

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.

astojilj commented 4 years ago

Dependent on https://github.com/mapbox/mapbox-gl-js/pull/8975.

stale[bot] commented 4 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.

Higuy8000 commented 3 years ago

Is this still an issue?

I tried adding a sky layer, which seems like the general type of thing for this, but I get the following error:

map_->addLayer({ {"id", "sky"}, {"type", "sky"} }, "background);

but it returns the error

Unable to add layer: Unsupported layer type! Null factory for type: sky

I can set a background color just fine before my raster map tiles, but this does not affect the area of the screen "off the map".

Using with Qt 5.15. I just want to set the color of the background past the map when you pitch up/see past the horizon.