diff --git a/android/src/main/java/org/lovebing/reactnative/baidumap/uimanager/MapViewManager.java b/android/src/main/java/org/lovebing/reactnative/baidumap/uimanager/MapViewManager.java index cf2f6117..a9ccf733 100644 --- a/android/src/main/java/org/lovebing/reactnative/baidumap/uimanager/MapViewManager.java +++ b/android/src/main/java/org/lovebing/reactnative/baidumap/uimanager/MapViewManager.java @@ -112,7 +112,7 @@ public void setShowsUserLocation(TextureMapView mapView, boolean showsUserLocati } @ReactProp(name = "showMapPoi") - public void showMapPoi(MapView mapView, boolean showMapPoi) { + public void showMapPoi(TextureMapView mapView, boolean showMapPoi) { mapView.getMap().showMapPoi(showMapPoi); } diff --git a/ios/RCTBaiduMap/Models/BMKPointAnnotationPro.h b/ios/RCTBaiduMap/Models/BMKPointAnnotationPro.h new file mode 100644 index 00000000..ec38991d --- /dev/null +++ b/ios/RCTBaiduMap/Models/BMKPointAnnotationPro.h @@ -0,0 +1,20 @@ +// +// BMKPointAnnotationPro.h +// CodePush +// +// Created by n on 2019/12/9. +// + +#import +#import + + +NS_ASSUME_NONNULL_BEGIN +//为什么是Pro呢?因为它在创建时就关联了View +@interface BMKPointAnnotationPro : BMKPointAnnotation + +@property (nonatomic,copy) BMKAnnotationView *(^getAnnotationView)(BMKPointAnnotation *annotation); + +@end + +NS_ASSUME_NONNULL_END diff --git a/ios/RCTBaiduMap/Models/BMKPointAnnotationPro.m b/ios/RCTBaiduMap/Models/BMKPointAnnotationPro.m new file mode 100644 index 00000000..08500110 --- /dev/null +++ b/ios/RCTBaiduMap/Models/BMKPointAnnotationPro.m @@ -0,0 +1,20 @@ +// +// BMKPointAnnotationPro.m +// CodePush +// +// Created by n on 2019/12/9. +// + +#import "BMKPointAnnotationPro.h" + + +@implementation BMKPointAnnotationPro +- (instancetype)init +{ + self = [super init]; + if (self) { + + } + return self; +} +@end diff --git a/ios/RCTBaiduMap/RCBMImageAnnotView/RCBMImageAnnotView.h b/ios/RCTBaiduMap/RCBMImageAnnotView/RCBMImageAnnotView.h new file mode 100644 index 00000000..7d4e0f1f --- /dev/null +++ b/ios/RCTBaiduMap/RCBMImageAnnotView/RCBMImageAnnotView.h @@ -0,0 +1,22 @@ +// +// RCBMImageAnnotView.h +// react-native-baidu-map +// +// Created by n on 2019/12/9. +// + +#import +#import +#import +@class RCTImageSource; +@class RCTBridge; + +NS_ASSUME_NONNULL_BEGIN + +@interface RCBMImageAnnotView : BMKAnnotationView +@property (nonatomic,strong) RCTBridge * bridge; +@property (nonatomic,strong) RCTImageSource * source; + +@end + +NS_ASSUME_NONNULL_END diff --git a/ios/RCTBaiduMap/RCBMImageAnnotView/RCBMImageAnnotView.m b/ios/RCTBaiduMap/RCBMImageAnnotView/RCBMImageAnnotView.m new file mode 100644 index 00000000..35018189 --- /dev/null +++ b/ios/RCTBaiduMap/RCBMImageAnnotView/RCBMImageAnnotView.m @@ -0,0 +1,52 @@ +// +// RCBMImageAnnotView.m +// react-native-baidu-map +// +// Created by n on 2019/12/9. +// + +#import "RCBMImageAnnotView.h" +#import "RCTImageView.h" +#import +#import + +// RCTImageView的属性: +//@property (nonatomic, copy) NSArray *imageSources; + +@implementation RCBMImageAnnotView +-(id)initWithAnnotation:(id)annotation reuseIdentifier:(NSString *)reuseIdentifier{ + self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]; + if(self){ + } + return self; +} + + +- (void)setSource:(RCTImageSource *)source{ + NSAssert(self.bridge, @"must setBridge first"); + if (source) { + _source = source; + } else { + _source = [self.class defaultSource];//source可能为nil,这时提供默认值 + } + + CGRect frame = CGRectMake(0, 0, self.source.size.width,self.source.size.height); + + RCTImageView *iv = [[RCTImageView alloc] initWithBridge:self.bridge]; + [iv setImageSources:@[self.source]]; + [iv reactSetFrame:frame]; + + [self addSubview:iv]; + self.bounds = frame; +} + ++ (RCTImageSource *)defaultSource { + NSURL *url = [[NSBundle mainBundle]URLForResource:@"rn-baidu-map-default_marker_icon@2x.png" withExtension:@""]; + NSURLRequest *req = [[NSURLRequest alloc]initWithURL:url]; + CGSize size = CGSizeMake(30, 30); + CGFloat scale = 2; + RCTImageSource * s = [[RCTImageSource alloc]initWithURLRequest:req size:size scale:scale]; + return s; +} +@end +