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

Allow direct setting of MGLMapView.camera properties #8930

Closed
friedbunny opened this issue May 9, 2017 · 5 comments
Closed

Allow direct setting of MGLMapView.camera properties #8930

friedbunny opened this issue May 9, 2017 · 5 comments
Labels
archived Archived because of inactivity iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS

Comments

@friedbunny
Copy link
Contributor

If we can find a reasonably safe way, we should allow properties such as MGLMapView.camera.pitch and friends to be set directly, rather than via a round-about method.

This:

map.camera = MGLMapCamera(lookingAtCenter: startingCenter, altitude: altitude, heading: 0, pitch: 60)

... could become:

map.camera.pitch = 60

/cc @1ec5 @incanus

@friedbunny friedbunny added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS labels May 9, 2017
@1ec5
Copy link
Contributor

1ec5 commented May 9, 2017

Off the top of my head, we could have MGLMapCamera maintain a backpointer to the MGLMapView that created it, or MGLMapView could observe changes to that MGLMapCamera’s properties. With KVO, it would be tricky to remove the observers at the right time.

With either approach, we’d need to figure out what to do when the same MGLMapCamera instance is set on two different MGLMapView’s – say, if the two map views are to be kept in sync. The developer would then expect a change to the camera’s property to affect both map views at the same time.

A third approach would be to use NSNotificationCenter somehow.

@jmkiley
Copy link
Contributor

jmkiley commented May 11, 2017

It is currently a little confusing, since you can type mapView.camera.pitch = 40, for example, but it doesn't change the pitch.

Since it's readwrite, we may want to update documentation with how to actually set camera properties.

@1ec5
Copy link
Contributor

1ec5 commented May 11, 2017

we may want to update documentation with how to actually set camera properties.

I would agree if we intend to keep that behavior. But if we intend to make it possible to set the pitch directly like that, then I guess we’d consider the current behavior to be essentially a bug that isn’t to be documented.

@1ec5
Copy link
Contributor

1ec5 commented Jun 8, 2017

This will surely exacerbate #3625: developers will attempt to set the center coordinate, heading, and pitch directly on the map view on separate lines, but each successive property write will cancel the previous one.

Essentially, the current behavior makes MGLMapCamera a transactional API, which suits our (hobbled) animation model well.

@stale
Copy link

stale bot commented Nov 30, 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 Nov 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived Archived because of inactivity iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS
Projects
None yet
Development

No branches or pull requests

3 participants