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

  • SEARCH
  • Home
  • 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 7550921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:20:35+00:00 2026-05-30T10:20:35+00:00

I want to be able to update the region displayed on a MKMapView by

  • 0

I want to be able to update the region displayed on a MKMapView by allowing the user to type in an address or location in a UIAlertView. I currently have:

        if (geocoder.geocoding)
            [geocoder cancelGeocode];

        [geocoder geocodeAddressString:[[alertView textFieldAtIndex:0] text] completionHandler:^(NSArray *placemarks, NSError *error) {
            if (!error) {
                NSLog(@"Found a location");
            } else {
                NSLog(@"Error in geocoding");
            }

            NSLog(@"Num found: %d", [placemarks count]);

            CLPlacemark *placemark = [placemarks objectAtIndex:0];
            MKCoordinateRegion region;
            region.center.latitude = placemark.region.center.latitude;
            region.center.longitude = placemark.region.center.longitude;
            MKCoordinateSpan span;
            double radius = placemark.region.radius / 1000;

            NSLog(@"Radius is %f", radius);
            span.latitudeDelta = radius / 112.0;
            //span.longitudeDelta = ??? 

            region.span = span;

            NSLog(@"Region is %f %f %f", region.center.latitude, region.center.longitude, span.latitudeDelta);

            [mapView setRegion:region animated:YES];
        }];

My problem is I am unsure how to calculate the longitude delta.

  • 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-30T10:20:36+00:00Added an answer on May 30, 2026 at 10:20 am

    You could just set it equal to latitudeDelta and the map view will adjust as needed.

    But you don’t need to calculate the span yourself in the first place. You can use:

    region = MKCoordinateRegionMakeWithDistance(
                 placemark.region.center, 
                 placemark.region.radius, 
                 placemark.region.radius);
    

    Not sure about the second part of your question.


    In iOS 7 and higher, the region returned by the CLPlacemark is actually a CLCircularRegion (see Deprecated CLRegion methods – how to get radius?).

    Although the original code will still work as-is, you may get a compiler warning that radius and center are deprecated.

    To avoid the warning, cast the region as a CLCircularRegion:

    CLCircularRegion *pmCircularRegion = (CLCircularRegion *)placemark.region;
    
    region = MKCoordinateRegionMakeWithDistance(
             pmCircularRegion.center,
             pmCircularRegion.radius,
             pmCircularRegion.radius);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF DataGrid that I want to be able to Update, Insert
I have BasicMsi project in InstallShield. I want to be able to update this
I want to be able to add and update certain information. Now it was
I want to be able to insert and update rows with embedded carriage returns
I want to be able to take an image that i have already captured
I want do be able do update some values direct form the index view
i have a question regarding some complex data-binding. I want to be able to
I want to be able to update a certain line on a text file.
I want to be able to update a row with the highest ID. The
I want to create an app and to be able to update it from

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.