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

  • Home
  • SEARCH
  • 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 4025942
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:54:33+00:00 2026-05-20T10:54:33+00:00

Trying to add a custom pin for current location, However the location does not

  • 0

Trying to add a custom pin for current location, However the location does not update. Even after setting setShowsUserLocation = YES;

- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
    if ([[annotation title] isEqualToString:@"Current Location"]) {
        self.image = [UIImage imageNamed:[NSString stringWithFormat:@"cursor_%i.png", [[Session instance].current_option cursorValue]+1]];
    }

However, if I set to return nil; everything works fine, but I lose the custom image. I really want to get this to work. Any help would be greatly appreciated.

  • 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-20T10:54:33+00:00Added an answer on May 20, 2026 at 10:54 am

    As you’ve seen the setShowsUserLocation flag only shows the current location using the default blue bubble.

    What you need to do here listen for location updates from the phone and manually reposition your annotation yourself. You can do this by creating a CLLocationManager instance and remove and replace your annotation whenever the Location Manager notifies its delegate of an update:

    - (void)locationManager:(CLLocationManager *)manager
        didUpdateToLocation:(CLLocation *)newLocation
               fromLocation:(CLLocation *)oldLocation
    {
      // update annotation position here
    }
    

    To reposition the coordinates, I have a class, Placemark, that conforms to the protocol MKAnnotation:

    //--- .h ---
    
    #import <Foundation/Foundation.h>
    #import <MapKit/MapKit.h>
    
    @interface Placemark : NSObject <MKAnnotation> {
    }
    
    @property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
    @property (nonatomic, retain) NSString *strSubtitle;
    @property (nonatomic, retain) NSString *strTitle;
    
    -(id)initWithCoordinate:(CLLocationCoordinate2D) coordinate;
    - (NSString *)subtitle;
    - (NSString *)title;
    
    @end
    
    //--- .m ---
    
    @implementation Placemark
    
    @synthesize coordinate;
    @synthesize strSubtitle;
    @synthesize strTitle;
    
    - (NSString *)subtitle{
        return self.strSubtitle;
    }
    - (NSString *)title{
        return self.strTitle;
    }
    
    -(id)initWithCoordinate:(CLLocationCoordinate2D) c {
        self.coordinate = c;
        [super init];
        return self;
    }
    
    @end
    

    Then in my mapview controller I place the annotation with:

    - (void) setPlacemarkWithTitle:(NSString *) title andSubtitle:(NSString *) subtitle forLocation: (CLLocationCoordinate2D) location {
    
        //remove pins already there...
        NSArray *pins = [mapView annotations];
    
        for (int i = 0; i<[pins count]; i++) {
          [mapView removeAnnotation:[pins objectAtIndex:i]];
        }
    
        Placemark *placemark=[[Placemark alloc] initWithCoordinate:location];
        placemark.strTitle = title;
        placemark.strSubtitle = subtitle;
        [mapView addAnnotation:placemark];  
        [self setSpan]; //a custom method that ensures the map is centered on the annotation 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add some custom build steps to my headless build process
I'm trying to add a custom font as a resource in my application. I
I'm trying to add a custom property which is a guid, but it gives
I am trying to figure out how to add a custom control to the
I'm trying add a tab to my web page that looks like this: Using
Trying to add an onclick handler to my tabs, and can't seem to get
trying to add an ExpiresDefault ExpiresByType to content on my website so that way
I was trying to add a favicon to a website earlier and looked for
I'm trying to add support for stackoverflow feeds in my rss reader but SelectNodes
I am trying to add a project reference or swc to papervision in FlashDevelop

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.