Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Off-Screen Coordinate Pixel Calculation (Bypass .fit() Transformation) #2294

Open
Ltei opened this issue Feb 21, 2025 · 0 comments
Open

Comments

@Ltei
Copy link

Ltei commented Feb 21, 2025

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:

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.

@Ltei Ltei changed the title point(for coordinate) when coordinate is out of screen Enable Off-Screen Coordinate Pixel Calculation (Bypass .fit() Transformation) Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant