MKMap showing detail of annotations

Posted by yeohchan on Stack Overflow See other posts from Stack Overflow or by yeohchan
Published on 2010-03-19T15:41:06Z Indexed on 2010/03/19 15:41 UTC
Read the original article Hit count: 299

Filed under:
|

I have encountered a problem of populating the description for each annotation. Each annotation works, but there is somehow an area when trying to click on it. Here is the code. the one in bold is the one that has the problem.

    -(void)viewDidLoad{
    FlickrFetcher *fetcher=[FlickrFetcher sharedInstance];
    NSArray *rec=[fetcher recentGeoTaggedPhotos];
    for(NSDictionary *dic in rec){
        NSLog(@"%@",dic);
        NSDictionary *string = [fetcher locationForPhotoID:[dic objectForKey:@"id"]];
        double latitude = [[string objectForKey:@"latitude"] doubleValue];
        double longitude = [[string objectForKey:@"longitude"]doubleValue];
        if(latitude !=0 && latitude != 0 ){
            CLLocationCoordinate2D  coordinate1 = {
            latitude,longitude
            };
            **NSDictionary *adress=[NSDictionary dictionaryWithObjectsAndKeys:[dic objectForKey:@"owner"],[dic objectForKey:@"title"],nil];**
            MKPlacemark *anArea=[[MKPlacemark alloc]initWithCoordinate:coordinate1 addressDictionary:adress];
            [mapView addAnnotation:anArea];
        }
    }
}

Here is what the Flickr class does:

#import <Foundation/Foundation.h>

#define TEST_HIGH_NETWORK_LATENCY 0

typedef enum {
    FlickrFetcherPhotoFormatSquare,
    FlickrFetcherPhotoFormatLarge
} FlickrFetcherPhotoFormat;

@interface FlickrFetcher : NSObject {
    NSManagedObjectModel *managedObjectModel;
    NSManagedObjectContext *managedObjectContext;
    NSPersistentStoreCoordinator *persistentStoreCoordinator;
}

// Returns the 'singleton' instance of this class
+ (id)sharedInstance;

//
// Local Database Access
//

// Checks to see if any database exists on disk
- (BOOL)databaseExists;

// Returns the NSManagedObjectContext for inserting and fetching objects into the store
- (NSManagedObjectContext *)managedObjectContext;

// Returns an array of objects already in the database for the given Entity Name and Predicate
- (NSArray *)fetchManagedObjectsForEntity:(NSString*)entityName withPredicate:(NSPredicate*)predicate;

// Returns an NSFetchedResultsController for a given Entity Name and Predicate
- (NSFetchedResultsController *)fetchedResultsControllerForEntity:(NSString*)entityName withPredicate:(NSPredicate*)predicate;

//
// Flickr API access
// NOTE: these are blocking methods that wrap the Flickr API and wait on the results of a network request
//

// Returns an array of Flickr photo information for photos with the given tag
- (NSArray *)photosForUser:(NSString *)username;

// Returns an array of the most recent geo-tagged photos
- (NSArray *)recentGeoTaggedPhotos;

// Returns a dictionary of user info for a given user ID. individual photos contain a user ID keyed as "owner"
- (NSString *)usernameForUserID:(NSString *)userID;

// Returns the photo for a given server, id and secret
- (NSData *)dataForPhotoID:(NSString *)photoID fromFarm:(NSString *)farm onServer:(NSString *)server withSecret:(NSString *)secret inFormat:(FlickrFetcherPhotoFormat)format;

// Returns a dictionary containing the latitue and longitude where the photo was taken (among other information)
- (NSDictionary *)locationForPhotoID:(NSString *)photoID;

@end

© Stack Overflow or respective owner

Related posts about cllocation

Related posts about mkmapview