mapbox / mapbox/mapbox-maps-ios
Black terrain, map only visible with high pitch values
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
This is the same as issue #1438, which was closed because of a lack of repro, but still occurring. Please let me know if there's more information I could provide to help repro.
Basically the map is black when i set the terrain. Zooming way out and tilting the map results in some non-black tiles being shown. The tiles all seem to be downloaded and rendered, but they're obscured. It seems to me that the default map layer is rendered and the black overlays are partially downloaded/rendered terrain tiles.
When just 2-finger pitch adjusting, the black sky disappears as the pitch reduces to bird's eye view, as one would expect. But instead of staying hidden when the horizon reaches the top of the screen, the horizon starts coming back down and the black sky starts covering the map again, almost like it's using an absolute value to determine position instead of clamping to 0.
Reproducible with:
- Xcode 14.1 - iPhone 14 Pro canvas
- MapboxCommon 23.3.0-beta.1
- MapboxCoreMaps 10.11.0-beta.1
- MapboxMaps main (downloaded this week)
- Turf 2.6.1
here's the terrain code:
internal func addTerrainLayer(mapView: MapView) {
var demSource = RasterDemSource()
demSource.url = "mapbox://mapbox.mapbox-terrain-dem-v1"
demSource.tileSize = 512
demSource.maxzoom = 14
try! mapView.mapboxMap.style.addSource(demSource, id: "mapbox-dem")
var terrain = Terrain(sourceId: "mapbox-dem")
terrain.exaggeration = .constant(2)
do {
try mapView.mapboxMap.style.setTerrain(terrain)
} catch {
print("Failed to add a terrain layer to the map's style.")
}
}
(same issue occurs with mapbox://mapbox.terrain-rgb)
camera options:
let cameraOptions = CameraOptions(
center: CLLocationCoordinate2D(latitude: 39.604909, longitude: -106.356534),
zoom: 12,
bearing: 0,
pitch: 0)
some screenshots ...
this is the black "sky" coming back down over the map, even though the horizon is out of bounds, well above the screen area:

this is with no pitch, zoomed in vs. out:


Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the terrain rendering issue on the listed Xcode, MapboxCommon, MapboxCoreMaps, MapboxMaps, and Turf versions using the addTerrainLayer(mapView:) code and CameraOptions shown. Check the terrain and pitch behavior described in the screenshots; done means the map remains visible without black terrain or sky overlays at the reported camera angles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- computer-graphics, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100