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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:36:16+00:00 2026-05-18T00:36:16+00:00

I am a newbie in MapKit for iPhone and tried to implement this, for

  • 0

I am a newbie in MapKit for iPhone and tried to implement this, for some reason I can’t see the current location blue dot, anyone else had this issue????

#import "DetailMapViewController.h"
#import "mapAnnotations.h"

@implementation DetailMapViewController

@synthesize inStock;

-(void)getlocation:(CLLocationCoordinate2D)loc
{
    location = loc;
}

- (void)viewDidLoad 
{
    [super viewDidLoad];
    self.navigationItem.title = @"Street View";
    mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
    mapView.delegate=self;      
    //MKCoordinateRegion region;
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(location, 5000, 5000);

    mapAnnotations *ann = [[mapAnnotations alloc] init];
    ann.title = @"";
    ann.subtitle = @"";
    ann.coordinate = region.center;

    mapView.showsUserLocation = YES;
    [mapView addAnnotation:ann];
    [mapView setRegion:region animated:TRUE];
    [mapView regionThatFits:region];
    [self.view insertSubview:mapView atIndex:0];
}


- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];

    if (annotation == mapView.userLocation)
    {

        annView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"blueDot"];
        if (annView != nil)
        {
            annView.annotation = annotation;
        }
        else
        {
            annView = [[[NSClassFromString(@"MKUserLocationView") alloc] initWithAnnotation:annotation reuseIdentifier:@"blueDot"] autorelease];


        }
    }

    if([inStock isEqual:@"yes"]){
        annView.pinColor = MKPinAnnotationColorGreen;
    } 
    if([inStock isEqual:@"no"]){
        annView.pinColor = MKPinAnnotationColorRed;
    }
    if([inStock isEqual:@"unknown"]){

        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"greyPin.png"]];
        [annView addSubview:imageView];




    }
    annView.animatesDrop=TRUE;
    annView.canShowCallout = YES;
    annView.calloutOffset = CGPointMake(-5, 5);
    return annView;
}

- (void)dealloc {
    [super dealloc];
}


@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-05-18T00:36:16+00:00Added an answer on May 18, 2026 at 12:36 am

    The way the viewForAnnotation is currently written, it should actually crash when trying to show the current location because the “blue dot” annotation view doesn’t have the pinColor or animatesDrop properties.

    Try changing it to the following:

    - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
    {
        if ([annotation isKindOfClass:MKUserLocation.class]) {
            //user location view is being requested,
            //return nil so it uses the default which is a blue dot...
            return nil;
        }
    
        MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
    
        if([inStock isEqual:@"yes"]){
            annView.pinColor = MKPinAnnotationColorGreen;
        } 
        if([inStock isEqual:@"no"]){
            annView.pinColor = MKPinAnnotationColorRed;
        }
        if([inStock isEqual:@"unknown"]){
            UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"greyPin.png"]];
            [annView addSubview:imageView];
        }
        annView.animatesDrop=TRUE;
        annView.canShowCallout = YES;
        annView.calloutOffset = CGPointMake(-5, 5);
        return annView;
    }
    

    On the simulator, the user’s location will be Cupertino, CA, USA (a little south of San Francisco). If your own annotation is not within 5000 meters of that, you won’t see the blue dot. You’ll have to zoom out to see it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie with databases, I would like some advise please.. I have agencies who can
newbie here. This is an iPhone utility project. First things first. I have a
Newbie here...can I write one program which incorporates .NET LINQ and also various Java
Total newbie question but this is driving me mad! I'm trying this: myInt =
Sorry for the second newbie question, I'm a developer not a sysadmin so this
Newbie question. Looking at arrays (ie: dynamically sized) this works: NSArray *array; array =
Newbie question: Python 2.6, Ubuntu 10.04, I can import both pycurl and curl ,
Newbie Scala Question: Say I want to do this [Java code] in Scala: public
newbie to iPhone game development and Box2D here. I'm developing a game in which
php newbie here..I need some PHP help ideas/examples on how to import data from

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.