summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rwxr-xr-xplatform/android/src/native_map_view.cpp7
-rw-r--r--platform/glfw/main.cpp20
-rw-r--r--platform/ios/src/MGLMapView.mm31
-rw-r--r--platform/macos/src/MGLMapView.mm23
-rw-r--r--platform/node/src/node_map.cpp2
-rw-r--r--platform/qt/src/qmapboxgl.cpp14
6 files changed, 56 insertions, 41 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index e8bc14c8c2..4755cc28c4 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -403,15 +403,16 @@ void NativeMapView::setPitch(jni::JNIEnv&, jni::jdouble pitch, jni::jlong durati
}
void NativeMapView::setZoom(jni::JNIEnv&, jni::jdouble zoom, jni::jdouble x, jni::jdouble y, jni::jlong duration) {
- map->setZoom(zoom, mbgl::ScreenCoordinate{x,y}, mbgl::AnimationOptions{mbgl::Milliseconds(duration)});
+ map->easeTo(mbgl::CameraOptions().withZoom(zoom).withAnchor(mbgl::ScreenCoordinate{ x, y }),
+ mbgl::AnimationOptions{ mbgl::Milliseconds(duration) });
}
jni::jdouble NativeMapView::getZoom(jni::JNIEnv&) {
- return map->getZoom();
+ return *map->getCameraOptions().zoom;
}
void NativeMapView::resetZoom(jni::JNIEnv&) {
- map->resetZoom();
+ map->jumpTo(mbgl::CameraOptions().withZoom(0.0));
}
void NativeMapView::setMinZoom(jni::JNIEnv&, jni::jdouble zoom) {
diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp
index 1bb2e13614..9963ca6884 100644
--- a/platform/glfw/main.cpp
+++ b/platform/glfw/main.cpp
@@ -117,9 +117,11 @@ int main(int argc, char *argv[]) {
style = std::string("file://") + style;
}
- map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom);
- map.setBearing(settings.bearing);
- map.setPitch(settings.pitch);
+ map.jumpTo(mbgl::CameraOptions()
+ .withCenter(mbgl::LatLng {settings.latitude, settings.longitude})
+ .withZoom(settings.zoom)
+ .withAngle(settings.bearing)
+ .withPitch(settings.pitch));
map.setDebug(mbgl::MapDebugOptions(settings.debug));
view->setOnlineStatusCallback([&settings, &fileSource]() {
@@ -172,12 +174,12 @@ int main(int argc, char *argv[]) {
view->run();
// Save settings
- mbgl::LatLng latLng = map.getLatLng();
- settings.latitude = latLng.latitude();
- settings.longitude = latLng.longitude();
- settings.zoom = map.getZoom();
- settings.bearing = map.getBearing();
- settings.pitch = map.getPitch();
+ mbgl::CameraOptions camera = map.getCameraOptions();
+ settings.latitude = camera.center->latitude();
+ settings.longitude = camera.center->longitude();
+ settings.zoom = *camera.zoom;
+ settings.bearing = *camera.angle;
+ settings.pitch = *camera.pitch;
settings.debug = mbgl::EnumType(map.getDebug());
settings.save();
mbgl::Log::Info(mbgl::Event::General,
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index f9ccab1422..aa57f75e16 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1673,7 +1673,7 @@ public:
{
[self trackGestureEvent:MMEEventGesturePinchStart forRecognizer:pinch];
- self.scale = powf(2, self.mbglMap.getZoom());
+ self.scale = powf(2, [self zoomLevel]);
[self notifyGestureDidBegin];
}
@@ -1688,7 +1688,8 @@ public:
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera])
{
- self.mbglMap.setZoom(newZoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y });
+ self.mbglMap.jumpTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }));
+
// The gesture recognizer only reports the gesture’s current center
// point, so use the previous center point to anchor the transition.
// If the number of touches has changed, the remembered center point is
@@ -1747,7 +1748,7 @@ public:
{
if (drift)
{
- self.mbglMap.setZoom(zoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }, MGLDurationFromTimeInterval(duration));
+ self.mbglMap.easeTo(mbgl::CameraOptions().withZoom(zoom).withAnchor(mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }), MGLDurationFromTimeInterval(duration));
}
}
@@ -1968,7 +1969,7 @@ public:
[self trackGestureEvent:MMEEventGestureDoubleTap forRecognizer:doubleTap];
mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
- self.mbglMap.setZoom(newZoom, center, MGLDurationFromTimeInterval(MGLAnimationDuration));
+ self.mbglMap.easeTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(center), MGLDurationFromTimeInterval(MGLAnimationDuration));
__weak MGLMapView *weakSelf = self;
@@ -1989,7 +1990,7 @@ public:
if ( ! self.isZoomEnabled) return;
- if (self.mbglMap.getZoom() == self.mbglMap.getMinZoom()) return;
+ if ([self zoomLevel] == self.mbglMap.getMinZoom()) return;
[self cancelTransitions];
@@ -2008,7 +2009,7 @@ public:
[self trackGestureEvent:MMEEventGestureTwoFingerSingleTap forRecognizer:twoFingerTap];
mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
- self.mbglMap.setZoom(newZoom, center, MGLDurationFromTimeInterval(MGLAnimationDuration));
+ self.mbglMap.easeTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(center), MGLDurationFromTimeInterval(MGLAnimationDuration));
__weak MGLMapView *weakSelf = self;
@@ -2031,7 +2032,7 @@ public:
{
[self trackGestureEvent:MMEEventGestureQuickZoom forRecognizer:quickZoom];
- self.scale = powf(2, self.mbglMap.getZoom());
+ self.scale = powf(2, [self zoomLevel]);
self.quickZoomStart = [quickZoom locationInView:quickZoom.view].y;
@@ -2043,7 +2044,7 @@ public:
CGFloat newZoom = MAX(log2f(self.scale) + (distance / 75), self.mbglMap.getMinZoom());
- if (self.mbglMap.getZoom() == newZoom) return;
+ if ([self zoomLevel] == newZoom) return;
CGPoint centerPoint = [self anchorPointForGesture:quickZoom];
@@ -2052,7 +2053,7 @@ public:
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera])
{
- self.mbglMap.setZoom(newZoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y });
+ self.mbglMap.jumpTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }));
}
[self cameraIsChanging];
@@ -3141,7 +3142,7 @@ public:
centerPoint = self.userLocationAnnotationViewCenter;
}
double newZoom = round(self.zoomLevel) + log2(scaleFactor);
- self.mbglMap.setZoom(newZoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y });
+ self.mbglMap.jumpTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }));
[self unrotateIfNeededForGesture];
_accessibilityValueAnnouncementIsPending = YES;
@@ -3274,7 +3275,8 @@ public:
- (double)zoomLevel
{
- return self.mbglMap.getZoom();
+ mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(self.contentInset);
+ return *self.mbglMap.getCameraOptions(padding).zoom;
}
- (void)setZoomLevel:(double)zoomLevel
@@ -3293,9 +3295,10 @@ public:
CGFloat duration = animated ? MGLAnimationDuration : 0;
- self.mbglMap.setZoom(zoomLevel,
- MGLEdgeInsetsFromNSEdgeInsets(self.contentInset),
- MGLDurationFromTimeInterval(duration));
+ self.mbglMap.easeTo(mbgl::CameraOptions()
+ .withZoom(zoomLevel)
+ .withPadding(MGLEdgeInsetsFromNSEdgeInsets(self.contentInset)),
+ MGLDurationFromTimeInterval(duration));
}
- (void)setMinimumZoomLevel:(double)minimumZoomLevel
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 5a24524b4a..03088ac5c6 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1047,7 +1047,8 @@ public:
}
- (double)zoomLevel {
- return _mbglMap->getZoom();
+ mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets);
+ return *_mbglMap->getCameraOptions(padding).zoom;
}
- (void)setZoomLevel:(double)zoomLevel {
@@ -1058,9 +1059,10 @@ public:
- (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated {
MGLLogDebug(@"Setting zoomLevel: %f animated: %@", zoomLevel, MGLStringFromBOOL(animated));
[self willChangeValueForKey:@"zoomLevel"];
- _mbglMap->setZoom(zoomLevel,
- MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets),
- MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0));
+ _mbglMap->easeTo(mbgl::CameraOptions()
+ .withZoom(zoomLevel)
+ .withPadding(MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets)),
+ MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0));
[self didChangeValueForKey:@"zoomLevel"];
}
@@ -1069,7 +1071,10 @@ public:
[self willChangeValueForKey:@"zoomLevel"];
MGLMapCamera *oldCamera = self.camera;
mbgl::ScreenCoordinate center(point.x, self.bounds.size.height - point.y);
- _mbglMap->setZoom(zoomLevel, center, MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0));
+ _mbglMap->easeTo(mbgl::CameraOptions()
+ .withZoom(zoomLevel)
+ .withAnchor(center),
+ MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0));
if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)]
&& ![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) {
self.camera = oldCamera;
@@ -1461,7 +1466,7 @@ public:
_mbglMap->cancelTransitions();
if (gestureRecognizer.state == NSGestureRecognizerStateBegan) {
- _zoomAtBeginningOfGesture = _mbglMap->getZoom();
+ _zoomAtBeginningOfGesture = [self zoomLevel];
} else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) {
CGFloat newZoomLevel = _zoomAtBeginningOfGesture - delta.y / 75;
[self setZoomLevel:newZoomLevel atPoint:startPoint animated:NO];
@@ -1525,7 +1530,7 @@ public:
if (gestureRecognizer.state == NSGestureRecognizerStateBegan) {
_mbglMap->setGestureInProgress(true);
- _zoomAtBeginningOfGesture = _mbglMap->getZoom();
+ _zoomAtBeginningOfGesture = [self zoomLevel];
} else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) {
NSPoint zoomInPoint = [gestureRecognizer locationInView:self];
mbgl::ScreenCoordinate center(zoomInPoint.x, self.bounds.size.height - zoomInPoint.y);
@@ -1533,7 +1538,9 @@ public:
[self willChangeValueForKey:@"zoomLevel"];
[self willChangeValueForKey:@"centerCoordinate"];
MGLMapCamera *oldCamera = self.camera;
- _mbglMap->setZoom(_zoomAtBeginningOfGesture + log2(1 + gestureRecognizer.magnification), center);
+ _mbglMap->jumpTo(mbgl::CameraOptions()
+ .withZoom(_zoomAtBeginningOfGesture + log2(1 + gestureRecognizer.magnification))
+ .withAnchor(center));
if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)]
&& ![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) {
self.camera = oldCamera;
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index 6dccdf5292..d6a5941bcb 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -959,7 +959,7 @@ void NodeMap::SetZoom(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
- nodeMap->map->setZoom(info[0]->NumberValue());
+ nodeMap->map->jumpTo(mbgl::CameraOptions().withZoom(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 cc4028b64d..8059960601 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -726,12 +726,12 @@ void QMapboxGL::setLongitude(double longitude_)
*/
double QMapboxGL::scale() const
{
- return std::pow(2.0, d_ptr->mapObj->getZoom());
+ return std::pow(2.0, zoom());
}
void QMapboxGL::setScale(double scale_, const QPointF &center)
{
- d_ptr->mapObj->setZoom(::log2(scale_), mbgl::ScreenCoordinate { center.x(), center.y() });
+ d_ptr->mapObj->jumpTo(mbgl::CameraOptions().withZoom(::log2(scale_)).withAnchor(mbgl::ScreenCoordinate { center.x(), center.y() }));
}
/*!
@@ -746,12 +746,12 @@ void QMapboxGL::setScale(double scale_, const QPointF &center)
*/
double QMapboxGL::zoom() const
{
- return d_ptr->mapObj->getZoom();
+ return *d_ptr->mapObj->getCameraOptions().zoom;
}
void QMapboxGL::setZoom(double zoom_)
{
- d_ptr->mapObj->setZoom(zoom_, d_ptr->margins);
+ d_ptr->mapObj->jumpTo(mbgl::CameraOptions().withZoom(zoom_).withPadding(d_ptr->margins));
}
/*!
@@ -806,8 +806,10 @@ void QMapboxGL::setCoordinate(const QMapbox::Coordinate &coordinate_)
*/
void QMapboxGL::setCoordinateZoom(const QMapbox::Coordinate &coordinate_, double zoom_)
{
- d_ptr->mapObj->setLatLngZoom(
- mbgl::LatLng { coordinate_.first, coordinate_.second }, zoom_, d_ptr->margins);
+ d_ptr->mapObj->jumpTo(mbgl::CameraOptions()
+ .withCenter(mbgl::LatLng { coordinate_.first, coordinate_.second })
+ .withZoom(zoom_)
+ .withPadding(d_ptr->margins));
}
/*!