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 8449881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:49:30+00:00 2026-06-10T10:49:30+00:00

I am trying to display multiple annotations on my mapView from an array. The

  • 0

I am trying to display multiple annotations on my mapView from an array. The annotation coordinates are parsed from an XML file and stored in the array as [currentCall longitude] and [currentCall latitude]. My question is, what is the syntax for “calling” the array? (I don’t know if that’s how you say it). In another part of my application, I display the parsed XML results in a table and use “JointCAD *currentCall = [[xmlParser calls] objectAtIndex:indexPath.row];” to “call” the array. How do I do it for displaying my annotations? Everything else works fine except that little part.

Here is the implementation file:

@implementation SecondViewController
@synthesize mapView;

XMLParser *xmlParser;

-(IBAction)getlocation {

mapView.showsUserLocation = YES;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView commitAnimations];

}

-(IBAction)changeSeg:(id)sender {

if (segment.selectedSegmentIndex == 0) {
    mapView.mapType = MKMapTypeStandard;
}
if (segment.selectedSegmentIndex == 1) {
    mapView.mapType = MKMapTypeSatellite;
}
if (segment.selectedSegmentIndex == 2) {
    mapView.mapType = MKMapTypeHybrid;
}
}

 -(void)viewDidLoad {

JointCAD *currentCall = [[xmlParser calls] objectAtIndex:indexPath.row];

mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
[self.view insertSubview:mapView atIndex:0];

[super viewDidLoad];
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
[mapView setDelegate:self];

MKCoordinateRegion WCCCA = { {0.0, 0.0} , {0.0, 0.0} };
WCCCA.center.latitude = 45.53540820864449;
WCCCA.center.longitude = -122.86178648471832;
WCCCA.span.longitudeDelta = 0.02f;
WCCCA.span.latitudeDelta = 0.02f;
[mapView setRegion:WCCCA animated:YES];

Annotation *ann1 = [[Annotation alloc] init];
ann1.title = @"WCCCA";
ann1.subtitle = @"Washington County Consolidated Communications Agency";
ann1.coordinate = WCCCA.center;
[mapView addAnnotation: ann1];

MKCoordinateRegion CALL = { {0.0, 0.0} , {0.0, 0.0} };
CALL.center.latitude = [currentCall.latitude doubleValue];
CALL.center.longitude = [currentCall.longitude doubleValue];
CALL.span.longitudeDelta = 0.02f;
CALL.span.latitudeDelta = 0.02f;
[mapView setRegion:WCCCA animated:YES];

Annotation *ann2 = [[Annotation alloc] init];
ann2.title = [currentCall currentCallType];
ann2.subtitle = [currentCall location];
ann2.coordinate = CALL.center;
[mapView addAnnotation: ann1];

}

-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
MKPinAnnotationView *MyPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"current"];
MyPin.pinColor = MKPinAnnotationColorRed;

UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[advertButton addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];

MyPin.rightCalloutAccessoryView = advertButton;
MyPin.draggable = NO;
MyPin.highlighted = YES;
MyPin.animatesDrop=TRUE;
MyPin.canShowCallout = YES;

return MyPin;
}

 @end
  • 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-06-10T10:49:31+00:00Added an answer on June 10, 2026 at 10:49 am

    If I am understanding your code properly, you should be able to just iterate through your parsed XML (it appears that the output the from your xmlParser object is an NSArray) and add the annotations to the mapView within the loop.

    You can use the C function CLLocationCoordinate2DMake() to create the coordinate data structure for your annotation.

    NSArray *callsArray = [xmlParser calls];
    
    for (JointCAD *call in callsArray) {
        Annotation *ann = [[Annotation alloc] init];
        ann.title = [call currentCallType];
        ann.subtitle = [call location];
        ann.coordinate = CLLocationCoordinate2DMake([call latitude], [call longitude]);
        [mapView addAnnotation:ann];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display the status of multiple claims from one day at
I'm trying to get a drop down list to display multiple columns from a
I am trying to send data from multiple checkboxes (id[]) and create an array
I'm trying to read a text file with multiple lines and then display it
I am trying to display multiple bing maps on the same page, with each
I am trying to display multiple Pushpin objects on an EntityLayer for Bing Maps.
I am trying to use getResources to display multiple resources withing one resource, including
I am trying to display data that I am getting from server through json.
I have being trying to display the filenames for the multiple files that have
I'm trying to display multiple, static jQuery Progress Bars on a single page, all

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.