From e8f7866e9e3328bb4d40da172fb5a549315fd486 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 23 Nov 2018 15:26:10 +0200 Subject: [PATCH] [core] Remove error-prone setlatLng overload --- include/mbgl/map/map.hpp | 1 - platform/ios/src/MGLMapView.mm | 2 +- src/mbgl/map/map.cpp | 8 +------- src/mbgl/map/transform.cpp | 13 +++---------- src/mbgl/map/transform.hpp | 1 - 5 files changed, 5 insertions(+), 20 deletions(-) diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index ca6c62d28..fec67eb28 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -75,7 +75,6 @@ public: // Position void moveBy(const ScreenCoordinate&, const AnimationOptions& = {}); - void setLatLng(const LatLng&, optional, const AnimationOptions& = {}); void setLatLng(const LatLng&, const EdgeInsets&, const AnimationOptions& = {}); void setLatLng(const LatLng&, const AnimationOptions& = {}); LatLng getLatLng(const EdgeInsets& = {}) const; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 8ab612663..28367e83b 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1579,7 +1579,7 @@ public: { CLLocationCoordinate2D centerCoordinate = _previousPinchCenterCoordinate; self.mbglMap.setLatLng(MGLLatLngFromLocationCoordinate2D(centerCoordinate), - mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); + mbgl::EdgeInsets { centerPoint.y, centerPoint.x, self.size.height - centerPoint.y, self.size.width - centerPoint.x }); } } [self cameraIsChanging]; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 1f64cf3ac..983d43eed 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -304,7 +304,7 @@ void Map::moveBy(const ScreenCoordinate& point, const AnimationOptions& animatio void Map::setLatLng(const LatLng& latLng, const AnimationOptions& animation) { impl->cameraMutated = true; - setLatLng(latLng, optional {}, animation); + setLatLng(latLng, animation); } void Map::setLatLng(const LatLng& latLng, const EdgeInsets& padding, const AnimationOptions& animation) { @@ -313,12 +313,6 @@ void Map::setLatLng(const LatLng& latLng, const EdgeInsets& padding, const Anima impl->onUpdate(); } -void Map::setLatLng(const LatLng& latLng, optional anchor, const AnimationOptions& animation) { - impl->cameraMutated = true; - impl->transform.setLatLng(latLng, anchor, animation); - impl->onUpdate(); -} - LatLng Map::getLatLng(const EdgeInsets& padding) const { return impl->transform.getLatLng(padding); } diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 03a1e117f..452cb19a0 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -323,7 +323,9 @@ void Transform::moveBy(const ScreenCoordinate& offset, const AnimationOptions& a } void Transform::setLatLng(const LatLng& latLng, const AnimationOptions& animation) { - setLatLng(latLng, optional {}, animation); + CameraOptions camera; + camera.center = latLng; + easeTo(camera, animation); } void Transform::setLatLng(const LatLng& latLng, const EdgeInsets& padding, const AnimationOptions& animation) { @@ -333,15 +335,6 @@ void Transform::setLatLng(const LatLng& latLng, const EdgeInsets& padding, const easeTo(camera, animation); } -void Transform::setLatLng(const LatLng& latLng, optional anchor, const AnimationOptions& animation) { - CameraOptions camera; - camera.center = latLng; - if (anchor) { - camera.padding = EdgeInsets(anchor->y, anchor->x, state.size.height - anchor->y, state.size.width - anchor->x); - } - easeTo(camera, animation); -} - void Transform::setLatLngZoom(const LatLng& latLng, double zoom, const AnimationOptions& animation) { setLatLngZoom(latLng, zoom, EdgeInsets(), animation); } diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp index bff44a2dc..96573b151 100644 --- a/src/mbgl/map/transform.hpp +++ b/src/mbgl/map/transform.hpp @@ -48,7 +48,6 @@ public: void moveBy(const ScreenCoordinate& offset, const AnimationOptions& = {}); void setLatLng(const LatLng&, const AnimationOptions& = {}); void setLatLng(const LatLng&, const EdgeInsets&, const AnimationOptions& = {}); - void setLatLng(const LatLng&, optional, const AnimationOptions& = {}); void setLatLngZoom(const LatLng&, double zoom, const AnimationOptions& = {}); void setLatLngZoom(const LatLng&, double zoom, const EdgeInsets&, const AnimationOptions& = {}); LatLng getLatLng(const EdgeInsets& = {}) const;