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.
This commit is contained in:
@@ -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. */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user