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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:41:02+00:00 2026-06-03T04:41:02+00:00

I am trying to plot a point in the mapview. I have created two

  • 0

I am trying to plot a point in the mapview.
I have created two files
1. A file which extends nsobject, and,
2. A file which extends views.
Here is source code for both the files:

#import "gpMapViewAnnotations.h"

@implementation gpMapViewAnnotations
@synthesize title, coordinate;

- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d {

    title = ttl;
    coordinate = c2d;
    return self;
}

this is the code for interface file.

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

@interface gpMapViewAnnotations : NSObject <MKAnnotation>{

    NSString *title;
    CLLocationCoordinate2D coordinate;
}
@property (nonatomic, copy) NSString *title;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d;


@end

@end

Now this is the source code for view files:

#import <UIKit/UIKit.h>
#import <MapKit/Mapkit.h>
#import "ASIHTTPRequestDelegate.h"
#import "AppDelegate.h"
#import "gpMapViewAnnotations.h"

@interface gpViewController : UIViewController
< ASIHTTPRequestDelegate, MKMapViewDelegate>
{
     MKMapView *gpMapView;


    gpMapViewAnnotations *gpAnnotations;

}
@property (strong, nonatomic) IBOutlet MKMapView *gpMapView;

@end

And here is the implementation file:

#import "gpViewController.h"
#import "ASIHTTPRequest.h"
#import "Parser.h"
#import "AppDelegate.h"
#import "TFHpple.h"
#import "TouchXML.h"
#import "gpMapViewAnnotations.h"


@interface gpViewController ()

@end

@implementation gpViewController
@synthesize gpMapView;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {

    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    // Set some coordinates for our position (Buckingham Palace!)
    CLLocationCoordinate2D location;
    location.latitude = (double) 51.501468;
    location.longitude = (double) -0.141596;

    // Add the annotation to our map view
    gpMapViewAnnotations *newAnnotation = [[gpMapViewAnnotations alloc] initWithTitle:@"Buckingham Palace" andCoordinate:location];
    [gpMapView addAnnotation:newAnnotation];

    NSURL *url = [NSURL URLWithString:@"http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/location.xml?apikey=YAHUGHET&range=50&northing=174900&easting=517900&name=richmond"];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

    [request setDelegate:self];

    [request startAsynchronous];
    [gpMapView setDelegate:self];

}

- (void)viewDidUnload
{
    [self setGpMapView:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
     NSLog(@"view did load");
    NSLog(@"request finished");
    // Use when fetching text data
    NSString *responseString = [request responseString];
//   NSLog(@"%@",responseString);
    // Use when fetching binary data

    NSData *responseData = [request responseData];

    //  we will put parsed data in an a array
    NSMutableArray *res = [[NSMutableArray alloc] init];
    //  using local resource file
   // NSString *XMLPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"test.xml"];
  //  NSData *XMLData   = [NSData dataWithContentsOfFile:responseString];
    CXMLDocument *doc = [[CXMLDocument alloc] initWithData:responseData options:0 error:nil];

    NSArray *nodes = NULL;
    //  searching for piglet nodes
    nodes = [doc nodesForXPath:@"//*" error:nil];
    NSLog(@"coming here 1");
    for (CXMLElement *node in nodes) {
        //NSLog(@"coming here 2");

      //  NSMutableArray *item = [[NSMutableArray alloc]init];
        //create list object to store the title and latitude and longitude.
        List *gpList = [[List alloc]init];

        if([[node localName] isEqualToString:@"entry"]){
            NSArray *entryTagNodes = [node children];

            //iterate on entry nodes
            for(CXMLElement *entryTagNode in entryTagNodes){
                //check if the tagname is content
                if([[entryTagNode localName] isEqualToString:@"content"]){
                        //iterat on content tag childs
                    NSArray *contentTagNodes = [entryTagNode children];
                    // NSLog(@"tag: %d",[contentTagNodes count]);
                    for(CXMLElement *innerContentNode in contentTagNodes){

                        NSArray *organisationTagNodes = [innerContentNode children];
                        for(CXMLElement *orgTagNode in organisationTagNodes){
                           // NSLog(@"%@",[orgTagNode localName]);

                                //check for tag name is equal to name
                            if([[orgTagNode localName] isEqualToString:@"name"]){
                                gpList.title = [orgTagNode stringValue];

                            }else if([[orgTagNode localName] isEqualToString:@"geographicCoordinates"]){
                                NSArray *geoCordTags = [orgTagNode children];

                                for(CXMLElement *geoCordTag in geoCordTags){
                                    if([[geoCordTag localName] isEqualToString:@"latitude"]){
                                        gpList.latitude = [geoCordTag stringValue];

                                    }else if([[geoCordTag localName] isEqualToString:@"longitude"]){
                                        gpList.longitude = [geoCordTag stringValue];
                                    }

                                }
                               NSLog(@"latitude nad longitude %@ %@",gpList.latitude,gpList.longitude);

                            }
                        }
                    }


                }

            }
            [res addObject:gpList];

        }

        //  and here it is - attributeForName! Simple as that.
      //  [item setObject:[[node valueForKey:@"id"] stringValue] forKey:@"id"];  // <------ this magical arrow is pointing to the area of interest



    }

    //  and we print our results
  //  NSLog(@"%@", res);
    NSEnumerator *enumerator = [res objectEnumerator];
    id obj;
    while(obj = [enumerator nextObject]){

            NSLog(@"title %@",[obj title]);

    }

    /*
    TFHpple *doc = [TFHpple hppleWithData:responseData isXML:YES];
    NSArray *elements = [doc searchWithXPathQuery:@"/"];

    NSLog(@"%d",[elements objectAtIndex:0]);
   */
    /*
    NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:responseData];
    Parser *parser = [[Parser alloc] initParser];

    [xmlParser setDelegate:parser];
    BOOL worked = [xmlParser parse];
    if(worked){
        NSLog(@"parsing is happening ");

    }else{
        NSLog(@"parsing is not happening %@",[app.listArray count]);
    }*/


}

-(void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views{
    MKAnnotationView *annotationView = [views objectAtIndex:0];
    id <MKAnnotation> mp = [annotationView annotation];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 1500, 1500);
    [mv setRegion:region animated:YES];
    [mv selectAnnotation:mp animated:YES];
}

- (void)requestFailed:(ASIHTTPRequest *)request
{
    NSError *error = [request error];
    NSLog(@"%@",error);
}

@end

I dont have a clue as where i am doing wrong in plotting a simple point. i still need to put multiple points using the array which i have created reading the xml file. but even a simple point is not getting plotted now.
Is there anything which I am doing wrong over here please?

  • 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-03T04:41:04+00:00Added an answer on June 3, 2026 at 4:41 am

    I can’t see your mapView:viewForAnnotation: delegate method. That’s where you can add the view to go along with annotations. Something like this:

    - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
    {
        if( annotation == mapView.userLocation ) return nil;
    
        MKPinAnnotationView *annotationView;
        annotationView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"AnnotationIdentifier"];
        if( annotationView == nil ){
            annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"AnnotationIdentifier"];
        }
    
        return annotationView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one y variable, which I am trying to plot against two related
I am trying to give float point into core-plot y axis value, it is
I'm trying to plot lines between two or more addresses in Google Maps. The
Here is my code: I am trying to get the CSV files from a
I'm using GD to plot some simple charts from array point data.. Trying to
I have a bunch of points that I am trying to plot using matplotlib.
I am trying to plot arrowheads on the lines between two geospatial points (latitude,
I am trying plot data sets consisting of 3 coordinates: X-coordinate, x-coordinate and the
Im trying to plot the roots of a polynomial, and i just cant get
I am trying to plot a series of 2D matrices containing ones and zeros

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.