Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6902727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:50:03+00:00 2026-05-27T07:50:03+00:00

I’m getting an error in MapView that I don’t recognize and can’t find documentation

  • 0

I’m getting an error in MapView that I don’t recognize and can’t find documentation on. It looks like this:

CoreAnimation: ignoring exception: 
Invalid Region <center:-180.00000000, -180.00000000 
                  span:+2.81462803, +28.12500000>

Obviously the numbers are exclusive to my code right now but I can’t figure out what’s going on. The MapView runs just fine and all of my annotations show up (and it zooms on the user’s location like I have it set). What specifically does this point to?

Thanks.


Here’s the method I use to zoom to the user’s location. It’s a little unorthodox but it’s what I’ve been helped with since I had problems with zooms for a variety of reasons (I can explain if need be, but it’s probably not relevant):

- (void)zoomToUserLocation:(MKUserLocation *)userlocation
{
    if (!userlocation)
        return;

    MKCoordinateRegion region;
    region.center = userlocation.coordinate;
    region.span = MKCoordinateSpanMake(2.0, 2.0);
    region = [self.mapView regionThatFits:region];
    [self.mapView setRegion:region animated:YES];
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [self zoomToUserLocation:self.mapView.userLocation];
}

- (void)mapView:(MKMapView *)theMapView didUpdateUserLocation:(MKUserLocation *)location
{
    [self zoomToUserLocation:location];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:50:03+00:00Added an answer on May 27, 2026 at 7:50 am

    Can’t tell where the invalid coordinates are coming from but I suggest adding the following checks to the zoomToUserLocation method.

    Just checking if userlocation is nil is not enough. You have to also check if the location property inside userlocation is nil or not. Then, you can use the coordinate property (especially when you’re using the coordinates outside the didUpdateUserLocation delegate method).

    Also, just checking if coordinate is 0,0 (technically a valid coordinate) is not recommended as the struct will be “zero” if it’s never been set or it could even be filled with random data. The Core Location framework’s CLLocationCoordinate2DIsValid function is used as the last line of defense to prevent an invalid region.

    You could also check the timestamp and horizontalAccuracy if you want.

    - (void)zoomToUserLocation:(MKUserLocation *)userlocation
    {
        if (!userlocation)
            return;
    
        if (!userlocation.location)
        {
            NSLog(@"actual location has not been obtained yet");
            return;
        }
    
        //optional: check age and/or horizontalAccuracy
        //(technically should check if location.timestamp is nil first)
        NSTimeInterval locationAgeInSeconds = 
            [[NSDate date] timeIntervalSinceDate:userlocation.location.timestamp];
        if (locationAgeInSeconds > 300)  //adjust max age as needed
        {
            NSLog(@"location data is too old");
            return;
        }
    
        if (!CLLocationCoordinate2DIsValid(userlocation.coordinate))
        {
            NSLog(@"userlocation coordinate is invalid");
            return;
        }
    
        MKCoordinateRegion region;
        region.center = userlocation.coordinate;
        region.span = MKCoordinateSpanMake(2.0, 2.0);
    
        //region = [self.mapView regionThatFits:region];
        //don't need to call regionThatFits explicitly, setRegion will do it
    
        [self.mapView setRegion:region animated:YES];
    }
    

    Additionally (possibly unrelated and you may have already done this but), based on a couple of your previous questions related to this, you might want to clear and re-set the map view’s delegate in the map view controller’s viewWillDisappear and viewWillAppear methods to prevent certain errors:

    -(void)viewWillAppear:(BOOL)animated
    {
        mapView.delegate = self;
    }
    
    -(void)viewWillDisappear:(BOOL)animated
    {
        mapView.delegate = nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.