Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7406241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:31:37+00:00 2026-05-29T05:31:37+00:00

This is the first time I am using a plist. I have been browsing

  • 0

This is the first time I am using a plist. I have been browsing around and I can’t find any other help.

I have the code below in my viewDidLoad. How come my annotations are not showing?

    mapView.showsUserLocation = YES;
mapView.delegate=self;


NSMutableArray *annotations = [[NSMutableArray alloc]init];
NSString *path = [[NSBundle mainBundle] pathForResource:@"StationAddress" ofType:@"plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
NSArray *anns = [dict objectForKey:@"GasStation"];
NSLog(@" MapView is %@",mapView);
NSLog(@"anns is: %@", anns);


for(int i = 0; i < [anns count]; i++) {
    NSLog(@"read2");

    double realLatitude = [[[anns objectAtIndex:i] objectForKey:@"Latitude"] doubleValue];
    NSLog(@" double lat value is %f",realLatitude);
    double realLongitude = [[[anns objectAtIndex:i] objectForKey:@"Longitude"] doubleValue];
    NSLog(@" double lot value is %f",realLatitude);

    NSLog(@"read3");



    MyAnnotation *myAnnotation = [[MyAnnotation alloc] init];
    CLLocationCoordinate2D theCoordinate;
    theCoordinate.latitude = realLatitude;
    theCoordinate.longitude = realLongitude;
    myAnnotation.coordinate=CLLocationCoordinate2DMake(realLatitude,realLongitude);

    myAnnotation.title = [[anns objectAtIndex:i] objectForKey:@"Name"];
    myAnnotation.subtitle = [[anns objectAtIndex:i] objectForKey:@"Address"];


    [mapView addAnnotation:myAnnotation];
    [annotations addObject:myAnnotation];
    [myAnnotation release];

EDIT MyAnnotation.h

@interface MyAnnotation : NSObject<MKAnnotation> {

CLLocationCoordinate2D  coordinate;
NSString*               title;
NSString*               subtitle;

}

@property (nonatomic, assign)   CLLocationCoordinate2D  coordinate;
@property (nonatomic, copy)     NSString*               title;
@property (nonatomic, copy)     NSString*               subtitle;

MyAnnotation.m

@implementation MyAnnotation

@synthesize title;
@synthesize subtitle;
@synthesize coordinate;

Hard Code for annotations, (this is inside viewdidload)

[mapView setShowsUserLocation:YES];

CLLocation *userLoc = mapView.userLocation.location;
CLLocationCoordinate2D userCoordinate = userLoc.coordinate;


NSLog(@"user latitude = %f",userCoordinate.latitude);
NSLog(@"user longitude = %f",userCoordinate.longitude);

mapView.delegate=self;

NSMutableArray* annotations=[[NSMutableArray alloc] init];

MKPointAnnotation *annot1 = [[MKPointAnnotation alloc] init]; 
annot1.title = @"TItle1"; 
annot1.subtitle=@"Address of title"; 
annot1.coordinate = CLLocationCoordinate2DMake(21.946114, 120.792778); 
[mapView addAnnotation:annot1]; 

and I did this for 3000 of them, but they ran slow, so I am trying to find a better way

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:31:37+00:00Added an answer on May 29, 2026 at 5:31 am

    Try this.

    Change:

         float realLatitude = [[[anns objectAtIndex:i] objectForKey:@"Latitude"] floatValue];
    

    To this:

         double realLatitude = [[[anns objectAtIndex:i] objectForKey:@"Latitude"] doubleValue];
         NSLog(@" double lat value is %f",realLatitude);
    

    (do longitude also).

    Also hint: check for your annotations in the southern Atlantic Ocean, south west of Equatorial Guinea – that’s where Lat/Lon of {0,0} is, and if your data isn’t converting correctly, that’s where your annotations might be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this XML classes for the first time and can't find this piece
This is my first time using JQuery in any of my projects. I have
This is my first time using Ruby, I hope you can help me to
This is my first time using stackoverflow. I've been unable to find out the
This is my first time using a JFrame. I can't get the window to
This is my first time using this site so sorry for any bad formatting
This is my first time using stackoverflow for a question, I have read a
this is my first time using any StackExchange website, so let's see how it
This is my first time using java to access databases, so I probably have
This is my first time using any sort of version control (git) and excited

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.