Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

fixes #2044: add -showAnnotations:animated: #2050

Merged
merged 1 commit into from
Aug 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/mbgl/ios/MGLMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ IB_DESIGNABLE
* @param animated Specify `YES` to animate the change by smoothly scrolling and zooming or `NO` to immediately display the given bounds. */
- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated;

/** Sets the visible region so that the map displays the specified annotations.
*
* Calling this method updates the value in the visibleCoordinateBounds property and potentially other properties to reflect the new map region.
* @param annotations The annotations that you want to be visible in the map.
* @param animated `YES` if you want the map region change to be animated, or `NO` if you want the map to display the new region immediately without animations. */
- (void)showAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations 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. */
Expand Down
23 changes: 23 additions & 0 deletions platform/ios/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,29 @@ - (void)deselectAnnotation:(id <MGLAnnotation>)annotation animated:(BOOL)animate
}
}

- (void)showAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations animated:(BOOL)animated
{
if ( ! annotations || ! annotations.count) return;

mbgl::LatLngBounds bounds;

for (id <MGLAnnotation> annotation in annotations)
{
if ([annotation conformsToProtocol:@protocol(MGLOverlay)])
{
bounds.extend(MGLLatLngBoundsFromCoordinateBounds(((id <MGLOverlay>)annotation).overlayBounds));
}
else
{
bounds.extend(MGLLatLngFromLocationCoordinate2D(annotation.coordinate));
}
}

[self setVisibleCoordinateBounds:MGLCoordinateBoundsFromLatLngBounds(bounds)
edgePadding:UIEdgeInsetsMake(100, 100, 100, 100)
animated:animated];
}

#pragma mark - User Location -

- (void)setShowsUserLocation:(BOOL)showsUserLocation
Expand Down