Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lovebing authored and lovebing committed Sep 28, 2016
1 parent 65886b3 commit d74c3d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion ios/RCTBaiduMap/RCTBaiduMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,38 @@ -(void)setMarker:(NSDictionary *)option {

-(void)setMarkers:(NSArray *)markers {
int markersCount = [markers count];
if(_annotations == nil) {
_annotations = [[NSMutableArray alloc] init];
}
if(markers != nil) {
for (int i = 0; i < markersCount; i++) {
NSDictionary *option = [markers objectAtIndex:i];

BMKPointAnnotation *annotation = [_annotations objectAtIndex:i];
BMKPointAnnotation *annotation = nil;
if(i < [_annotations count]) {
annotation = [_annotations objectAtIndex:i];
}
if(annotation == nil) {
annotation = [[BMKPointAnnotation alloc]init];
[self addMarker:annotation option:option];
[_annotations addObject:annotation];
}
else {
[self updateMarker:annotation option:option];
}
}

int _annotationsCount = [_annotations count];

NSString *smarkersCount = [NSString stringWithFormat:@"%d", markersCount];
NSString *sannotationsCount = [NSString stringWithFormat:@"%d", _annotationsCount];
NSLog(smarkersCount);
NSLog(sannotationsCount);

if(markersCount < _annotationsCount) {
int start = _annotationsCount - markersCount;
for(int i = start; i < _annotationsCount; i++) {
NSLog(@"forforforfor");
BMKPointAnnotation *annotation = [_annotations objectAtIndex:i];
[self removeAnnotation:annotation];
[_annotations removeObject:annotation];
Expand Down Expand Up @@ -86,6 +100,9 @@ -(void)addMarker:(BMKPointAnnotation *)annotation option:(NSDictionary *)option
-(void)updateMarker:(BMKPointAnnotation *)annotation option:(NSDictionary *)option {
CLLocationCoordinate2D coor = [self getCoorFromMarkerOption:option];
NSString *title = [RCTConvert NSString:option[@"title"]];
if(title.length == 0) {
title = nil;
}
annotation.coordinate = coor;
annotation.title = title;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-baidu-map",
"version": "0.4.0",
"version": "0.4.1",
"description": "Baidu Map SDK For React Native, Support both Android and IOS.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit d74c3d7

Please sign in to comment.