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 clipping to viewport when converting coordinates to screen position #2179

Merged
merged 6 commits into from
Jul 21, 2020

Conversation

matteblair
Copy link
Member

This addresses some uncommon situations where converting a geographic coordinate to a screen position does not have a meaningful result, as described in #2165

This change adds a method to convert coordinates to screen positions "clipped" to the viewport, internally resolving the problematic edge cases.

@matteblair
Copy link
Member Author

To summarize what this looks like for SDK users:

On Android, MapController has a new method that converts a LngLat into a screen position as a PointF and can optionally clip the result to the viewport. The return value is true when the original point is in the current viewport.

public boolean lngLatToScreenPosition(@NonNull final LngLat lngLat, @NonNull final PointF screenPositionOut, boolean clipToViewport)

On iOS, TGMapView has one changed method and one new method (because out-parameters translate to Swift very poorly). First, the signature for viewPositionFromCoordinate now takes a boolean option for clipping to the viewport.

- (CGPoint)viewPositionFromCoordinate:(CLLocationCoordinate2D)coordinate clipToViewport:(BOOL)clip;

There's a separate method to check if a coordinate is in the current viewport.

-(BOOL)viewportContainsCoordinate:(CLLocationCoordinate2D)coordinate;

@matteblair matteblair merged commit 1671b1b into master Jul 21, 2020
@matteblair matteblair deleted the lnglat2screen-clipped branch July 21, 2020 07:00
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

Successfully merging this pull request may close these issues.

1 participant