summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAnder Conselvan de Oliveira <ander.deoliveira@mapbox.com>2019-03-08 12:43:05 +0200
committerAnder Conselvan de Oliveira <ander.deoliveira@mapbox.com>2019-03-14 18:33:11 +0200
commit57334407473a31ff43baa645dafd2f5e1bd910fb (patch)
treee981f87c0040799a1ebc45f86d05b3ece6916aba /include
parent11de777628e9e2c4b219bae3f1a6eabd86f2a3c5 (diff)
downloadqtlocation-mapboxgl-57334407473a31ff43baa645dafd2f5e1bd910fb.tar.gz
[core] Group Map LatLngBounds, min and max zoom methods
Group bounds, minimum and maximum zoom related methods together using the new BoundOptions. v2: Document that getBounds() initializes all optional fields. - Add test for getBounds() on a map with default values.
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/map/bound_options.hpp30
-rw-r--r--include/mbgl/map/map.hpp17
2 files changed, 40 insertions, 7 deletions
diff --git a/include/mbgl/map/bound_options.hpp b/include/mbgl/map/bound_options.hpp
new file mode 100644
index 0000000000..69d353a301
--- /dev/null
+++ b/include/mbgl/map/bound_options.hpp
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <mbgl/util/geo.hpp>
+#include <mbgl/util/optional.hpp>
+
+namespace mbgl {
+
+/**
+ * @brief Holds options to limit what parts of a map are visible. All fields are
+ * optional.
+ */
+struct BoundOptions {
+ /// Sets the latitude and longitude bounds to which the camera center are constrained
+ BoundOptions& withLatLngBounds(LatLngBounds b) { bounds = b; return *this; }
+ /// Sets the minimum zoom level
+ BoundOptions& withMinZoom(double z) { minZoom = z; return *this; }
+ /// Sets the maximum zoom level
+ BoundOptions& withMaxZoom(double z) { maxZoom = z; return *this; }
+
+ /// Constrain the center of the camera to be within these bounds.
+ optional<LatLngBounds> bounds;
+
+ /// Maximum zoom level allowed.
+ optional<double> maxZoom;
+
+ /// Minimum zoom level allowed.
+ optional<double> minZoom;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 93e5190f99..b4f60a19ba 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -2,6 +2,7 @@
#include <mbgl/util/optional.hpp>
#include <mbgl/util/chrono.hpp>
+#include <mbgl/map/bound_options.hpp>
#include <mbgl/map/map_observer.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/map/mode.hpp>
@@ -76,13 +77,15 @@ public:
CameraOptions cameraForGeometry(const Geometry<double>&, const EdgeInsets&, optional<double> bearing = {}, optional<double> pitch = {}) const;
LatLngBounds latLngBoundsForCamera(const CameraOptions&) const;
- // Bounds
- void setLatLngBounds(LatLngBounds);
- LatLngBounds getLatLngBounds() const;
- void setMinZoom(double);
- double getMinZoom() const;
- void setMaxZoom(double);
- double getMaxZoom() const;
+ /// @name Bounds
+ /// @{
+
+ void setBounds(const BoundOptions& options);
+
+ /// Returns the current map bound options. All optional fields in BoundOptions are set.
+ BoundOptions getBounds() const;
+
+ /// @}
// North Orientation
void setNorthOrientation(NorthOrientation);