Weex开发之地图篇的具体使用(3)

- (instancetype)initWithRef:(NSString *)ref type:(NSString*)type styles:(nullable NSDictionary *)styles attributes:(nullable NSDictionary *)attributes events:(nullable NSArray *)events weexInstance:(WXSDKInstance *)weexInstance { self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]; if (self) { if (attributes[@"open"]) { _isOpen = [attributes[@"open"] boolValue]; } } return self; } - (UIView *) loadView { return [[DMapInfoWindow alloc] initWithAnnotation:_annotation reuseIdentifier:_identifier]; } - (void)insertSubview:(WXComponent *)subcomponent atIndex:(NSInteger)index{} - (void)updateAttributes:(NSDictionary *)attributes { [super updateAttributes:attributes]; if (attributes[@"open"]) { _isOpen = [attributes[@"open"] boolValue]; if (_isOpen) { [self _addSubView]; }else { [self _removeViewFromSuperView]; } } } #pragma mark - private method 1. (void)_addSubView { [self _removeViewFromSuperView]; [(DMapViewComponent *)self.supercomponent addMarker:self]; } 2. (void)_removeViewFromSuperView { [(DMapViewComponent *)self.supercomponent removeMarker:self]; }

2.4 weex-amap-circle

weex-amap-circle组件主要用于实现画圈功能,如地图范围,其效果如下图所示:

在这里插入图片描述

新建DMapCircleComponent类继承WXComponent;

在DMapViewComponent中使用mapview的addOverlay方法添加DMapCircleComponent组件;

在DMapViewComponent重写insertSubview方法来添加子组建圆。

下面是部分实现逻辑:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/6aad1e73875f62d2873f0909d7946d2b.html