summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2019-02-27 19:58:35 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-04 14:45:32 +0200
commit21a39306da56c5d2c88447ba5ea053a7f989480a (patch)
tree7b932a7bb81c2de64546ef52bd72feb5aa4317c7
parentf5f10ec11989ccb403c2cd4261db74c44b263558 (diff)
downloadqtlocation-mapboxgl-21a39306da56c5d2c88447ba5ea053a7f989480a.tar.gz
[core] Remove map pitch setters/getters
-rw-r--r--include/mbgl/map/map.hpp5
-rwxr-xr-xplatform/android/src/native_map_view.cpp5
-rw-r--r--platform/ios/src/MGLMapView.mm9
-rw-r--r--platform/macos/src/MGLMapView.mm7
-rw-r--r--platform/node/src/node_map.cpp2
-rw-r--r--platform/qt/src/qmapboxgl.cpp4
-rw-r--r--src/mbgl/map/map.cpp22
7 files changed, 20 insertions, 34 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index b05747df8d..5674902fe9 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -107,11 +107,6 @@ public:
void resetNorth(const AnimationOptions& = {{mbgl::Milliseconds(500)}});
void resetNorth(const EdgeInsets&, const AnimationOptions& = {{mbgl::Milliseconds(500)}});
- // Pitch
- void setPitch(double pitch, const AnimationOptions& = {});
- void setPitch(double pitch, optional<ScreenCoordinate>, const AnimationOptions& = {});
- double getPitch() const;
-
// North Orientation
void setNorthOrientation(NorthOrientation);
NorthOrientation getNorthOrientation() const;
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 4755cc28c4..94bcbe3cab 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -395,11 +395,12 @@ void NativeMapView::resetPosition(jni::JNIEnv&) {
}
jni::jdouble NativeMapView::getPitch(jni::JNIEnv&) {
- return map->getPitch();
+ return *map->getCameraOptions().pitch;
}
void NativeMapView::setPitch(jni::JNIEnv&, jni::jdouble pitch, jni::jlong duration) {
- map->setPitch(pitch, mbgl::AnimationOptions{mbgl::Milliseconds(duration)});
+ map->easeTo(mbgl::CameraOptions().withPitch(pitch),
+ mbgl::AnimationOptions{ mbgl::Milliseconds(duration) });
}
void NativeMapView::setZoom(jni::JNIEnv&, jni::jdouble zoom, jni::jdouble x, jni::jdouble y, jni::jlong duration) {
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index aa57f75e16..a7f201e8cf 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -2076,7 +2076,7 @@ public:
if (twoFingerDrag.state == UIGestureRecognizerStateBegan)
{
- initialPitch = self.mbglMap.getPitch();
+ initialPitch = *self.mbglMap.getCameraOptions().pitch;
[self trackGestureEvent:MMEEventGesturePitchStart forRecognizer:twoFingerDrag];
[self notifyGestureDidBegin];
}
@@ -2095,7 +2095,9 @@ public:
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera])
{
- self.mbglMap.setPitch(pitchNew, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y });
+ self.mbglMap.jumpTo(mbgl::CameraOptions()
+ .withPitch(pitchNew)
+ .withAnchor(mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }));
}
[self cameraIsChanging];
@@ -3784,10 +3786,11 @@ public:
return nil;
}
+ mbgl::CameraOptions mapCamera = self.mbglMap.getCameraOptions();
CLLocationCoordinate2D centerCoordinate = MGLLocationCoordinate2DFromLatLng(cameraOptions.center ? *cameraOptions.center : self.mbglMap.getLatLng());
double zoomLevel = cameraOptions.zoom ? *cameraOptions.zoom : self.zoomLevel;
CLLocationDirection direction = cameraOptions.angle ? mbgl::util::wrap(*cameraOptions.angle, 0., 360.) : self.direction;
- CGFloat pitch = cameraOptions.pitch ? *cameraOptions.pitch : self.mbglMap.getPitch();
+ CGFloat pitch = cameraOptions.pitch ? *cameraOptions.pitch : *mapCamera.pitch;
CLLocationDistance altitude = MGLAltitudeForZoomLevel(zoomLevel, pitch, centerCoordinate.latitude, self.frame.size);
return [MGLMapCamera cameraLookingAtCenterCoordinate:centerCoordinate altitude:altitude pitch:pitch heading:direction];
}
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 03088ac5c6..21aa2c3bef 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1357,10 +1357,11 @@ public:
}
- (MGLMapCamera *)cameraForCameraOptions:(const mbgl::CameraOptions &)cameraOptions {
+ mbgl::CameraOptions mapCamera = _mbglMap->getCameraOptions();
CLLocationCoordinate2D centerCoordinate = MGLLocationCoordinate2DFromLatLng(cameraOptions.center ? *cameraOptions.center : _mbglMap->getLatLng());
double zoomLevel = cameraOptions.zoom ? *cameraOptions.zoom : self.zoomLevel;
CLLocationDirection direction = cameraOptions.angle ? mbgl::util::wrap(*cameraOptions.angle, 0., 360.) : self.direction;
- CGFloat pitch = cameraOptions.pitch ? *cameraOptions.pitch : _mbglMap->getPitch();
+ CGFloat pitch = cameraOptions.pitch ? *cameraOptions.pitch : *mapCamera.pitch;
CLLocationDistance altitude = MGLAltitudeForZoomLevel(zoomLevel, pitch,
centerCoordinate.latitude,
self.frame.size);
@@ -1477,7 +1478,7 @@ public:
if (gestureRecognizer.state == NSGestureRecognizerStateBegan) {
_directionAtBeginningOfGesture = self.direction;
- _pitchAtBeginningOfGesture = _mbglMap->getPitch();
+ _pitchAtBeginningOfGesture = *_mbglMap->getCameraOptions().pitch;
} else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) {
MGLMapCamera *oldCamera = self.camera;
BOOL didChangeCamera = NO;
@@ -1490,7 +1491,7 @@ public:
[self didChangeValueForKey:@"direction"];
}
if (self.pitchEnabled) {
- _mbglMap->setPitch(_pitchAtBeginningOfGesture + delta.y / 5, center);
+ _mbglMap->jumpTo(mbgl::CameraOptions().withPitch(_pitchAtBeginningOfGesture + delta.y / 5).withAnchor(center));
didChangeCamera = YES;
}
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index d6a5941bcb..f1a29145cf 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -993,7 +993,7 @@ void NodeMap::SetPitch(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
- nodeMap->map->setPitch(info[0]->NumberValue());
+ nodeMap->map->jumpTo(mbgl::CameraOptions().withPitch(info[0]->NumberValue()));
} catch (const std::exception &ex) {
return Nan::ThrowError(ex.what());
}
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 8059960601..cdeb4a962a 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -879,12 +879,12 @@ void QMapboxGL::setBearing(double degrees, const QPointF &center)
*/
double QMapboxGL::pitch() const
{
- return d_ptr->mapObj->getPitch();
+ return *d_ptr->mapObj->getCameraOptions().pitch;
}
void QMapboxGL::setPitch(double pitch_)
{
- d_ptr->mapObj->setPitch(pitch_);
+ d_ptr->mapObj->jumpTo(mbgl::CameraOptions().withPitch(pitch_));
}
void QMapboxGL::pitchBy(double pitch_)
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index b02d784e75..c3e5edc688 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -330,8 +330,8 @@ double Map::getMaxZoom() const {
void Map::setMinPitch(double minPitch) {
impl->transform.setMinPitch(minPitch * util::DEG2RAD);
- if (getPitch() < minPitch) {
- setPitch(minPitch);
+ if (impl->transform.getPitch() < minPitch) {
+ jumpTo(CameraOptions().withPitch(minPitch));
}
}
@@ -341,8 +341,8 @@ double Map::getMinPitch() const {
void Map::setMaxPitch(double maxPitch) {
impl->transform.setMaxPitch(maxPitch * util::DEG2RAD);
- if (getPitch() > maxPitch) {
- setPitch(maxPitch);
+ if (impl->transform.getPitch() > maxPitch) {
+ jumpTo(CameraOptions().withPitch(maxPitch));
}
}
@@ -389,20 +389,6 @@ void Map::resetNorth(const AnimationOptions& animation) {
easeTo(CameraOptions().withAngle(0.0), animation);
}
-#pragma mark - Pitch
-
-void Map::setPitch(double pitch, const AnimationOptions& animation) {
- easeTo(CameraOptions().withPitch(pitch), animation);
-}
-
-void Map::setPitch(double pitch, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) {
- easeTo(CameraOptions().withPitch(pitch).withAnchor(anchor), animation);
-}
-
-double Map::getPitch() const {
- return impl->transform.getPitch() * util::RAD2DEG;
-}
-
#pragma mark - North Orientation
void Map::setNorthOrientation(NorthOrientation orientation) {