Skip to content

Commit

Permalink
Add in support for showing annotation callouts by default without the…
Browse files Browse the repository at this point in the history
… user clicking on the pins

Reviewed By: mmmulani

Differential Revision: D4209555

fbshipit-source-id: 38c2459f9bec0dd2279cf673bcb22aef15748347
  • Loading branch information
donyu authored and Facebook Github Bot committed Nov 20, 2016
1 parent 7f0071a commit 1835dbe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Libraries/Components/MapView/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ const MapView = React.createClass({
*/
showsCompass: React.PropTypes.bool,

/**
* If `true` the map will show the callouts for all annotations without
* the user having to click on the annotation.
* Default value is `false`.
*/
showsAnnotationCallouts: React.PropTypes.bool,

/**
* If `false` the user won't be able to pinch/zoom the map.
* Default value is `true`.
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RCT_EXTERN const CGFloat RCTMapZoomBoundBuffer;

@property (nonatomic, assign) BOOL followUserLocation;
@property (nonatomic, assign) BOOL hasStartedRendering;
@property (nonatomic, assign) BOOL showsAnnotationCallouts;
@property (nonatomic, assign) CGFloat minDelta;
@property (nonatomic, assign) CGFloat maxDelta;
@property (nonatomic, assign) UIEdgeInsets legalLabelInsets;
Expand Down
9 changes: 9 additions & 0 deletions React/Views/RCTMapManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(showsUserLocation, BOOL)
RCT_EXPORT_VIEW_PROPERTY(showsPointsOfInterest, BOOL)
RCT_EXPORT_VIEW_PROPERTY(showsCompass, BOOL)
RCT_EXPORT_VIEW_PROPERTY(showsAnnotationCallouts, BOOL)
RCT_EXPORT_VIEW_PROPERTY(followUserLocation, BOOL)
RCT_EXPORT_VIEW_PROPERTY(zoomEnabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(rotateEnabled, BOOL)
Expand Down Expand Up @@ -289,6 +290,14 @@ - (MKAnnotationView *)mapView:(RCTMap *)mapView
return annotationView;
}

- (void)mapView:(RCTMap *)mapView didAddAnnotationViews:(NSArray *)views {
if (mapView.showsAnnotationCallouts) {
for (id<MKAnnotation> annotation in mapView.annotations) {
[mapView selectAnnotation:annotation animated:YES];
}
}
}

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay
{
RCTAssert([overlay isKindOfClass:[RCTMapOverlay class]], @"Overlay must be of type RCTMapOverlay");
Expand Down

0 comments on commit 1835dbe

Please sign in to comment.