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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:31:05+00:00 2026-05-16T12:31:05+00:00

I am working with Mapkit and I have to show annotations in the map

  • 0

I am working with Mapkit and I have to show annotations in the map but I’m not able to display the annotation. Here’s my code:

@interface MyMapView : UIViewController <MKAnnotation,MKMapViewDelegate>{

MKMapView *Obj_Map_View;
MKPlacemark *pmark;
MKReverseGeocoder *geocoder1;
}

@end


#import "MyMapView.h"
@implementation MyMapView

- (id)init {
    if (self = [super init]) {

    }
    return self;
}

- (void)loadView {  
    [super loadView];   
    Obj_Map_View = [[MKMapView alloc]initWithFrame:self.view.bounds];
    Obj_Map_View.showsUserLocation =YES;
    Obj_Map_View.mapType=MKMapTypeStandard;
    [self.view addSubview:Obj_Map_View];
    Obj_Map_View.delegate = self;

    CLLocationCoordinate2D cord =  {latitude: 19.120000, longitude: 73.020000};
    MKCoordinateSpan span = {latitudeDelta:0.3, longitudeDelta:0.3};
    MKCoordinateRegion reg= {cord,span};
    [Obj_Map_View setRegion:reg animated:YES];
    //[Obj_Map_View release];
}

- (NSString *)subtitle{
    return @"Sub Title";
}

- (NSString *)title{
    return @"Title";
}

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
    MKPinAnnotationView *annov = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"Current location"];
    annov.animatesDrop = TRUE;
    [annotation title]==@"Current location";
    annov.canShowCallout = YES;
    [annov setPinColor:MKPinAnnotationColorGreen];
    return annov;
}

The above code works fine and displays a map but not with annotation.

  • 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-16T12:31:05+00:00Added an answer on May 16, 2026 at 12:31 pm

    Typically, the class that conforms to the MKAnnotation protocol isn’t the view controller, it’s a data class.

    You’ll need to create another class, which I’ll call “MyLandmarks” for the example.

    @interface MyLandmarks : NSObject <MKAnnotation>
       // Normally, there'd be some variables that contain the name and location.
       // And maybe some means to populate them from a URL or a database.
       // This example hard codes everything.
    
    @end
    
    
    @implementation MyLandmarks
    -(NSString*)title {
        return @"'ere I am, J.H.";
    }   
    
    -(NSString*)subtitle {
        return @"The ghost in the machine.";
    }
    
    -(CLLocationCoordinate2D) coordinate {
        CLLocationCoordinate2D coord = {latitude: 19.120000, longitude: 73.020000}; 
    
        return coord; 
    }
    @end
    

    Then, somewhere appropriate in your MyMapView class add:

    MyLandmark *landmark = [[[MyLandmark alloc]init]autorelease];
    [Obj_Map_View addAnnotation:landmark];
    

    A couple other bits that other Objective-C developers working with you will appreciate:

    • To avoid confusion, don’t call the class MyMapView if it descends from a UIViewController. Call it MyMapViewController, instead.
    • Classes start with a capital letter, variables start lowercase. Both are CamelCased. Obj_Map_View should be objMapView.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a Mapkit App and I want to show annotations according
I have an app that deals with mapkit and annotation and it's working fine,
I am working on a sample map kit app for iOS. I have everything
I am working with MapKit and want to be able to add a (NSString
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
I am working with MapKit and annotations in iOS. Right before the annotations are
I'm using the MapKit framework and I have used pins to display the exact
i'm NEW TO XCODE, working with mapkit and annotations, howver after building and running
I'm a beginner but have been working really hard to build this application. Working
I'm working on a mapkit view, i added a button on an annotation like

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.