Alex Rivera | Logout

HowTo initialise MKMapView with a given user location?

Asked 2009-09-17T08:50:24.643
19

My app knows the current user position (CoreLocation.framework). As soon as the user opens a new MapView his iPhone starts searching for the current position again. Is it possible to skip that or to change the first user position for mkMapView?

Edit:

Is it possible to overwrite MKMapView and use an other LocationManager?

Edit
Report

2 Answers

27

In your controller:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    CLLocationCoordinate2D coord = {latitude: 37.423617, longitude: -122.220154};
    MKCoordinateSpan span = {latitudeDelta: 1, longitudeDelta: 1};
    MKCoordinateRegion region = {coord, span};
    [mapView setRegion:region];
}

When map appears it's going to be centered close to Palo Alto

answered 2009-09-24T07:49:40.463
0

You don't need to use another Location Manager, you can add whatever points you want to the map and update them via whatever other logic you want.

Let's say you had a socket connection to a remote control car, and that car send back socket data containing geo-location information in the payload. You could parse that out, and update the location of the thumbnail on your map in real time. The "userLocation" property is not needed for that, but you could show it if you wanted to.

The location of the user is read-only, you can use it or not. That doesn't mean you need another location manager to do anything you might need to do. It sounds like your app doesn't really need that feature, but I could be misunderstanding your question.

answered 2009-09-28T18:04:48.990

Your Answer