[core] Remove map pitch setters/getters

This commit is contained in:
Bruno de Oliveira Abinader
2019-02-27 19:58:35 +02:00
parent f5f10ec119
commit 21a39306da
7 changed files with 20 additions and 34 deletions

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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];
}

View File

@@ -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;
}

View File

@@ -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());
}

View File

@@ -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_)

View File

@@ -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) {