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 3342646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:51:47+00:00 2026-05-18T00:51:47+00:00

I’m familiar with the Google Maps API and I’m trying to learned the iOS

  • 0

I’m familiar with the Google Maps API and I’m trying to learned the iOS MapKit library now. I have an iPhone application which takes an input string and geocodes it using Google Maps geocoder service. I also want to set an appropriate zoom level for the new map but I’m not quite sure how to do it.

After reading, Determining zoom level from single LatLong in Google Maps API

My plan was to parse the JSON response from the Google Maps API and extract the ExtendedData field.

 "ExtendedData":{
     "LatLonBox":{
         "north":34.13919,
         "south":34.067018, 
         "east":-118.38971, 
         "west":-118.442796
     }

Then using that I would like to set the bounds of my map accordingly using the MapKit setRegion function.

I started laying out a function to do this, but I’m a little lost on the logic…

- (void) setMapZoomForLocation(CLLocationCoordinate2D location, double north, double south, double east, double west){

    // some fancy math here....

    // set map region
    MKCoordinateRegion region;
    region.center = location;
    MKCoordinateSpan span;

    // set the span so that the map bounds are correct
    span.latitudeDelta = ???;
    span.longitudeDelta = ???;

    region.span = span;
    [self.mapView setRegion:region animated:YES];
}

Alternatively, I guess I could just used the Accuracy result from a geocode result to set a sort of default zoom level. I’m just not sure how to compute the equivalent default zoom levels for the various results.

See https://code.google.com/apis/maps/documentation/geocoding/v2/#GeocodingAccuracy

———————— Update: Solution I Used ——————————

// parse json result
NSDictionary *results = [jsonString JSONValue];
NSArray *placemarks = (NSArray *) [results objectForKey:@"Placemark"];
NSDictionary *firstPlacemark = [placemarks objectAtIndex:0];

// parse out location
NSDictionary *point = (NSDictionary *) [firstPlacemark objectForKey:@"Point"];
NSArray *coordinates = (NSArray *) [point objectForKey:@"coordinates"];
CLLocationCoordinate2D location;
location.latitude = [[coordinates objectAtIndex:1] doubleValue];
location.longitude = [[coordinates objectAtIndex:0] doubleValue];
// DEBUG
//NSLog(@"Parsed Location: (%g,%g)", location.latitude, location.longitude);

// parse out suggested bounding box
NSDictionary *extendedData = (NSDictionary *) [firstPlacemark objectForKey:@"ExtendedData"];
NSDictionary *latLngBox = (NSDictionary *) [extendedData objectForKey:@"LatLonBox"];

double north = [[latLngBox objectForKey:@"north"] doubleValue];
double south = [[latLngBox objectForKey:@"south"] doubleValue];
double east = [[latLngBox objectForKey:@"east"] doubleValue];
double west = [[latLngBox objectForKey:@"west"] doubleValue];
// DEBUG
//NSLog(@"Parsed Bounding Box: ne = (%g,%g), sw = (%g,%g)", north, east, south, west);

MKCoordinateSpan span = MKCoordinateSpanMake(fabs(north - south), fabs(east - west));
MKCoordinateRegion region = MKCoordinateRegionMake(location, span);
[self.mapView setRegion:region animated:YES];
  • 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-18T00:51:48+00:00Added an answer on May 18, 2026 at 12:51 am

    If all you want to do is generate a MKCoordinateRegion, you shouldn’t need to know anything at all about zoom level. Just create a coordinate region using the width and height of the LatLonBox.

    MKCoordinateSpan span = MKCoordinateSpanMake(fabs(north - south), fabs(east - west));
    MKCoordinateRegion region = MKCoordinateRegionMake(location, span);
    [self.mapView setRegion:region animated:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.