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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:55:37+00:00 2026-05-18T09:55:37+00:00

In map view, i’m showing current user location. On click on the pin its

  • 0

In map view, i’m showing current user location. On click on the pin its showing “Current Location”. I want to change it to “My Current Location”. How can I change it.
Also I want to change the current user location pin color in a timer. Some thing like every one second it should change its color between green, purple and red. Possible to do it?

I’m using map kit’s show default location and then manipulating the annotation pin color as below:

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation{
static NSString *AnnotationViewID = @"annotationViewID";
SolarAnnotationView* annotationView = (SolarAnnotationView*)[map dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
if(annotationView == nil)
{
    if([self CLLocationCoordinate2DEquals:mapView.userLocation.location.coordinate withSecondCoordinate:[annotation coordinate]]) //Show current location with green pin
    {
        annotationView = [[SolarAnnotationView alloc] initWithAnnotation:annotation];
        annotationView.delegate = self;
        [annotationView setPinColor:MKPinAnnotationColorGreen];
    }
    else
    {
        annotationView = [[SolarAnnotationView alloc] initWithAnnotation:annotation];
        annotationView.delegate = self;
    }
}   

return annotationView;

}

- (BOOL) CLLocationCoordinate2DEquals:(const CLLocationCoordinate2D)lhs withSecondCoordinate:(const CLLocationCoordinate2D) rhs{
const CLLocationDegrees DELTA = 0.001;
return fabs(lhs.latitude - rhs.latitude) <= DELTA && fabs(lhs.longitude - rhs.longitude) <= DELTA;

}

  • 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-18T09:55:37+00:00Added an answer on May 18, 2026 at 9:55 am

    If you let the map view show the default annotation view for the user location (blue dot), this is simpler to implement (and you get a nice blue dot with cool animated zooming circle).

    If you must show the user location using a pin image instead of a blue dot, then some more work is needed.

    First, the simple way using the blue dot:

    - (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation{
        if ([annotation isKindOfClass:[MKUserLocation class]])
        {
            ((MKUserLocation *)annotation).title = @"My Current Location";
            return nil;  //return nil to use default blue dot view
        }
    
        //Your existing code for viewForAnnotation here (with some corrections)...
        static NSString *AnnotationViewID = @"annotationViewID";
        SolarAnnotationView* annotationView = (SolarAnnotationView*)[map dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
        if(annotationView == nil)
        {
            {
                annotationView = [[[SolarAnnotationView alloc] initWithAnnotation:annotation] autorelease];
                //added autorelease above to avoid memory leak
                annotationView.delegate = self;
            }
        }
    
        //update annotation in view in case we are re-using a view
        annotationView.annotation = annotation;
    
        return annotationView;
    }
    

    If you want to use your custom annotation view for the user location instead, you should put the pin color changing code in the custom view. One way to periodically change the color is using performSelector:withObject:afterDelay:. In the SolarAnnotationView.m, add these two methods:

    -(void)startChangingPinColor
    {
        switch (self.pinColor) {
            case MKPinAnnotationColorRed:
                self.pinColor = MKPinAnnotationColorGreen;
                break;
            case MKPinAnnotationColorGreen:
                self.pinColor = MKPinAnnotationColorPurple;
                break;
            default:
                self.pinColor = MKPinAnnotationColorRed;
                break;
        }
        [self performSelector:@selector(startChangingPinColor) withObject:nil afterDelay:1.0];
    }
    
    -(void)stopChangingPinColor
    {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    

    Also add the method headers to the SolarAnnotationView.h file.

    Then change the viewForAnnotation method like this:

    - (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation{
        static NSString *AnnotationViewID = @"annotationViewID";
        SolarAnnotationView* annotationView = (SolarAnnotationView*)[map dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
        if(annotationView == nil)
        {
            {
                annotationView = [[[SolarAnnotationView alloc] initWithAnnotation:annotation] autorelease];
                annotationView.delegate = self;
            }
        }
    
        //Update annotation in view in case we are re-using a view...
        annotationView.annotation = annotation;
    
        //Stop pin color changing in case we are re-using a view that has it on
        //and this annotation is not user location...
        [annotationView stopChangingPinColor];
    
        if([self CLLocationCoordinate2DEquals:mapView.userLocation.location.coordinate withSecondCoordinate:[annotation coordinate]]) //Show current location with green pin
        {
            [annotationView setPinColor:MKPinAnnotationColorGreen];
            annotationView.canShowCallout = YES;
            ((MKPointAnnotation *)annotation).title = @"My Current Location";
            [annotationView startChangingPinColor];
        }
    
        return annotationView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In MKMapKit's map view control, i am showing the user's current location. A blue
I can display the map view for specific location. However, I dont know how
I create a Map view base application. I want to do. when I click
In my android app i ve map view and current location,nearest theaters displayed now
I want to show a simple text view on map view pushpin.on click of
When the user taps on the right callout accessory on my map view's pin's
I have a MKMapView and in the Map View Show User Location is set.
I want to draw a circle on map view. I want the user to
I want to to change the google map view from one state to another.
I have a map view with pins that when the user selects a pin

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.