add setVisibleCoordinateBounds to js module.

This commit is contained in:
Pierre-Etienne Cherière
2015-10-23 10:59:40 +02:00
parent f536b404e6
commit 7e21eebb94
4 changed files with 25 additions and 0 deletions
+3
View File
@@ -24,6 +24,9 @@ var MapMixins = {
},
removeAnnotation(mapRef, annotationInArray) {
NativeModules.MapboxGLManager.removeAnnotation(React.findNodeHandle(this.refs[mapRef]), annotationInArray);
},
setVisibleCoordinateBoundsAnimated(mapRef, latitudeSW, longitudeSW, latitudeNE, longitudeNE, edge) {
NativeModules.MapboxGLManager.setVisibleCoordinateBoundsAnimated(React.findNodeHandle(this.refs[mapRef]), latitudeSW, longitudeSW, latitudeNE, longitudeNE, edge);
}
};
+1
View File
@@ -34,6 +34,7 @@
- (void)setCenterCoordinateZoomLevelAnimated:(CLLocationCoordinate2D)coordinates zoomLevel:(double)zoomLevel;
- (void)selectAnnotationAnimated:(NSUInteger)annotationInArray;
- (void)removeAnnotation:(NSUInteger)annotationInArray;
- (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)padding animated:(BOOL)animated;
@end
+5
View File
@@ -242,6 +242,11 @@ RCT_EXPORT_MODULE();
[_map setCenterCoordinate:coordinates zoomLevel:zoomLevel animated:YES];
}
- (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)padding animated:(BOOL)animated
{
[_map setVisibleCoordinateBounds:bounds edgePadding:padding animated:animated];
}
- (void)mapView:(MGLMapView *)mapView didUpdateUserLocation:(MGLUserLocation *)userLocation;
{
NSDictionary *event = @{ @"target": self.reactTag,
+16
View File
@@ -100,6 +100,22 @@ RCT_EXPORT_METHOD(setCenterCoordinateZoomLevelAnimated:(nonnull NSNumber *)react
}];
}
RCT_EXPORT_METHOD(setVisibleCoordinateBoundsAnimated:(nonnull NSNumber *)reactTag
latitudeSW:(float) latitudeSW
longitudeSW:(float) longitudeSW
latitudeNE:(float) latitudeNE
longitudeNE:(float) longitudeNE
edgePadding:(double) edgePadding)
{
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
RCTMapboxGL *mapView = viewRegistry[reactTag];
if ([mapView isKindOfClass:[RCTMapboxGL class]]) {
MGLCoordinateBounds coordinatesBounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(latitudeSW, longitudeSW), CLLocationCoordinate2DMake(latitudeNE, longitudeNE));
[mapView setVisibleCoordinateBounds:coordinatesBounds edgePadding:UIEdgeInsetsMake(edgePadding, edgePadding, edgePadding, edgePadding) animated:YES];
}
}];
}
RCT_EXPORT_METHOD(selectAnnotationAnimated:(nonnull NSNumber *) reactTag
annotationInArray:(NSUInteger)annotationInArray)
{