Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Including direction in setVisibleCoordinates calculates the viewport incorrectly #12075

Closed
TimWatson opened this issue Jun 6, 2018 · 7 comments
Assignees
Labels
iOS Mapbox Maps SDK for iOS support

Comments

@TimWatson
Copy link

TimWatson commented Jun 6, 2018

If you include direction when setting the visible coordinates it calculates the viewport first and then rotates the map resulting in an incorrect viewport.

Example:

var coordinates = [CLLocationCoordinate2D(latitude: 34.407548, longitude: -119.8696609),
							   CLLocationCoordinate2D(latitude: 34.4211754, longitude: -119.8394465)]
let padding = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
let direction = CLLocationDirection(90)
let animation = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
mapView.setVisibleCoordinates(&coordinates, count: UInt(coordinates.count), edgePadding: padding, direction: direction, duration: 0.4, animationTimingFunction: animation, completionHandler: nil)

iOS 11.4
Mapbox 4.0.1, 4.0.2

- (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion;

@julianrex
Copy link
Contributor

Thanks for the report @TimWatson

@julianrex julianrex added bug iOS Mapbox Maps SDK for iOS labels Jun 7, 2018
@stale stale bot added the archived Archived because of inactivity label Dec 4, 2018
@stale
Copy link

stale bot commented Dec 5, 2018

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Dec 5, 2018
@TimWatson
Copy link
Author

lol what. Does that mean this isn't getting fixed?

@julianrex
Copy link
Contributor

Still on our list!

@julianrex julianrex reopened this Dec 5, 2018
@stale stale bot removed the archived Archived because of inactivity label Dec 5, 2018
@fabian-guerra fabian-guerra self-assigned this Jan 15, 2019
@fabian-guerra fabian-guerra added support and removed bug labels Jan 18, 2019
@fabian-guerra
Copy link
Contributor

Hi @TimWatson. Thank you for using Mapbox. When you start the map it has a direction = 0 (north according to the docs). If you set the direction to 90 degrees then it will rotate to the east. If you require that the map view keep it's direction I suggest use:

mapView.setVisibleCoordinates(&coordinates, count: UInt(coordinates.count), edgePadding: padding, direction: mapView.direction, duration: 0.4, animationTimingFunction: animation, completionHandler: nil)

@TimWatson
Copy link
Author

Hi Fabian, thanks for getting back to me. I need both the direction and the visible bounds to change but when using this function it currently calculates the new map bounds to fit the required visible bounds and then it applies the rotation. That means that the calculation is now wrong since the required visible bounds now fit differently in the new, rotated, map viewport. Your suggestion doesn't solve this issue.

@fabian-guerra
Copy link
Contributor

Fixed in #13761

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS support
Projects
None yet
Development

No branches or pull requests

3 participants