@@ -40,24 +40,38 @@ -(void)setMarker:(NSDictionary *)option {
4040
4141-(void )setMarkers : (NSArray *)markers {
4242 int markersCount = [markers count ];
43+ if (_annotations == nil ) {
44+ _annotations = [[NSMutableArray alloc ] init ];
45+ }
4346 if (markers != nil ) {
4447 for (int i = 0 ; i < markersCount; i++) {
4548 NSDictionary *option = [markers objectAtIndex: i];
4649
47- BMKPointAnnotation *annotation = [_annotations objectAtIndex: i];
50+ BMKPointAnnotation *annotation = nil ;
51+ if (i < [_annotations count ]) {
52+ annotation = [_annotations objectAtIndex: i];
53+ }
4854 if (annotation == nil ) {
4955 annotation = [[BMKPointAnnotation alloc ]init];
5056 [self addMarker: annotation option: option];
57+ [_annotations addObject: annotation];
5158 }
5259 else {
5360 [self updateMarker: annotation option: option];
5461 }
5562 }
5663
5764 int _annotationsCount = [_annotations count ];
65+
66+ NSString *smarkersCount = [NSString stringWithFormat: @" %d " , markersCount];
67+ NSString *sannotationsCount = [NSString stringWithFormat: @" %d " , _annotationsCount];
68+ NSLog (smarkersCount);
69+ NSLog (sannotationsCount);
70+
5871 if (markersCount < _annotationsCount) {
5972 int start = _annotationsCount - markersCount;
6073 for (int i = start; i < _annotationsCount; i++) {
74+ NSLog (@" forforforfor" );
6175 BMKPointAnnotation *annotation = [_annotations objectAtIndex: i];
6276 [self removeAnnotation: annotation];
6377 [_annotations removeObject: annotation];
@@ -86,6 +100,9 @@ -(void)addMarker:(BMKPointAnnotation *)annotation option:(NSDictionary *)option
86100-(void )updateMarker : (BMKPointAnnotation *)annotation option : (NSDictionary *)option {
87101 CLLocationCoordinate2D coor = [self getCoorFromMarkerOption: option];
88102 NSString *title = [RCTConvert NSString: option[@" title" ]];
103+ if (title.length == 0 ) {
104+ title = nil ;
105+ }
89106 annotation.coordinate = coor;
90107 annotation.title = title;
91108}
0 commit comments