RCTConvert+AMap3D.m
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#import <MAMapKit/MAMapView.h>
#import <React/RCTConvert.h>
#import <React/RCTConvert+CoreLocation.h>
#import "Coordinate.h"
#import "LocationStyle.h"
@implementation RCTConvert (AMapView)
RCT_ENUM_CONVERTER(MAMapType, (@{
@"standard": @(MAMapTypeStandard),
@"satellite": @(MAMapTypeSatellite),
@"navigation": @(MAMapTypeNavi),
@"night": @(MAMapTypeStandardNight),
@"bus": @(MAMapTypeBus),
}), MAMapTypeStandard, integerValue)
RCT_ENUM_CONVERTER(MAPinAnnotationColor, (@{
@"red": @(MAPinAnnotationColorRed),
@"green": @(MAPinAnnotationColorGreen),
@"purple": @(MAPinAnnotationColorPurple),
}), MAPinAnnotationColorRed, integerValue)
+ (Coordinate *)Coordinate:(id)json {
return [[Coordinate alloc] initWithCoordinate:[self CLLocationCoordinate2D:json]];
}
+ (LocationStyle *)LocationStyle:(id)json {
LocationStyle *locationStyle = [LocationStyle new];
locationStyle.fillColor = [self UIColor:json[@"fillColor"]];
locationStyle.strokeColor = [self UIColor:json[@"strokeColor"]];
locationStyle.strokeWidth = [self CGFloat:json[@"strokeWidth"]];
locationStyle.image = [UIImage imageNamed:[self NSString:json[@"image"]]];
return locationStyle;
}
+ (MAHeatMapNode *)MAHeatMapNode:(id)json {
MAHeatMapNode *node = [MAHeatMapNode new];
node.coordinate = [self CLLocationCoordinate2D:json];
node.intensity = 1;
return node;
}
+ (MAMultiPointItem *)MAMultiPointItem:(id)json {
MAMultiPointItem *item = [MAMultiPointItem new];
item.coordinate = [self CLLocationCoordinate2D:json];
return item;
}
+ (MACoordinateRegion)MACoordinateRegion:(id)json {
return MACoordinateRegionMake(
[self CLLocationCoordinate2D:json],
MACoordinateSpanMake(
[self CLLocationDegrees:json[@"latitudeDelta"]],
[self CLLocationDegrees:json[@"longitudeDelta"]]));
}
RCT_ARRAY_CONVERTER(Coordinate)
RCT_ARRAY_CONVERTER(MAHeatMapNode)
RCT_ARRAY_CONVERTER(MAMultiPointItem)
@end