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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:50:26+00:00 2026-05-25T15:50:26+00:00

I have this code : – (void)viewDidLoad { [super viewDidLoad]; CLLocationCoordinate2D userLocation = CLLocationCoordinate2DMake(48.9793946200,

  • 0

I have this code :

- (void)viewDidLoad
{
    [super viewDidLoad];

    CLLocationCoordinate2D userLocation = CLLocationCoordinate2DMake(48.9793946200, 2.4726272850);
    CLLocationDistance dist1 = 636.9887048804;
    CLLocationDistance dist2 = 900.8380655203;
    CLLocationDistance dist = dist1;

    [self.myMapView setRegion:MKCoordinateRegionMakeWithDistance(userLocation, dist, dist) animated:YES];

    // TEST
    // ------------------------------------------------------------
    MKCoordinateRegion region = self.myMapView.region;
    CLLocationDegrees lat = region.center.latitude;
    CLLocationDegrees lon = region.center.longitude - region.span.longitudeDelta/2;
    CLLocation *west = [[[CLLocation alloc] initWithLatitude:lat longitude:lon] autorelease];

    NSLog(@"User location: lat : %.10lf long : %.10lf", userLocation.latitude, userLocation.longitude);
    NSLog(@"distance set: %.10lfm", dist);
    NSLog(@"center: lat : %.8lf long : %.8lf", region.center.latitude, region.center.longitude);

    CLLocation* centerRegion = [[[CLLocation alloc] initWithLatitude:region.center.latitude longitude:region.center.longitude] autorelease];
    NSLog(@"distance to western boundary: %.2lfm", [centerRegion distanceFromLocation:west]);

    lat = region.center.latitude - region.span.latitudeDelta/2 ;
    lon = region.center.longitude;
    CLLocation *north = [[[CLLocation alloc] initWithLatitude:lat longitude:lon] autorelease];

    NSLog(@"distance to western boundary: %.2lfm", [centerRegion distanceFromLocation:north]);
    // ------------------------------------------------------------
}

When setting dist = dist1, that gives :

User location: lat : 48.9793946200 long : 2.4726272850
distance set: 636.9887048804m

center: lat : 48.97937199 long : 2.47269630
distance to western boundary: 500.44m
distance to western boundary: 650.57m

enter image description here

When setting dist = dist2, that gives :

User location: lat : 48.9793946200 long : 2.4726272850
distance set: 900.8380655203m

center: lat : 48.97937199 long : 2.47269630
distance to western boundary: 500.44m
distance to western boundary: 650.57m

enter image description here

What’s the problem here ? Why do I have the same display with 2 different distances ?

Final question : How can I be sure to display the wanted meters on the map, at minimum for horizontal and vertical visual (with or without animation of course) ?

  • 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-25T15:50:26+00:00Added an answer on May 25, 2026 at 3:50 pm

    If I understand it correctly, you want to tell the mapView “give me a map which is 636m across” or “give me a map which is 900m across”. But the map gives you the same distance across for both of these.

    When you set a map region, you generally don’t get back exactly what you ask for, but instead a best fit. The map view looks at the region you requested, then creates a region which fits your region inside it. The problem is that the map view doesn’t zoom exactly to your requested region, it finds the highest zoom level that allows all your region to be visible. It won’t use an in-between zoom level. This is why when you use setRegion: the map always looks crisp. You can manually set an in-between zoom level by pinching in or out, but not (as far as I know) programatically.

    Note too that the map view might change the actual region variable you pass to it. Here’s the docs:

    When setting a new region, the map may adjust the value in the region parameter so that it fits the visible area of the map precisely. This is normal and is done to ensure that the value in the region property always reflects the visible portion of the map. However, it does mean that if you get the value of that property right after calling this method, the returned value may not match the value you set. (You can use the regionThatFits: method to determine the region that will actually be set by the map.)

    You can see the difference in regions by logging the region you give it, and the one the map view actually sets (although I didn’t see the passed myRegion change):

    MKCoordinateRegion myRegion = MKCoordinateRegionMakeWithDistance(userLocation, dist, dist);
    NSLog(@"Passed: %f %f", myRegion.span.latitudeDelta, myRegion.span.longitudeDelta);
    [self.mapView setRegion:myRegion animated:YES];
    
    NSLog(@"Passed 2: %f %f", myRegion.span.latitudeDelta, myRegion.span.longitudeDelta);
    NSLog(@"Set: %f %f", mapView.region.span.latitudeDelta, mapView.region.span.longitudeDelta);
    
    > Passed: 0.005728 0.008702
    > Passed 2: 0.005728 0.008702
    > Set: 0.012957 0.013733
    

    If you bump your distance up to 1200m, you’ll be able to see the next zoom level.

    BTW, there’s a small error in your code:

    NSLog(@"distance to western boundary: %.2lfm", [centerRegion distanceFromLocation:north]);
    

    should be

    NSLog(@"distance to northern boundary: %.2lfm", [centerRegion distanceFromLocation:north]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have this code, that draws an image. private void timer1_Tick(object sender, EventArgs e)
i have this code which doesnt work: void CAnalyzerIF::SetData(int i_iIters, const CParameterSet* i_CParameterSet) {
I have this code in jQuery, that I want to reimplement with the prototype
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:
I have this code that performs an ajax call and loads the results into
I have this code #include <iostream> using namespace std; int main(int argc,char **argv) {
I have this code: CCalcArchive::CCalcArchive() : m_calcMap() { } m_calcMap is defined as this:
I have this code: myVariable which I want to change into trace(myVariable: + myVariable);
I have this code while($row = mysql_fetch_row($result)) { echo '<tr>'; $pk = $row[0]['ARTICLE_NO']; foreach($row

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.