Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-31-2010, 06:04 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 5
Ennio is on a distinguished road
Smile MapKit API

Hello all,

I'm new here to this forum, and I have a question about getting the user location.

Current I have an App that will start and get the user location, but the problem that I have is that if I move the map around it the map always moves back to the current location, so I can never see around my location.

Here is the code I have on my app so far.

Code:
@synthesize locationManager, location;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
	mapView.showsUserLocation = YES;
	mapView.delegate = self;
	mapView.scrollEnabled = YES;
	mapView.zoomEnabled = YES;
	mapView.userInteractionEnabled = YES;
	[self.view insertSubview:mapView atIndex:0];

	
	self.locationManager = [[CLLocationManager alloc] init];
	locationManager.delegate = self;
	locationManager.desiredAccuracy = kCLLocationAccuracyBest;
	
	[locationManager startUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
	location=newLocation.coordinate;
	//One location is obtained.. just zoom to that location
	
	MKCoordinateRegion region;
	region.center=location;
	//Set Zoom level using Span
	MKCoordinateSpan span;
	span.latitudeDelta=.005;
	span.longitudeDelta=.005;
	region.span=span;

	[mapView setRegion:region animated:TRUE];	
}
Ennio is offline   Reply With Quote
Old 08-31-2010, 06:21 PM   #2 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 5
Ennio is on a distinguished road
Default

I found the solution...

Code:
locationManager.distanceFilter = 10;
Ennio is offline   Reply With Quote
Old 08-31-2010, 06:27 PM   #3 (permalink)
Use [code] tags please
 
Join Date: Jun 2009
Location: Jacksonville, FL
Posts: 410
timle8n1 is on a distinguished road
Default

Quote:
Originally Posted by Ennio View Post
I found the solution...

Code:
locationManager.distanceFilter = 10;
That is not the solution.

If you do not want your map to go back to the user location - why does your didUpdateToLocation method do exactly that????

didUpdateToLocation is called when CLLocationManager sends your delegate a new user location. If you just want a map that shows the user location you don't need that method or a CLLocationManager and delegate at all.
timle8n1 is offline   Reply With Quote
Old 09-02-2010, 08:05 AM   #4 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 5
Ennio is on a distinguished road
Default

Quote:
Originally Posted by timle8n1 View Post
That is not the solution.

If you do not want your map to go back to the user location - why does your didUpdateToLocation method do exactly that????

didUpdateToLocation is called when CLLocationManager sends your delegate a new user location. If you just want a map that shows the user location you don't need that method or a CLLocationManager and delegate at all.
I do want the map to go back... but not every centimeter... so that is why I used the distanceFilter.
Ennio is offline   Reply With Quote
Reply

Bookmarks

Tags
gps, ios, location, mapkit

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 356
7 members and 349 guests
dre, freewind, hain, HemiMG, lendo, Newbie123, oceanlablight
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:01 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0