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

[ios, macos] clarified documentation for newCamera param of the shouldChangeFromCamera delegate #14680

Merged
merged 2 commits into from
May 16, 2019

Conversation

samfader
Copy link
Contributor

The newCamera parameter available in the shouldChangeFromCamera: delegate is described as if it becomes a modifiable new camera object - this is not entirely true, and this update to the documentation describes how it works a bit more clearly.

cc @captainbarbosa @fabian-guerra

@samfader samfader added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS documentation labels May 15, 2019
@samfader samfader requested review from captainbarbosa and a team May 15, 2019 19:07
Copy link
Contributor

@fabian-guerra fabian-guerra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just another copy change.

@@ -66,7 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
gesture is recognized. If this method returns `NO`, the map view’s camera
continues to be this camera.
@param newCamera The expected camera after the gesture completes. If this
method returns `YES`, this camera becomes the map view’s camera.
method returns `YES`, the viewport of the map will transition to the new camera. Note that the new camera cannot be modified.
@param reason The reason for the camera change.
@return A Boolean value indicating whether the map view should stay at
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be also changed to:

A boolean value indicating wether the map view should stay at oldCamera or transition to newCamera.

Copy link
Contributor

@captainbarbosa captainbarbosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like @fabian-guerra's suggestion, so consider this approved with his suggested change 👍 thanks!

@natalia-osa
Copy link

natalia-osa commented May 15, 2019

Why not do it the other way around? Passing newCamera as a reference - so it'd be editable for those who want it, or not for those who don't want it. Or make another delegate to eventually edit it if you want to keep in sync with the old version. Letting the user edit it makes so much sense.

2 examples why it's so useful to edit newCamera:

  1. When someone wants to handle restricting map panning to an area in a better way, than just prohibiting any movement when you're close to map border. In reality, when bounds are eg set to US, one would rather prefer not to stop the movement from New York to Pekin, but allow to move it behind California, to the border of US. Returning NO in this method, as you do in the sample (https://docs.mapbox.com/ios/maps/examples/constraining-gestures/), works far from perfect. A simple change to newCamera and overwriting location would be sufficient to do it.

  2. If you open Google Maps at zoom 6, centre to UK and scroll right/left you will see the map gets rotated as well. In this scenario, they're doing the rotation to mimic north pole. A simple change of heading in newCamera would be sufficient to do it.

I think it's not the documentation what should be changed but logic. The documentation is pointing the right direction.

@fabian-guerra
Copy link
Contributor

@natalia-osa the update in the documentation is to reflect what is currently happening. The value passed in newCamera is a projection considering the ongoing gesture values (direction, velocity, scale, etc). Due to is a projection we use it with the solely purpose of let you know the camera trajectory.

We also welcome contributions.

@captainbarbosa captainbarbosa force-pushed the sf-camera-doc-update branch from 1f3acf3 to 0a70082 Compare May 15, 2019 23:49
@samfader samfader merged commit 163c085 into master May 16, 2019
@captainbarbosa captainbarbosa deleted the sf-camera-doc-update branch May 16, 2019 03:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants