summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-06-23 15:20:50 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-06-25 21:54:53 -0700
commitc57799f26cf06995629cfdee55bdd4a94452b320 (patch)
tree97ace2a4b513fbf92092343f3f747698c6c8c675 /include
parentf5c1e2630e553a727a91f0de623bf3ec1bdcc559 (diff)
downloadqtlocation-mapboxgl-c57799f26cf06995629cfdee55bdd4a94452b320.tar.gz
Reimplemented fit to bounds
The new implementation is now public and takes advantage of MGLCoordinateBounds. It is re-ported from `Camera.prototype.fitBounds()` in mapbox/mapbox-gl-js to ensure correct behavior. A new function, MGLCoordinateBoundsMake(), makes it easier to create an MGLCoordinateBounds for use with this method.
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/ios/MGLMapView.h8
-rw-r--r--include/mbgl/ios/MGLTypes.h7
-rw-r--r--include/mbgl/map/map.hpp1
3 files changed, 16 insertions, 0 deletions
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index bf258ee82e..001e7aa678 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -118,6 +118,14 @@ IB_DESIGNABLE
* @param animated Specify `YES` if you want the map view to animate scrolling and zooming to the new location or `NO` if you want the map to display the new location immediately. */
- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel animated:(BOOL)animated;
+/** Returns the coordinate bounds visible in the receiver’s viewport. */
+- (MGLCoordinateBounds)visibleCoordinateBounds;
+
+/** Changes the receiver’s viewport to fit the given coordinate bounds, optionally animating the change.
+* @param bounds The bounds that the viewport will show in its entirety.
+* @param animated Specify `YES` to animate the change by smoothly scrolling and zooming or `NO` to immediately display the given bounds. */
+- (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds animated:(BOOL)animated;
+
/** The heading of the map (measured in degrees) relative to true north.
*
* The value `0` means that the top edge of the map view corresponds to true north. The value `90` means the top of the map is pointing due east. The value `180` means the top of the map points due south, and so on. */
diff --git a/include/mbgl/ios/MGLTypes.h b/include/mbgl/ios/MGLTypes.h
index 65d5e7846d..9213dafb37 100644
--- a/include/mbgl/ios/MGLTypes.h
+++ b/include/mbgl/ios/MGLTypes.h
@@ -28,6 +28,13 @@ typedef struct {
CLLocationCoordinate2D ne;
} MGLCoordinateBounds;
+NS_INLINE MGLCoordinateBounds MGLCoordinateBoundsMake(CLLocationCoordinate2D sw, CLLocationCoordinate2D ne) {
+ MGLCoordinateBounds bounds;
+ bounds.sw = sw;
+ bounds.ne = ne;
+ return bounds;
+}
+
NS_ASSUME_NONNULL_END
#pragma clang diagnostic push
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index e7474005e4..42ae72bb70 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -95,6 +95,7 @@ public:
void setZoom(double zoom, Duration = Duration::zero());
double getZoom() const;
void setLatLngZoom(LatLng latLng, double zoom, Duration = Duration::zero());
+ void fitBounds(LatLngBounds bounds, Duration = Duration::zero());
void resetZoom();
double getMinZoom() const;
double getMaxZoom() const;