mapbox / mapbox/mapbox-maps-ios
ElevationData getelevationfor**(_:) from outdoors map layers does not work
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
 Environment
Xcode version: Version 15.2 (15C500b)
iOS version: iOS17
Devices affected: iPhone15
Maps SDK Version: 11.2.0 (same behavior with 11.1.0)
## Observed behavior and steps to reproduce
Pre-condition:
Create a SwiftUI mapview using
```
let locationProvider = AppleLocationProvider()
var mapStyle: MapStyle = .outdoors
MapReader { proxy in
Map(viewport: $viewport) {
...
}
.onMapLongPressGesture { context in
// Get elevation from map
print("Elevation: \(proxy.map?.elevation(at: locationProvider.getLastObservedLocation()!.coordinate))m, location:\(locationProvider.getLastObservedLocation()!.coordinate)")
}
}
```
coordinate is a CLLocationCoordinate2D and points to a visible region on the screen.
printed elevation is always "nil' regardless whether mapstyle is set to outdoors, zoom scale and contour lines with contour line elevation (e.g. 300m) are displayed on the map.
printed message is: Elevation: nilm, location:CLLocationCoordinate2D(latitude: 34.88005051423801, longitude: 5.031331175034814)
## Expected behavior
https://docs.tilestream.net/ios/maps/api/latest/documentation/mapboxmaps/mapboxmap/elevation(at:)
func elevation(at coordinate: CLLocationCoordinate2D) -> Double?
return a value according the visible contour lines or other estimation method of features shown on map.
## Notes / preliminary analysis
Additional layers are programmatically added in slot .middle and .top
## Additional links and references
protocol ElevationData
https://docs.tilestream.net/ios/maps/api/latest/documentation/mapboxmaps/elevationdata/#instance-methods
[func getElevationFor(CLLocationCoordinate2D) -> NSNumber?](https://docs.tilestream.net/ios/maps/api/latest/documentation/mapboxmaps/elevationdata/**getelevationfor**(_:))
getelevationfor(_:) works according specification and returns the terrain elevation in m.
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
Reproduce the issue with the SwiftUI MapReader/Map setup, iOS 17, SDK 11.2.0, and .outdoors style, then inspect the elevation(at:) path alongside ElevationData.getElevationFor(_:). Compare the nil result with the displayed contour lines and the documented expected Double? result; done when a visible coordinate returns the expected elevation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100