Note that there are some explanatory texts on larger screens.

plurals
  1. POMKMapView not zooming to region
    primarykey
    data
    text
    <p>I have an MKMapView, and I'm trying to set the map, so that when you first load the application it goes to a user set location, and if the user hasn't set one, to a default one. The problem is that it always seems to go to 0 latitude, 0 longitude. </p> <pre><code>-(void) viewDidLoad { [worldView setShowsUserLocation:YES]; double longitude = [[NSUserDefaults standardUserDefaults] doubleForKey:WhereamiNewLongPrefKey]; double latitude = [[NSUserDefaults standardUserDefaults] doubleForKey:WhereamiNewLatPrefKey]; CLLocationCoordinate2D savedLoc = CLLocationCoordinate2DMake(latitude, longitude); MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(savedLoc, 250, 250); NSLog(@"latitude :%f", region.center.latitude); NSLog(@"longitude :%f", region.center.longitude); [worldView setRegion:region animated:YES]; } </code></pre> <p>I've tried setting <code>setShowUserLocation</code> to <code>NO</code>, but that doesn't work. I know it's reading the correct region, because the <code>NSLog</code> is outputing the default latitude, but the map insists on going to somewhere in China...</p> <p>I've also tried setting the region in <code>mapView:didUpdateUserLocation:</code>, but still the same result.</p> <p>What am I doing wrong?</p> <p>EDIT: I added the <code>NSLog</code> to output the longitude as well. The output is:</p> <pre><code>2012-11-14 09:50:30.699 Whereami[34256:13d03] latitude :20.516700 2012-11-14 09:50:30.699 Whereami[34256:13d03] longitude :99.900000 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload