Note that there are some explanatory texts on larger screens.

plurals
  1. POException : 'Invalid Region <center:+inf, +0.00000000 span:+1.00000000, +0.50000000>' when trying to display the map
    text
    copied!<p>when i try to display the map i got this exception :</p> <pre><code>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Region &lt;center:+inf, +0.00000000 span:+1.00000000, +0.50000000&gt;' </code></pre> <p>my relevant code is this :</p> <pre><code>-(void)viewWillAppear:(BOOL)animated { [mapView removeAnnotations:mapView.annotations]; // locationManager update as location locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = kCLDistanceFilterNone; [locationManager startUpdatingLocation]; CLLocation *location = [locationManager location]; //Configure the new event with information from the location CLLocationCoordinate2D coordinate = [location coordinate]; latitudeOfUserLocation=coordinate.latitude; longitudeOfUserLocation=coordinate.longitude; location2D = (CLLocationCoordinate2D){ .latitude = latitudeOfUserLocation, .longitude = longitudeOfUserLocation }; MyLocation *annotation=[[[MyLocation alloc]initWithName:@"You are here" distanceVersLaStation:@"" coordinate:location2D]autorelease]; annotation.pinColor = MKPinAnnotationColorRed; [mapView addAnnotation:annotation]; MKCoordinateSpan span={latitudeDelta:1,longitudeDelta:0.5}; MKCoordinateRegion region={location2D,span}; [mapView setRegion:region]; } </code></pre> <p>i can't figure out how to solve this issue, thx in advance :)</p> <p><strong>EDIT :</strong></p> <p>Hi again, i try to do as you said, the exception is solved, however, when i try to display the longitude/latitude of the user in the console i got nothing, this is my code which is pretty correct :</p> <pre><code> -(void)viewWillAppear:(BOOL)animated { [mapView removeAnnotations:mapView.annotations]; // locationManager update as location locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = kCLDistanceFilterNone; [locationManager startUpdatingLocation]; NSURL *url=[NSURL URLWithString:@"http://ipho.franceteam.org/ad_V1/stations/"]; ASIFormDataRequest * request=[ASIFormDataRequest requestWithURL:url]; [request setPostValue:[NSNumber numberWithFloat:longitudeOfUserLocation] forKey:@"longitude"]; [request setDelegate:self]; [request startAsynchronous]; MBProgressHUD *hud=[MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.labelText=@"Recherche en cours..";// this never stop loading } -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLLocation *location = [locationManager location]; //Configure the new event with information from the location CLLocationCoordinate2D coordinate = [location coordinate]; latitudeOfUserLocation=coordinate.latitude; longitudeOfUserLocation=coordinate.longitude; NSLog(@"your latitude :%f",latitudeOfUserLocation);//here nothing is shown NSLog(@"your longitude :%f",longitudeOfUserLocation);// and here too location2D = (CLLocationCoordinate2D){ .latitude = latitudeOfUserLocation, .longitude = longitudeOfUserLocation }; MyLocation *annotation=[[[MyLocation alloc]initWithName:@"Vous êtes ici" distanceVersLaStation:@"" coordinate:location2D]autorelease]; annotation.pinColor = MKPinAnnotationColorRed; //or red or whatever [mapView addAnnotation:annotation]; // MKCoordinateSpan span={latitudeDelta:1,longitudeDelta:0.5}; MKCoordinateRegion region={location2D,span}; [mapView setRegion:region]; }//End function </code></pre> <p>even i work on the simulator, i should get something on the console right ?</p> <p><strong>EDIT :</strong> Hi again, i had the opportunity to test my code on iPhone (device) and i have noticed that when i try to search, the application has suucceded to track my position and to find me the stations that meet my search (purple annotation), however, the map isn't displayed and the searching progress is still loading and never stop.</p> <pre><code>hud.labelText=@"Recherche en cours..";// this never stop loading </code></pre> <p>here is a screenshot that could explain better :</p> <p><img src="https://i.stack.imgur.com/ZlFPI.png" alt="enter image description here"></p>
 

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