mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Implement draggable annotations on MapView. Closes #2512
Summary: Closes https://github.com/facebook/react-native/pull/4441 Reviewed By: svcscm Differential Revision: D2707897 Pulled By: nicklockwood fb-gh-sync-id: 6f67f711c1ec1f821d03b9b1ea5cc39859d28fd1
This commit is contained in:
committed by
facebook-github-bot-7
parent
64edddadcc
commit
b8aac8b77a
@@ -42,22 +42,23 @@ RCT_ENUM_CONVERTER(MKMapType, (@{
|
||||
json = [self NSDictionary:json];
|
||||
RCTMapAnnotation *annotation = [RCTMapAnnotation new];
|
||||
annotation.coordinate = [self CLLocationCoordinate2D:json];
|
||||
annotation.title = [RCTConvert NSString:json[@"title"]];
|
||||
annotation.subtitle = [RCTConvert NSString:json[@"subtitle"]];
|
||||
annotation.identifier = [RCTConvert NSString:json[@"id"]];
|
||||
annotation.hasLeftCallout = [RCTConvert BOOL:json[@"hasLeftCallout"]];
|
||||
annotation.hasRightCallout = [RCTConvert BOOL:json[@"hasRightCallout"]];
|
||||
annotation.animateDrop = [RCTConvert BOOL:json[@"animateDrop"]];
|
||||
annotation.tintColor = [RCTConvert UIColor:json[@"tintColor"]];
|
||||
annotation.image = [RCTConvert UIImage:json[@"image"]];
|
||||
annotation.draggable = [self BOOL:json[@"draggable"]];
|
||||
annotation.title = [self NSString:json[@"title"]];
|
||||
annotation.subtitle = [self NSString:json[@"subtitle"]];
|
||||
annotation.identifier = [self NSString:json[@"id"]];
|
||||
annotation.hasLeftCallout = [self BOOL:json[@"hasLeftCallout"]];
|
||||
annotation.hasRightCallout = [self BOOL:json[@"hasRightCallout"]];
|
||||
annotation.animateDrop = [self BOOL:json[@"animateDrop"]];
|
||||
annotation.tintColor = [self UIColor:json[@"tintColor"]];
|
||||
annotation.image = [self UIImage:json[@"image"]];
|
||||
annotation.viewIndex =
|
||||
[RCTConvert NSInteger:json[@"viewIndex"] ?: @(NSNotFound)];
|
||||
[self NSInteger:json[@"viewIndex"] ?: @(NSNotFound)];
|
||||
annotation.leftCalloutViewIndex =
|
||||
[RCTConvert NSInteger:json[@"leftCalloutViewIndex"] ?: @(NSNotFound)];
|
||||
[self NSInteger:json[@"leftCalloutViewIndex"] ?: @(NSNotFound)];
|
||||
annotation.rightCalloutViewIndex =
|
||||
[RCTConvert NSInteger:json[@"rightCalloutViewIndex"] ?: @(NSNotFound)];
|
||||
[self NSInteger:json[@"rightCalloutViewIndex"] ?: @(NSNotFound)];
|
||||
annotation.detailCalloutViewIndex =
|
||||
[RCTConvert NSInteger:json[@"detailCalloutViewIndex"] ?: @(NSNotFound)];
|
||||
[self NSInteger:json[@"detailCalloutViewIndex"] ?: @(NSNotFound)];
|
||||
return annotation;
|
||||
}
|
||||
|
||||
@@ -66,19 +67,19 @@ RCT_ARRAY_CONVERTER(RCTMapAnnotation)
|
||||
+ (RCTMapOverlay *)RCTMapOverlay:(id)json
|
||||
{
|
||||
json = [self NSDictionary:json];
|
||||
NSArray<NSDictionary *> *locations = [RCTConvert NSDictionaryArray:json[@"coordinates"]];
|
||||
NSArray<NSDictionary *> *locations = [self NSDictionaryArray:json[@"coordinates"]];
|
||||
CLLocationCoordinate2D coordinates[locations.count];
|
||||
NSUInteger index = 0;
|
||||
for (NSDictionary *location in locations) {
|
||||
coordinates[index++] = [RCTConvert CLLocationCoordinate2D:location];
|
||||
coordinates[index++] = [self CLLocationCoordinate2D:location];
|
||||
}
|
||||
|
||||
RCTMapOverlay *overlay = [RCTMapOverlay polylineWithCoordinates:coordinates
|
||||
count:locations.count];
|
||||
|
||||
overlay.strokeColor = [RCTConvert UIColor:json[@"strokeColor"]];
|
||||
overlay.identifier = [RCTConvert NSString:json[@"id"]];
|
||||
overlay.lineWidth = [RCTConvert CGFloat:json[@"lineWidth"] ?: @1];
|
||||
overlay.strokeColor = [self UIColor:json[@"strokeColor"]];
|
||||
overlay.identifier = [self NSString:json[@"id"]];
|
||||
overlay.lineWidth = [self CGFloat:json[@"lineWidth"] ?: @1];
|
||||
return overlay;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user