Reputation: 51
I'm trying to figure out why the track bar button won't move the map back to user current location. It just changes to the waiting spin wheel (picture below) and the map doesn't move either. thanks.
Part of my code below. The co-ords there is for the city centre, but I've set my simulator's location to another place, so if I click on the track bar button I expect to move there.
- (void)viewDidLoad
{
[super viewDidLoad];
[self focusMap];
self.mapView.showsUserLocation = YES;
}
- (void) focusMap
{
CLLocationCoordinate2D coord = { -33.882365, 151.211025 };
MKCoordinateSpan span = {0.005,0.005};
MKCoordinateRegion region = {coord, span};
[mapView setRegion: region animated: YES];
MKUserTrackingBarButtonItem* trackerButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView: self.mapView];
self.navigationItem.rightBarButtonItem = trackerButton;
[trackerButton release];
mapView.zoomEnabled = YES;
}
Upvotes: 1
Views: 626
Reputation: 22246
You're in the simulator right? When you are using the simulator you need to simulate the GPS from Xcode by supplying a pre-defined GPX file or make one of your own. Look for a location arrow just above the debug window. Alternatively, within the Simulator you can choose Debug -> Location. To make a custom GPX file it has the following format:
<?xml version="1.0"?>
<gpx version="1.1" creator="Xcode">
<wpt lat="59.90855" lon="10.721554">
<name>Oslo, Norway</name>
</wpt>
</gpx>
Upvotes: 1