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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:03:55+00:00 2026-05-29T19:03:55+00:00

While my end project is not another where did I park app. I thought

  • 0

While my end project is not another where did I park app. I thought this would be a good place to start to get a good grasp of MKMap and Locations.

Ok so I can set pins, see myself, and get my current location to show up in a label.

What I can’t do is:

A. On a button push
1) Store the users current location.
2) Drop a pin(red) in the current users location.
(So the new pin stays even if the user(blue) moves)

B. On a separate button push
1) Clear the pin of the users dropped pin(red) off the map.

I cannot seem to set the map annotation for the new pin in the button. The numbers change and the map does not refresh(i’m guessing) to show my pin with or with out the right set of coords in it.

This what I have so far. (NO SNICKERING) 😛

#import "Find_My_CarViewController.h"
#import "MapAnnotation.h"

@implementation Find_My_CarViewController

@synthesize CLController;
@synthesize hereIamLat;
@synthesize hereIamLong;
@synthesize mapView;

- (void)dealloc
{
    [hereIamLat release];
    [hereIamLong release];
    [CLController release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    CLController = [[CoreLocationController alloc] init];
    CLController.delegate = self;
    [CLController.locMgr startUpdatingLocation];  
}

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(void)viewWillAppear:(BOOL)animated
{
    MKCoordinateRegion region;
    region.center.latitude =40.798356;
    region.center.longitude= -81.411158;
    region.span.longitudeDelta=0.3;
    region.span.latitudeDelta =0.3;
    [mapView setRegion:region animated:YES];   
}

- (void)locationUpdate:(CLLocation *)location
{
    latitudeLabel.text = [NSString stringWithFormat:@"LATITUDE: %f", location.coordinate.latitude];
    longitudeLabel.text = [NSString stringWithFormat:@"LONGITUDE: %f", location.coordinate.longitude];

    //hereIamLat = [NSString stringWithFormat:@"%g", location.coordinate.latitude];
    //hereIamLong = [NSString stringWithFormat:@"%g", location.coordinate.longitude];   
}

- (void)locationError:(NSError *)error
{
//speedLabel.text = [error description];
}

-(IBAction)PushToMark
{
    NSScanner *strLat = [NSScanner scannerWithString:latitudeLabel.text];
    double dblLat;
    [strLat scanDouble:&dblLat];
    NSScanner *strLong = [NSScanner scannerWithString:longitudeLabel.text];
    double dblLong;
    [strLong scanDouble:&dblLong];

    NSLog(@"lat: %f",dblLat);
    NSLog(@"long: %f",dblLong);
    MKCoordinateRegion location1;
    location1.center.latitude =dblLat;
    location1.center.longitude= dblLong;
    location1.span.longitudeDelta=0.1;
    location1.span.latitudeDelta =0.1;

    MapAnnotation *ann1 =[[[MapAnnotation alloc] init] autorelease];
    ann1.title=@"Here";
    ann1.subtitle=@"I AM";
    ann1.coordinate= location1.center;
    [mapView addAnnotation:ann1];
}

@end

Edit:
Ok so I went this route thanks.

#import "LocationTestViewController.h"
#import "CoreLocation/CoreLocation.h"
#import "MapAnnotation.h"

@implementation LocationTestViewController
@synthesize locationManager;
@synthesize mapView;

- (void)dealloc
{
[mapView release];
[locationManager release];
[super dealloc];
} 

- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
 [super viewDidLoad];
}
*/

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)getLocation:(id)sender {


locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter=kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];

[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
MKCoordinateRegion region = {{0.0,0.0},{0.0,0.0}};
region.center.latitude = locationManager.location.coordinate.latitude;
region.center.longitude = locationManager.location.coordinate.longitude;
region.span.longitudeDelta = 0.005f;
region.span.latitudeDelta = 0.005f;
[mapView setRegion:region animated:YES];
[mapView setDelegate:sender];

MKCoordinateRegion location1;
location1.center.latitude =locationManager.location.coordinate.latitude;
location1.center.longitude= locationManager.location.coordinate.longitude;
location1.span.longitudeDelta=0.1;
location1.span.latitudeDelta =0.1;

MapAnnotation *ann1 =[[[MapAnnotation alloc] init] autorelease];
ann1.title=@"You Parked Here";
ann1.subtitle=@"";
ann1.coordinate= location1.center;
[mapView addAnnotation:ann1];

}
@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-29T19:03:56+00:00Added an answer on May 29, 2026 at 7:03 pm

    Why not use a CLLocationCoordinate2D to store your current location when you get the delegate callback - (void)locationUpdate:(CLLocation *)location ? There’s no real reason to use an MKCoordinateRegion and NSScanner.

    Do this instead:

    - (void)locationUpdate:(CLLocation *)location
    {
        latitudeLabel.text = [NSString stringWithFormat:@"LATITUDE: %f", location.coordinate.latitude];
        longitudeLabel.text = [NSString stringWithFormat:@"LONGITUDE: %f", location.coordinate.longitude];
    
        self.myLocation = location; // a property that stores the current location
    }
    

    Then in your - (IBAction)pushToMark you can create and add the annotation using self.myLocation as the coordinate property.

    As for removing the annotation – see Mundi’s answer for that.

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

Sidebar

Related Questions

It's been a while since I've programmed a GUI program, so this may end
when including libraries c, the line does not end with a semicolon, while other
Our application uses a SQL Server back-end with many stored procedures. Recently, while trying
While working in a Java app, I recently needed to assemble a comma-delimited list
This has bothered me for quite a while, but now it is necessity that
I have a Partner model that has_and_belongs_to_many Projects, while each Project has_many Sites. I
I take care of critical app in my project. It does stuff related to
I realize this is not necessarily the smartest way to do this, but now
I get an error while saving a string. the error is: prject prKlanten.exe raised
First of all, apologies for not being able to supply any sourcecode. My project

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.