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

Camera API #2193

Merged
merged 2 commits into from
Sep 7, 2015
Merged

Camera API #2193

merged 2 commits into from
Sep 7, 2015

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Aug 27, 2015

The pre-existing methods on mbgl::Map only allow you to modify 2–3 degrees of freedom at once. This PR adds the concept of the viewer’s “camera”, allowing you to transition center coordinate, zoom level, rotation, and pitch all in one animation, and to configure that animation. The camera is represented by a CameraOptions struct and manipulated by jumpTo() and easeTo() methods, much like in Mapbox GL JS. On iOS, the camera is represented by an MGLMapCamera object that imitates MKMapCamera.

(This PR was originally opened by @bleege as #2159, but we’ll need to merge into master instead of the perspective branch now that #2116 has landed.)

/cc @incanus @friedbunny @ansis @bleege

@1ec5 1ec5 added feature GL JS parity For feature parity with Mapbox GL JS iOS Mapbox Maps SDK for iOS ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Aug 27, 2015
@1ec5 1ec5 self-assigned this Aug 27, 2015
@1ec5 1ec5 added this to the ios-v2.1.0 milestone Aug 27, 2015
@1ec5 1ec5 mentioned this pull request Aug 27, 2015
@incanus
Copy link
Contributor

incanus commented Aug 27, 2015

🎥 😛 👍

@1ec5
Copy link
Contributor Author

1ec5 commented Aug 28, 2015

One small change here is that, where currently possible, I’ve changed some animation timing curves from linear to the system default, which eases in a little. So that’ll make the user dot move a little less jarringly, at least until we manage to make it move continuously (and animate linearly) for #1582.

void Map::setPitch(double pitch) {
transform->setPitch(std::min(pitch, 60.0) * M_PI / 180);
void Map::setPitch(double pitch, const Duration& duration) {
transform->setPitch(util::clamp(pitch, 0., 90.) * M_PI / 180, duration);
Copy link
Contributor

Choose a reason for hiding this comment

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

The 60 here was intentional. We don't support level of detail loading so if the pitch is set it to 90 it will try to load all the tiles in the world

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, right, this is an artifact from rebasing.

@1ec5 1ec5 force-pushed the 1ec5-camera-1834 branch 2 times, most recently from 822cc57 to 02cc15f Compare September 4, 2015 22:17
@1ec5 1ec5 mentioned this pull request Sep 4, 2015
@1ec5 1ec5 removed the ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold label Sep 4, 2015
@1ec5 1ec5 changed the title [WIP] Camera API Camera API Sep 4, 2015
@1ec5
Copy link
Contributor Author

1ec5 commented Sep 4, 2015

Momentarily punting on #256 and #2266, but that’s what I’ll look at next. Does this look ready to merge @incanus?

@incanus
Copy link
Contributor

incanus commented Sep 4, 2015

Cursory glance looks good. Let me pull it down & double-check.

@incanus
Copy link
Contributor

incanus commented Sep 4, 2015

No red flags to me, but we'll roll a build and make sure things feel good. I think at this point we are 👍.

@@ -0,0 +1,36 @@
#import "Mapbox.h"

#pragma once
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious @1ec5 why this is required, for an iOS header which should be brought in with the once-safe #import vs. #include anyway.

@incanus
Copy link
Contributor

incanus commented Sep 7, 2015

Per chat last week, this is ready to merge; additional milestones will be hit in #256 and #2266.

1ec5 added 2 commits September 7, 2015 09:22
Plumbed camera options all the way through to MGLMapView. Added a method that lets you specify a direction in addition to center point and zoom level.

Added Map::jumpTo() for parity with mapbox-gl-js. Replaced usage of Map::setLatLng() and Map::setLatLngZoom() with Map::jumpTo() or Map::easeTo() within MGLMapView. Replaced MGLMapView.pitch with MGLMapCamera for setting all supported degrees of freedom simultaneously. Simultaneously move and rotate with course.

Support customizable timing functions on iOS.

iosapp now persists an archived MGLMapCamera instead of separate viewpoint properties and also synchronizes user defaults on termination. This change implements persistence entirely in Objective-C, eliminating the use of the Objective-C++ implementation.

Fixes #1643, fixes #1834. Ref #1581.
@incanus incanus merged commit 7b93107 into master Sep 7, 2015
@incanus incanus deleted the 1ec5-camera-1834 branch September 7, 2015 16:23
friedbunny added a commit that referenced this pull request Sep 8, 2015
Previously in #2265 we would ask for location permission at app startup if `!settings->showsUserLocation`. #2193 0a172a2 changed the way we used `NSUserDefaults` and mostly removed the `settings` object, which broke #2265.

Rather than fix our pestering location permissions ask at startup, this commit now only asks for location permissions when the user hits the locate-me button.

Once a user grants permission, the user dot appears because a `userTrackingMode` is set, `showsUserLocation` is permanently set to `YES` in `NSUserDefaults` and is restored at launch.
friedbunny added a commit that referenced this pull request Sep 11, 2015
Previously in #2265 we would ask for location permission at app startup if `!settings->showsUserLocation`. #2193 0a172a2 changed the way we used `NSUserDefaults` and mostly removed the `settings` object, which broke #2265.

Rather than fix our pestering location permissions ask at startup, this commit now only asks for location permissions when the user hits the locate-me button.

Once a user grants permission, the user dot appears because a `userTrackingMode` is set, `showsUserLocation` is permanently set to `YES` in `NSUserDefaults` and is restored at launch.
@bleege bleege mentioned this pull request Oct 26, 2015
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this pull request Nov 6, 2015
Previously in mapbox#2265 we would ask for location permission at app startup if `!settings->showsUserLocation`. mapbox#2193 0a172a2 changed the way we used `NSUserDefaults` and mostly removed the `settings` object, which broke mapbox#2265.

Rather than fix our pestering location permissions ask at startup, this commit now only asks for location permissions when the user hits the locate-me button.

Once a user grants permission, the user dot appears because a `userTrackingMode` is set, `showsUserLocation` is permanently set to `YES` in `NSUserDefaults` and is restored at launch.
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this pull request Nov 6, 2015
Previously in mapbox#2265 we would ask for location permission at app startup if `!settings->showsUserLocation`. mapbox#2193 0a172a2 changed the way we used `NSUserDefaults` and mostly removed the `settings` object, which broke mapbox#2265.

Rather than fix our pestering location permissions ask at startup, this commit now only asks for location permissions when the user hits the locate-me button.

Once a user grants permission, the user dot appears because a `userTrackingMode` is set, `showsUserLocation` is permanently set to `YES` in `NSUserDefaults` and is restored at launch.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature GL JS parity For feature parity with Mapbox GL JS iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS setDirection:animated: cancels setCenterCoordinate:animated: flyTo equivalent
3 participants