Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (IBAction)playBtn:(id)sender {
- timer = [NSTimer scheduledTimerWithTimeInterval:(4.0) target:self selector:@selector(control) userInfo:nil repeats:YES];
- }
- -(void)control{
- NSMutableArray *annotationArray = [[[NSMutableArray alloc] init] autorelease];
- switch (value%2) {
- case 0:
- {
- // Create some annotations
- Annotation *annotation = nil;
- annotation = [[Annotation alloc] init];
- annotation.coordinate = CLLocationCoordinate2DMake(29.7161,-95.3906);
- annotation.color = RGB(13, 0, 182);
- annotation.title = @"17";
- [annotationArray addObject:annotation];
- [annotation release];
- annotation = [[Annotation alloc] init];
- annotation.coordinate = CLLocationCoordinate2DMake(30.168456,-95.504480);
- annotation.color = RGB(0, 182, 146);
- annotation.title = @"16";
- [annotationArray addObject:annotation];
- [annotation release];
- // Center map
- //self.mapView.visibleMapRect = [self makeMapRectWithAnnotations:annotationArray];
- // Add to map
- //[self.mapView addAnnotations:annotationArray];
- }
- break;
- case 1:
- {
- // Create some annotations
- Annotation *annotation = nil;
- annotation = [[Annotation alloc] init];
- annotation.coordinate = CLLocationCoordinate2DMake(29.7161,-95.3906);
- annotation.color = RGB(13, 0, 182);
- annotation.title = @"27";
- [annotationArray addObject:annotation];
- [annotation release];
- annotation = [[Annotation alloc] init];
- annotation.coordinate = CLLocationCoordinate2DMake(30.168456,-95.504480);
- annotation.color = RGB(0, 182, 146);
- annotation.title = @"25";
- [annotationArray addObject:annotation];
- [annotation release];
- }
- break;
- }
- [self.mapView addAnnotations:annotationArray];
- [mapView setNeedsDisplay];
- value++;
- BOOL annFound = NO;
- //loop through the map view's annotations array to find annotation id# 42...
- for (id<MKAnnotation> ann in mapView.annotations)
- {
- if ([ann isKindOfClass:[MyAnnotationClass class]])
- {
- MyAnnotationClass *myAnn = (MyAnnotationClass *)ann;
- if (myAnn.annotationId == 42)
- {
- annFound = YES;
- myAnn.title = @"some new title";
- break;
- }
- }
- }
- if (!annFound)
- {
- //annotation id# 42 is not yet on the map.
- //create it and add to map...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement