Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
20 changes: 20 additions & 0 deletions ios/RCTBaiduMap/Models/BMKPointAnnotationPro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// BMKPointAnnotationPro.h
// CodePush
//
// Created by n on 2019/12/9.
//

#import <BaiduMapAPI_Map/BMKPointAnnotation.h>
#import <BaiduMapAPI_Map/BMKAnnotationView.h>


NS_ASSUME_NONNULL_BEGIN
//为什么是Pro呢?因为它在创建时就关联了View
@interface BMKPointAnnotationPro : BMKPointAnnotation

@property (nonatomic,copy) BMKAnnotationView *(^getAnnotationView)(BMKPointAnnotation *annotation);

@end

NS_ASSUME_NONNULL_END
20 changes: 20 additions & 0 deletions ios/RCTBaiduMap/Models/BMKPointAnnotationPro.m
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions ios/RCTBaiduMap/RCBMImageAnnotView/RCBMImageAnnotView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// RCBMImageAnnotView.h
// react-native-baidu-map
//
// Created by n on 2019/12/9.
//

#import <UIKit/UIKit.h>
#import <BaiduMapAPI_Map/BMKPointAnnotation.h>
#import <BaiduMapAPI_Map/BMKAnnotationView.h>
@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
52 changes: 52 additions & 0 deletions ios/RCTBaiduMap/RCBMImageAnnotView/RCBMImageAnnotView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// RCBMImageAnnotView.m
// react-native-baidu-map
//
// Created by n on 2019/12/9.
//

#import "RCBMImageAnnotView.h"
#import "RCTImageView.h"
#import <React/RCTImageSource.h>
#import <React/UIView+React.h>

// RCTImageView的属性:
//@property (nonatomic, copy) NSArray<RCTImageSource *> *imageSources;

@implementation RCBMImageAnnotView
-(id)initWithAnnotation:(id<BMKAnnotation>)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