New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
iOS Development Discussion on developing apps for the iOS platform.

Custom Pin Issue


Post Reply New Thread Subscribe

 
Thread Tools
Jakesta42

 
Member Since: Mar 08, 2011
Posts: 4
Jakesta42 is on a distinguished road

Jakesta42 is offline
So I have this problem. I'm trying to add a bunch of annotations to my MapView, of various different colors. I've implemented the correct protocols, and I'm calling the addAnnotation method in the map view object. The issue is that either none or very few annotations appear (I'm not sure what the factor that determines this change is).

I have this method called updateNodes that is being called regularly (about every 5 seconds). This method goes through an array of custom objects I've made called, Party objects. In my main View Controller I have a property called "currentParty" which the current party points through. The objective of this method is pretty much to loop through each party, adding it to the map, and then stop.

Theoretically this is all working to the program. There are around 8 Party objects at a time in the array, and each object has the "addAnnotation" method called on it (I've tested it with a few NSLog statements). But the error is that the annotations themselves aren't being added to the map. I've overridden the viewForAnnotation method, but that method for some reason is being delayed when it's getting called, and it's only getting called around once, when I expected it to be getting called each time the addAnnotation method is called (which is about 8 times). However it is only called once (again, tested with a print statement at the top of the method).

The code is below:

Code:
//Main view controller
- (void)viewDidLoad{
    currentParty = [[Party alloc] init];
    [ViewController instantiatePartyArray];
    initialPinAlreadyAdded = NO;
    NSLog(@"View Did Load Called");
    [super viewDidLoad];
	manager = [[CLLocationManager alloc] init];     //Instantiate CLLocationManager
         //Array that holds all parties. Should be populated from the database
    manager.desiredAccuracy = kCLLocationAccuracyBest;  //Best accuracy
    manager.delegate = self;            //Delegate the manager to affect this View Controller
    self.map.delegate = self;
    [manager startUpdatingLocation];     //Triangulate location
    NSLog(@"Triangulation Started");
    MKCoordinateSpan span;
    span.latitudeDelta = 0.01;      //10 km up and down
    span.longitudeDelta = 0.01;     //10 km side to side
    MKCoordinateRegion region;
    region.span = span;
    region.center = startingUserLocation.coordinate;
    if(loc.coordinate.latitude != 0 && loc.coordinate.longitude != 0){
        [map setRegion: region animated: YES];
        NSLog(@"Setting Region");
    }
    else{
        [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(lockToLocation:) userInfo:nil repeats:NO];
        NSLog(@"Waiting Started");
    }
    NSLog(@"Waiting Finished");
    [ViewController updateArray];
    [self updateNodes];
    
}
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation{
    NSLog(@"Map View Method Called");
    MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
    pinView.pinColor = [currentParty getPartyColor];
    currentParty.annot.title = [currentParty getPartyName];
    return pinView;
}
-(void) updateNodes{
    for(Party *party in allParties){
        if(!party.alreadyAdded){
            party.alreadyAdded = YES;
            currentParty = party;
            [map addAnnotation:currentParty.annot];
            NSLog(@"Adding Successful!");
        }
    }
}
Really not liking the way I have to deal with custom annotations!
QUOTE Thanks

Post Reply New Thread Subscribe


« Creating an App for Coeliacs | Drawing Annotations to Map? Help!! »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
4 pin to Mini Display Port? ImageExtensions Movies and Video 0 05-26-2011 04:08 PM
needed Apple Display adapter 29 pin combined DVI - male 1 x 4 pin USB Type A - male - jessicamcgj Other Hardware and Peripherals 1 03-18-2011 03:22 PM
I Pod touch - photos issue andrewmpalmer iPod Hardware and Accessories 2 09-06-2010 03:41 PM
Apple deleting posts again - iPhone 4 antenna issue robains iPhone Hardware and Accessories 7 07-23-2010 11:23 AM
Macbook Pro Firewire issue Monteh Apple Notebooks 2 01-25-2010 11:40 PM

All times are GMT -4. The time now is 03:26 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?