release 1.0.3
This commit is contained in:
@ -234,6 +234,16 @@
|
||||
[weakSelf.mapView clearDisk];
|
||||
result(nil);
|
||||
}];
|
||||
[self.channel addMethodName:@"map#toScreenCoordinate" withHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
|
||||
CLLocationCoordinate2D location = [AMapConvertUtil coordinateFromArray:call.arguments];
|
||||
CGPoint point = [weakSelf.mapView convertCoordinate:location toPointToView:weakSelf.mapView];
|
||||
result([AMapConvertUtil dictionaryFromPoint:point]);
|
||||
}];
|
||||
[self.channel addMethodName:@"map#fromScreenCoordinate" withHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
|
||||
CGPoint point = [AMapConvertUtil pointFromDictionary:call.arguments];
|
||||
CLLocationCoordinate2D coordinate = [weakSelf.mapView convertPoint:point toCoordinateFromView:weakSelf.mapView];
|
||||
result([AMapConvertUtil arrayFromLocation:coordinate]);
|
||||
}];
|
||||
}
|
||||
|
||||
//MARK: MAMapViewDelegate
|
||||
|
@ -24,9 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param numberColor 色值
|
||||
+ (UIColor*)colorFromNumber:(NSNumber*)numberColor;
|
||||
|
||||
/// 将数组(内含数字)转换为point坐标,(默认数组第一个元素为x值,第二个为y值)
|
||||
/// @param data 数组
|
||||
+ (CGPoint)pointFromArray:(NSArray*)data;
|
||||
+ (CGPoint)pointFromDictionary:(NSDictionary *)dictionary;
|
||||
|
||||
/// 从数据中解析经纬度
|
||||
/// @param array 经纬度数组对(默认第一个当做维度,第二个当做经度)
|
||||
@ -63,6 +61,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param array json数组[southwest,northeast],分别为西南、东北的坐标
|
||||
+ (MAMapRect)mapRectFromArray:(NSArray *)array;
|
||||
|
||||
+ (CGPoint)pointFromDictionary:(NSDictionary *)dictionary;
|
||||
+ (CGPoint)pointFromArray:(NSArray *)array;
|
||||
+ (NSDictionary<NSString *, NSNumber *> *)dictionaryFromPoint:(CGPoint)point;
|
||||
+ (NSArray *)arrayFromLocation:(CLLocationCoordinate2D)location;
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@ -27,11 +27,6 @@
|
||||
alpha:((float)((value & 0xFF000000) >> 24)) / 255.0];
|
||||
}
|
||||
|
||||
+ (CGPoint)pointFromArray:(NSArray*)data {
|
||||
NSAssert((data != nil && [data isKindOfClass:[NSArray class]] && data.count == 2), @"数组类型转point格式错误");
|
||||
return CGPointMake([data[0] doubleValue],
|
||||
[data[1] doubleValue]);
|
||||
}
|
||||
|
||||
/// 从数据中解析经纬度
|
||||
/// @param array 经纬度数组对(默认第一个当做维度,第二个当做经度)
|
||||
@ -212,4 +207,28 @@
|
||||
}
|
||||
|
||||
|
||||
+ (CGPoint)pointFromDictionary:(NSDictionary *)dictionary {
|
||||
double x = [dictionary[@"x"] doubleValue];
|
||||
double y = [dictionary[@"y"] doubleValue];
|
||||
return CGPointMake(x, y);
|
||||
}
|
||||
|
||||
+ (CGPoint)pointFromArray:(NSArray*)array {
|
||||
NSAssert((array != nil && [array isKindOfClass:[NSArray class]] && array.count == 2), @"数组类型转point格式错误");
|
||||
return CGPointMake([array[0] doubleValue],
|
||||
[array[1] doubleValue]);
|
||||
}
|
||||
|
||||
+ (NSDictionary<NSString *, NSNumber *> *)dictionaryFromPoint:(CGPoint)point {
|
||||
return @{
|
||||
@"x" : @(lroundf(point.x)),
|
||||
@"y" : @(lroundf(point.y)),
|
||||
};
|
||||
}
|
||||
|
||||
+ (NSArray *)arrayFromLocation:(CLLocationCoordinate2D)location {
|
||||
return @[ @(location.latitude), @(location.longitude) ];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user