init project
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
//
|
||||
// FlutterMethodChannel+MethodCallDispatch.h
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/16.
|
||||
//
|
||||
|
||||
#import <Flutter/Flutter.h>
|
||||
#import "AMapMethodCallDispatcher.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FlutterMethodChannel (MethodCallDispatch)
|
||||
|
||||
@property (nonatomic,strong,readonly) AMapMethodCallDispatcher* methodCallDispatcher;
|
||||
|
||||
|
||||
/// 添加methodCall的回调(注意:使用该方法之后,就不能再调用setMethodCallHandler: 方法了)
|
||||
/// @param methodName methodName对应call的唯一方法名
|
||||
/// @param handler 回调处理
|
||||
- (void)addMethodName:(NSString *)methodName withHandler:(FlutterMethodCallHandler)handler;
|
||||
|
||||
/// 移除methodCall对应的回调
|
||||
/// @param methodName 唯一的方法名
|
||||
- (void)removeHandlerWithMethodName:(NSString *)methodName;
|
||||
|
||||
/// 清空所有的handler
|
||||
- (void)clearAllHandler;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@ -0,0 +1,42 @@
|
||||
//
|
||||
// FlutterMethodChannel+MethodCallDispatch.m
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/16.
|
||||
//
|
||||
|
||||
#import "FlutterMethodChannel+MethodCallDispatch.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation FlutterMethodChannel (MethodCallDispatch)
|
||||
|
||||
- (AMapMethodCallDispatcher *)methodCallDispatcher {
|
||||
return objc_getAssociatedObject(self, @selector(methodCallDispatcher));
|
||||
}
|
||||
|
||||
- (void)setMethodCallDispatcher:(AMapMethodCallDispatcher *)dispatcher {
|
||||
objc_setAssociatedObject(self, @selector(methodCallDispatcher), dispatcher, OBJC_ASSOCIATION_RETAIN);
|
||||
}
|
||||
|
||||
- (void)addMethodName:(NSString *)methodName withHandler:(FlutterMethodCallHandler)handler {
|
||||
if (self.methodCallDispatcher == nil) {
|
||||
self.methodCallDispatcher = [[AMapMethodCallDispatcher alloc] init];
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[self setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
|
||||
if (weakSelf.methodCallDispatcher) {
|
||||
[weakSelf.methodCallDispatcher onMethodCall:call result:result];
|
||||
}
|
||||
}];
|
||||
}
|
||||
[self.methodCallDispatcher addMethodName:methodName withHandler:handler];
|
||||
}
|
||||
|
||||
- (void)removeHandlerWithMethodName:(NSString *)methodName {
|
||||
[self.methodCallDispatcher removeHandlerWithMethodName:methodName];
|
||||
}
|
||||
|
||||
- (void)clearAllHandler {
|
||||
[self.methodCallDispatcher clearAllHandler];
|
||||
}
|
||||
|
||||
@end
|
20
ios/Classes/Category/MAAnnotationView+Flutter.h
Normal file
20
ios/Classes/Category/MAAnnotationView+Flutter.h
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// MAAnnotationView+Flutter.h
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/5.
|
||||
//
|
||||
|
||||
#import <MAMapKit/MAMapKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class AMapMarker;
|
||||
|
||||
@interface MAAnnotationView (Flutter)
|
||||
|
||||
- (void)updateViewWithMarker:(AMapMarker *)marker;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
40
ios/Classes/Category/MAAnnotationView+Flutter.m
Normal file
40
ios/Classes/Category/MAAnnotationView+Flutter.m
Normal file
@ -0,0 +1,40 @@
|
||||
//
|
||||
// MAAnnotationView+Flutter.m
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/5.
|
||||
//
|
||||
|
||||
#import "MAAnnotationView+Flutter.h"
|
||||
#import "AMapMarker.h"
|
||||
#import "AMapInfoWindow.h"
|
||||
|
||||
@implementation MAAnnotationView (Flutter)
|
||||
|
||||
- (void)updateViewWithMarker:(AMapMarker *)marker {
|
||||
if (marker == nil) {
|
||||
return;
|
||||
}
|
||||
self.alpha = marker.alpha;
|
||||
self.image = marker.image;
|
||||
//anchor变换成地图centerOffset
|
||||
if (self.image) {
|
||||
CGSize imageSize = self.image.size;
|
||||
//iOS的annotationView的中心默认位于annotation的坐标位置,对应的锚点为(0.5,0.5)
|
||||
CGFloat offsetW = imageSize.width * (0.5 - marker.anchor.x);
|
||||
CGFloat offsetH = imageSize.height * (0.5 - marker.anchor.y);
|
||||
self.centerOffset = CGPointMake(offsetW, offsetH);
|
||||
}
|
||||
self.enabled = marker.clickable;
|
||||
self.draggable = marker.draggable;
|
||||
// marker.flat;//flat属性,iOS暂时不开
|
||||
self.canShowCallout = marker.infoWindowEnable;
|
||||
// TODO: 气泡的锚点,由于iOS中的气泡,区分默认气泡和自定义气泡,且无法获得气泡的大小,所以没法将其锚点转换为calloutOffset
|
||||
// self.calloutOffset = marker.infoWindow.anchor;
|
||||
//角度旋转
|
||||
self.imageView.transform = CGAffineTransformMakeRotation(marker.rotation / 180.f * M_PI);
|
||||
self.hidden = (!marker.visible);
|
||||
self.zIndex = marker.zIndex;
|
||||
}
|
||||
|
||||
@end
|
30
ios/Classes/Category/MAMapView+Flutter.h
Normal file
30
ios/Classes/Category/MAMapView+Flutter.h
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// MAMapView+Flutter.h
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/10/30.
|
||||
//
|
||||
|
||||
#import <MAMapKit/MAMapKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class AMapCameraPosition;
|
||||
@class AMapOption;
|
||||
@protocol FlutterPluginRegistrar;
|
||||
|
||||
@interface MAMapView (Flutter)
|
||||
|
||||
- (void)setCameraPosition:(AMapCameraPosition *)cameraPosition animated:(BOOL)animated duration:(CFTimeInterval)duration;
|
||||
|
||||
/// 获取地图的当前cameraPostion
|
||||
- (AMapCameraPosition *)getCurrentCameraPosition;
|
||||
|
||||
/// 地图camera更新操作
|
||||
- (void)setCameraUpdateDict:(NSDictionary *)updateDict;
|
||||
|
||||
- (void)updateMapViewOption:(NSDictionary *)dict withRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
222
ios/Classes/Category/MAMapView+Flutter.m
Normal file
222
ios/Classes/Category/MAMapView+Flutter.m
Normal file
@ -0,0 +1,222 @@
|
||||
//
|
||||
// MAMapView+Flutter.m
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/10/30.
|
||||
//
|
||||
|
||||
#import "MAMapView+Flutter.h"
|
||||
#import "AMapCameraPosition.h"
|
||||
#import "AMapConvertUtil.h"
|
||||
#import "AMapJsonUtils.h"
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@implementation MAMapView (Flutter)
|
||||
|
||||
- (void)setCameraPosition:(AMapCameraPosition *)cameraPosition animated:(BOOL)animated duration:(CFTimeInterval)duration {
|
||||
if (cameraPosition == nil) {
|
||||
return;
|
||||
}
|
||||
MAMapStatus *mapStatus = [MAMapStatus statusWithCenterCoordinate:cameraPosition.target
|
||||
zoomLevel:cameraPosition.zoom
|
||||
rotationDegree:cameraPosition.bearing
|
||||
cameraDegree:cameraPosition.tilt
|
||||
screenAnchor:self.screenAnchor];
|
||||
[self setMapStatus:mapStatus animated:animated duration:duration];
|
||||
}
|
||||
|
||||
- (AMapCameraPosition *)getCurrentCameraPosition {
|
||||
AMapCameraPosition *position = [[AMapCameraPosition alloc] init];
|
||||
position.target = self.centerCoordinate;
|
||||
position.zoom = self.zoomLevel;
|
||||
position.bearing = self.rotationDegree;
|
||||
position.tilt = self.cameraDegree;
|
||||
return position;
|
||||
}
|
||||
|
||||
- (void)setCameraUpdateDict:(NSDictionary *)updateDict {
|
||||
if (updateDict == nil || updateDict.count == 0) {
|
||||
return;
|
||||
}
|
||||
BOOL animated;
|
||||
if ([updateDict[@"animated"] isKindOfClass:[NSNull class]]) {
|
||||
animated = NO;
|
||||
} else {
|
||||
animated = [updateDict[@"animated"] boolValue];
|
||||
}
|
||||
double duration;
|
||||
if ([updateDict[@"duration"] isKindOfClass:[NSNull class]]) {
|
||||
duration = 0;
|
||||
} else {
|
||||
duration = [updateDict[@"duration"] doubleValue]/1000.0;
|
||||
}
|
||||
NSArray *cameraUpdate = updateDict[@"cameraUpdate"];
|
||||
//后面的操作时数组,第一个是操作符,后面才是真的参数;
|
||||
NSAssert(cameraUpdate.count >= 1, @"cameraUpdate 参数错误");
|
||||
NSString *operation = cameraUpdate.firstObject;
|
||||
if ([operation isEqualToString:@"newCameraPosition"] && cameraUpdate.count == 2) {//按照cameraPositon移动
|
||||
AMapCameraPosition *newCameraPosition = [AMapJsonUtils modelFromDict:cameraUpdate[1] modelClass:[AMapCameraPosition class]];
|
||||
[self setCameraPosition:newCameraPosition animated:animated duration:duration];
|
||||
} else if ([operation isEqualToString:@"newLatLng"] && cameraUpdate.count == 2) {//只移动屏幕中心点
|
||||
CLLocationCoordinate2D position = [AMapConvertUtil coordinateFromArray:cameraUpdate[1]];
|
||||
MAMapStatus *currentStatus = [self getMapStatus];
|
||||
currentStatus.centerCoordinate = position;
|
||||
[self setMapStatus:currentStatus animated:animated duration:duration];
|
||||
} else if ([operation isEqualToString:@"newLatLngBounds"] && cameraUpdate.count == 3) {//设置视图的显示范围和边界
|
||||
// TODO: 这里没有使用参数duration
|
||||
MAMapRect boundRect = [AMapConvertUtil mapRectFromArray:cameraUpdate[1]];
|
||||
double padding = [cameraUpdate[2] doubleValue];
|
||||
UIEdgeInsets inset = UIEdgeInsetsMake(padding, padding, padding, padding);
|
||||
[self setVisibleMapRect:boundRect edgePadding:inset animated:animated];
|
||||
} else if ([operation isEqualToString:@"newLatLngZoom"] && cameraUpdate.count == 3) {//设置地图中心点和zoomLevel
|
||||
CLLocationCoordinate2D position = [AMapConvertUtil coordinateFromArray:cameraUpdate[1]];
|
||||
CGFloat zoomLevel = [cameraUpdate[2] floatValue];
|
||||
MAMapStatus *currentStatus = [self getMapStatus];
|
||||
currentStatus.centerCoordinate = position;
|
||||
currentStatus.zoomLevel = zoomLevel;
|
||||
[self setMapStatus:currentStatus animated:animated duration:duration];
|
||||
} else if ([operation isEqualToString:@"scrollBy"] && cameraUpdate.count == 3) {//按照屏幕像素点移动
|
||||
CGPoint pixelPointOffset = CGPointMake([cameraUpdate[1] doubleValue], [cameraUpdate[2] doubleValue]);
|
||||
CGPoint updateCenter = CGPointMake(self.center.x + pixelPointOffset.x/[UIScreen mainScreen].scale, self.center.y + pixelPointOffset.y/[UIScreen mainScreen].scale);
|
||||
CLLocationCoordinate2D centerCoord = [self convertPoint:updateCenter toCoordinateFromView:self];
|
||||
MAMapStatus *currentStatus = [self getMapStatus];
|
||||
currentStatus.centerCoordinate = centerCoord;
|
||||
[self setMapStatus:currentStatus animated:animated duration:duration];
|
||||
} else if ([operation isEqualToString:@"zoomIn"]) {
|
||||
MAMapStatus *currentStatus = [self getMapStatus];
|
||||
currentStatus.zoomLevel = currentStatus.zoomLevel + 1;
|
||||
[self setMapStatus:currentStatus animated:animated duration:duration];
|
||||
} else if ([operation isEqualToString:@"zoomOut"]) {
|
||||
MAMapStatus *currentStatus = [self getMapStatus];
|
||||
currentStatus.zoomLevel = currentStatus.zoomLevel - 1;
|
||||
[self setMapStatus:currentStatus animated:animated duration:duration];
|
||||
} else if ([operation isEqualToString:@"zoomTo"] && cameraUpdate.count == 2) {
|
||||
MAMapStatus *currentStatus = [self getMapStatus];
|
||||
currentStatus.zoomLevel = [cameraUpdate[1] doubleValue];
|
||||
[self setMapStatus:currentStatus animated:animated duration:duration];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)updateMapViewOption:(NSDictionary *)dict withRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||
if ([dict isKindOfClass:[NSDictionary class]] == NO || dict == nil || dict.count == 0) {
|
||||
return;
|
||||
}
|
||||
//地图类型
|
||||
NSNumber *mapType = dict[@"mapType"];
|
||||
if (mapType) {
|
||||
self.mapType = mapType.integerValue;
|
||||
}
|
||||
NSDictionary *customStyleOptions = dict[@"customStyleOptions"];
|
||||
if (customStyleOptions) {
|
||||
BOOL customMapStyleEnabled = [customStyleOptions[@"enabled"] boolValue];
|
||||
self.customMapStyleEnabled = customMapStyleEnabled;
|
||||
if (customMapStyleEnabled) {
|
||||
MAMapCustomStyleOptions *styleOption = [[MAMapCustomStyleOptions alloc] init];
|
||||
styleOption.styleData = ((FlutterStandardTypedData*)customStyleOptions[@"styleData"]).data;
|
||||
styleOption.styleExtraData = ((FlutterStandardTypedData*)customStyleOptions[@"styleExtraData"]).data;
|
||||
[self setCustomMapStyleOptions:styleOption];
|
||||
}
|
||||
}
|
||||
|
||||
NSDictionary *locationStyleDict = dict[@"myLocationStyle"];
|
||||
if (locationStyleDict) {
|
||||
BOOL showUserLocation = [locationStyleDict[@"enabled"] boolValue];
|
||||
self.showsUserLocation = showUserLocation;
|
||||
if (showUserLocation) {
|
||||
self.userTrackingMode = MAUserTrackingModeNone;//强制设置为非追随模式,追随模式后续在demo中,使用自定义定位样式实现
|
||||
if (locationStyleDict[@"circleFillColor"] != nil
|
||||
|| locationStyleDict[@"circleStrokeColor"] != nil
|
||||
|| locationStyleDict[@"circleStrokeWidth"] != nil
|
||||
|| locationStyleDict[@"icon"] != nil) {//自定义样式有不为空的属性时,才启动自定义的样式设置
|
||||
MAUserLocationRepresentation *locationStyle = [[MAUserLocationRepresentation alloc] init];
|
||||
if (locationStyleDict[@"circleFillColor"]) {
|
||||
locationStyle.fillColor = [AMapConvertUtil colorFromNumber:locationStyleDict[@"circleFillColor"]];
|
||||
}
|
||||
if (locationStyleDict[@"circleStrokeColor"]) {
|
||||
locationStyle.strokeColor = [AMapConvertUtil colorFromNumber:locationStyleDict[@"circleStrokeColor"]];
|
||||
}
|
||||
if (locationStyleDict[@"circleStrokeWidth"]) {
|
||||
locationStyle.lineWidth = [locationStyleDict[@"circleStrokeWidth"] doubleValue];
|
||||
}
|
||||
if (locationStyleDict[@"icon"]) {
|
||||
locationStyle.image = [AMapConvertUtil imageFromRegistrar:registrar iconData:locationStyleDict[@"icon"]];
|
||||
}
|
||||
[self updateUserLocationRepresentation:locationStyle];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///地图锚点
|
||||
NSArray *screenAnchor = dict[@"screenAnchor"];
|
||||
if (screenAnchor) {
|
||||
CGPoint anchorPoint = [AMapConvertUtil pointFromArray:screenAnchor];
|
||||
self.screenAnchor = anchorPoint;
|
||||
}
|
||||
|
||||
//缩放级别范围
|
||||
NSArray* zoomData = dict[@"minMaxZoomPreference"];
|
||||
if (zoomData) {
|
||||
CGFloat minZoom = (zoomData[0] == [NSNull null]) ? 3.0 : [zoomData[0] doubleValue];
|
||||
self.minZoomLevel = minZoom;
|
||||
CGFloat maxZoom = (zoomData[1] == [NSNull null]) ? 20.0 : [zoomData[1] doubleValue];
|
||||
self.maxZoomLevel = maxZoom;
|
||||
}
|
||||
NSArray *limitBounds = dict[@"limitBounds"];
|
||||
if (limitBounds) {
|
||||
MAMapRect limitRect = [AMapConvertUtil mapRectFromArray:limitBounds];
|
||||
self.limitMapRect = limitRect;
|
||||
}
|
||||
//显示路况开关
|
||||
NSNumber *showTraffic = dict[@"trafficEnabled"];
|
||||
if (showTraffic) {
|
||||
self.showTraffic = [showTraffic boolValue];
|
||||
}
|
||||
// 地图poi是否允许点击
|
||||
NSNumber *touchPOIEnable = dict[@"touchPoiEnabled"];
|
||||
if (touchPOIEnable) {
|
||||
self.touchPOIEnabled = [touchPOIEnable boolValue];
|
||||
}
|
||||
//是否显示3D建筑物
|
||||
NSNumber *showBuilding = dict[@"buildingsEnabled"];
|
||||
if (showBuilding) {
|
||||
self.showsBuildings = [showBuilding boolValue];
|
||||
}
|
||||
//是否显示底图文字标注
|
||||
NSNumber *showLable = dict[@"labelsEnabled"];
|
||||
if (showLable) {
|
||||
self.showsLabels = [showLable boolValue];
|
||||
}
|
||||
//是否显示指南针
|
||||
NSNumber *showCompass = dict[@"compassEnabled"];
|
||||
if (showCompass) {
|
||||
self.showsCompass = [showCompass boolValue];
|
||||
}
|
||||
//是否显示比例尺
|
||||
NSNumber *showScale = dict[@"scaleEnabled"];
|
||||
if (showScale) {
|
||||
self.showsScale = [showScale boolValue];
|
||||
}
|
||||
//是否支持缩放手势
|
||||
NSNumber *zoomEnable = dict[@"zoomGesturesEnabled"];
|
||||
if (zoomEnable) {
|
||||
self.zoomEnabled = [zoomEnable boolValue];
|
||||
}
|
||||
//是否支持滑动手势
|
||||
NSNumber *scrollEnable = dict[@"scrollGesturesEnabled"];
|
||||
if (scrollEnable) {
|
||||
self.scrollEnabled = [scrollEnable boolValue];
|
||||
}
|
||||
//是否支持旋转手势
|
||||
NSNumber *rotateEnable = dict[@"rotateGesturesEnabled"];
|
||||
if (rotateEnable) {
|
||||
self.rotateEnabled = [rotateEnable boolValue];
|
||||
}
|
||||
//是否支持仰角手势
|
||||
NSNumber *rotateCameraEnable = dict[@"tiltGesturesEnabled"];
|
||||
if (rotateCameraEnable) {
|
||||
self.rotateCameraEnabled = [rotateCameraEnable boolValue];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
29
ios/Classes/Category/MAPointAnnotation+Flutter.h
Normal file
29
ios/Classes/Category/MAPointAnnotation+Flutter.h
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// MAPointAnnotation+Flutter.h
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/9.
|
||||
//
|
||||
|
||||
#import <MAMapKit/MAMapKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// AnnotationView的复用标识
|
||||
extern NSString *const AMapFlutterAnnotationViewIdentifier;
|
||||
|
||||
/// 该拓展类型主要用于对地图原PointAnnotation添加一个唯一id,
|
||||
/// 便于在地图回调代理中,通过id快速找到对应的AMapMarker对象,
|
||||
/// 以此来构建对应的MAAnnotatioView
|
||||
@interface MAPointAnnotation (Flutter)
|
||||
|
||||
//为Annotation拓展存储的flutter传入的markerId,便于快速查找对应的marker数据
|
||||
@property (nullable,nonatomic,copy,readonly) NSString *markerId;
|
||||
|
||||
/// 使用MarkerId初始化对应的Annotation
|
||||
/// @param markerId marker的唯一标识
|
||||
- (instancetype)initWithMarkerId:(NSString *)markerId;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
31
ios/Classes/Category/MAPointAnnotation+Flutter.m
Normal file
31
ios/Classes/Category/MAPointAnnotation+Flutter.m
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// MAPointAnnotation+Flutter.m
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/9.
|
||||
//
|
||||
|
||||
#import "MAPointAnnotation+Flutter.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
NSString *const AMapFlutterAnnotationViewIdentifier = @"AMapFlutterAnnotationViewIdentifier";
|
||||
|
||||
@implementation MAPointAnnotation (Flutter)
|
||||
|
||||
- (NSString *)markerId {
|
||||
return objc_getAssociatedObject(self, @selector(markerId));
|
||||
}
|
||||
|
||||
- (void)setMarkerId:(NSString * _Nonnull)markerId {
|
||||
objc_setAssociatedObject(self, @selector(markerId), markerId, OBJC_ASSOCIATION_COPY);
|
||||
}
|
||||
|
||||
- (instancetype)initWithMarkerId:(NSString *)markerId {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.markerId = markerId;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
26
ios/Classes/Category/MAPolygon+Flutter.h
Normal file
26
ios/Classes/Category/MAPolygon+Flutter.h
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// MAPolygon+Flutter.h
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/12.
|
||||
//
|
||||
|
||||
#import <MAMapKit/MAMapKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 该拓展类型主要用于对地图原MAPolygon添加一个唯一id,
|
||||
/// 便于在地图回调代理中,通过id快速找到对应的AMapPolyline对象,
|
||||
/// 以此来构建对应的polygonRender
|
||||
|
||||
@interface MAPolygon (Flutter)
|
||||
|
||||
@property (nonatomic,copy,readonly) NSString *polygonId;
|
||||
|
||||
/// 使用polygonId初始化对应的MAPolygon
|
||||
/// @param polygonId polylgon的唯一标识
|
||||
- (instancetype)initWithPolygonId:(NSString *)polygonId;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
29
ios/Classes/Category/MAPolygon+Flutter.m
Normal file
29
ios/Classes/Category/MAPolygon+Flutter.m
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// MAPolygon+Flutter.m
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/12.
|
||||
//
|
||||
|
||||
#import "MAPolygon+Flutter.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation MAPolygon (Flutter)
|
||||
|
||||
- (NSString *)polygonId {
|
||||
return objc_getAssociatedObject(self, @selector(polygonId));
|
||||
}
|
||||
|
||||
- (void)setPolygonId:(NSString * _Nonnull)polygonId {
|
||||
objc_setAssociatedObject(self, @selector(polygonId), polygonId, OBJC_ASSOCIATION_COPY);
|
||||
}
|
||||
|
||||
- (instancetype)initWithPolygonId:(NSString *)polygonId {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.polygonId = polygonId;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
20
ios/Classes/Category/MAPolygonRenderer+Flutter.h
Normal file
20
ios/Classes/Category/MAPolygonRenderer+Flutter.h
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// MAPolygonRenderer+Flutter.h
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/12.
|
||||
//
|
||||
|
||||
#import <MAMapKit/MAMapKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class AMapPolygon;
|
||||
|
||||
@interface MAPolygonRenderer (Flutter)
|
||||
|
||||
- (void)updateRenderWithPolygon:(AMapPolygon *)polygon;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
26
ios/Classes/Category/MAPolygonRenderer+Flutter.m
Normal file
26
ios/Classes/Category/MAPolygonRenderer+Flutter.m
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// MAPolygonRenderer+Flutter.m
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/12.
|
||||
//
|
||||
|
||||
#import "MAPolygonRenderer+Flutter.h"
|
||||
#import "AMapPolygon.h"
|
||||
|
||||
@implementation MAPolygonRenderer (Flutter)
|
||||
|
||||
- (void)updateRenderWithPolygon:(AMapPolygon *)polygon {
|
||||
self.lineWidth = polygon.strokeWidth;
|
||||
self.strokeColor = polygon.strokeColor;
|
||||
self.fillColor = polygon.fillColor;
|
||||
self.lineJoinType = polygon.joinType;
|
||||
if (polygon.visible) {
|
||||
self.alpha = 1.0;
|
||||
} else {
|
||||
self.alpha = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
26
ios/Classes/Category/MAPolyline+Flutter.h
Normal file
26
ios/Classes/Category/MAPolyline+Flutter.h
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// MAPolyline+Flutter.h
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/9.
|
||||
//
|
||||
|
||||
#import <MAMapKit/MAMapKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 该拓展类型主要用于对地图原MAPolyline添加一个唯一id,
|
||||
/// 便于在地图回调代理中,通过id快速找到对应的AMapPolyline对象,
|
||||
/// 以此来构建对应的polylineRender
|
||||
|
||||
@interface MAPolyline (Flutter)
|
||||
|
||||
@property (nonatomic,copy,readonly) NSString *polylineId;
|
||||
|
||||
/// 使用polylineId初始化对应的MAPolyline
|
||||
/// @param polylineId polyline的唯一标识
|
||||
- (instancetype)initWithPolylineId:(NSString *)polylineId;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
29
ios/Classes/Category/MAPolyline+Flutter.m
Normal file
29
ios/Classes/Category/MAPolyline+Flutter.m
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// MAPolyline+Flutter.m
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/9.
|
||||
//
|
||||
|
||||
#import "MAPolyline+Flutter.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation MAPolyline (Flutter)
|
||||
|
||||
- (NSString *)polylineId {
|
||||
return objc_getAssociatedObject(self, @selector(polylineId));
|
||||
}
|
||||
|
||||
- (void)setPolylineId:(NSString * _Nonnull)polylineId {
|
||||
objc_setAssociatedObject(self, @selector(polylineId), polylineId, OBJC_ASSOCIATION_COPY);
|
||||
}
|
||||
|
||||
- (instancetype)initWithPolylineId:(NSString *)polylineId {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.polylineId = polylineId;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
20
ios/Classes/Category/MAPolylineRenderer+Flutter.h
Normal file
20
ios/Classes/Category/MAPolylineRenderer+Flutter.h
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// MAPolylineRenderer+Flutter.h
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/7.
|
||||
//
|
||||
|
||||
#import <MAMapKit/MAMapKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class AMapPolyline;
|
||||
|
||||
@interface MAPolylineRenderer (Flutter)
|
||||
|
||||
- (void)updateRenderWithPolyline:(AMapPolyline *)polyline;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
30
ios/Classes/Category/MAPolylineRenderer+Flutter.m
Normal file
30
ios/Classes/Category/MAPolylineRenderer+Flutter.m
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// MAPolylineRenderer+Flutter.m
|
||||
// amap_map
|
||||
//
|
||||
// Created by lly on 2020/11/7.
|
||||
//
|
||||
|
||||
#import "MAPolylineRenderer+Flutter.h"
|
||||
#import "AMapPolyline.h"
|
||||
|
||||
@implementation MAPolylineRenderer (Flutter)
|
||||
|
||||
- (void)updateRenderWithPolyline:(AMapPolyline *)polyline {
|
||||
self.lineWidth = polyline.width;
|
||||
self.strokeColor = polyline.color;
|
||||
if (polyline.visible) {//可见时,才设置透明度
|
||||
self.alpha = polyline.alpha;
|
||||
} else {
|
||||
self.alpha = 0;
|
||||
}
|
||||
if (polyline.strokeImage) {
|
||||
self.strokeImage = polyline.strokeImage;
|
||||
}
|
||||
self.lineDashType = polyline.dashLineType;
|
||||
self.lineJoinType = polyline.joinType;
|
||||
self.lineCapType = polyline.capType;
|
||||
self.userInteractionEnabled = YES;//默认可点击
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user