mapbox / mapbox/mapbox-maps-ios
Enable Off-Screen Coordinate Pixel Calculation (Bypass .fit() Transformation)
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
## New Feature
I propose an enhancement to the iOS SDK’s coordinate-to-screen-point conversion. Currently, the `point(for:)` function returns (-1, -1) for off-screen coordinates due to the final `.fit(to: size)` call:
```swift
public func point(for coordinate: CLLocationCoordinate2D) -> CGPoint {
return __map.pixelForCoordinate(for: coordinate).point.fit(to: size)
}
```
In my use case —with a constant map pitch of 0 and coordinates close to the screen— I need access to the raw pixel values even if the point is off-screen. I suggest either:
* Exposing map.pixelForCoordinate directly, or
* Adding an alternative function (e.g., unsafePixelForCoordinate) that omits the .fit() transformation, along with clear documentation warning about its potential pitfalls.
## Why
This feature is valuable for developing custom overlays, annotations, and animations that require off-screen coordinate calculations. While Mapbox Kotlin SDK developers might use reflection to access hidden methods, this approach is neither desirable nor possible in Swift.
Contributor guide
Research direction
Start with the iOS SDK's point(for:) function and the referenced __map.pixelForCoordinate call. Trace how the final .fit(to: size) transformation handles off-screen points, then review the public API and documentation conventions. Done means an agreed, documented way to obtain raw off-screen pixel values without changing existing point(for:) behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- api, mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100