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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:11:48+00:00 2026-06-17T17:11:48+00:00

I tried to set visibleMapRect property of MKMapView object but result map rect is

  • 0

I tried to set visibleMapRect property of MKMapView object but result map rect is not the exact what I expected.

This is my code:

NSLog(@"current size %f %f", mapView.visibleMapRect.size.width, mapView.visibleMapRect.size.height);
NSLog(@"target size %f %f", newBounds.size.width, newBounds.size.height);
mapView.visibleMapRect = newBounds;
NSLog(@"new size %f %f", mapView.visibleMapRect.size.width, mapView.visibleMapRect.size.height);

And this is the result:

2013-01-15 19:21:25.440 MyApp[4216:14c03] current size 67108864.594672 46006272.643333
2013-01-15 19:21:25.441 MyApp[4216:14c03] target size 3066685.527175 2102356.690531
2013-01-15 19:21:25.442 MyApp[4216:14c03] new size 4194304.162631  2875392.126220

What kind of magic is this? And how can I set the precise visible rect to my map view?

  • 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-06-17T17:11:50+00:00Added an answer on June 17, 2026 at 5:11 pm

    Thanks to Anna Karenina’s comment I found the answer. MKMapView setVisibleMapRect methods shows rect with maximum zoom level to fit input rect and show map tiles pixel per pixel to keep image looks crisp.

    So I write this code to predict MKMapRect that will be shown for input MKMapRect.

    - (MKMapRect)expectedMapRectForMapRect:(MKMapRect)mapRect inMapView:(MKMapView*)mapView
    {
        CGFloat targetPointPerPixelRatio = MAX(MKMapRectGetWidth(mapRect) / CGRectGetWidth(mapView.bounds), MKMapRectGetHeight(mapRect) / CGRectGetHeight(mapView.bounds));
        CGFloat expextedPointPerPixelRatio = powf(2, ceilf(log2f(targetPointPerPixelRatio)));
    
        NSLog(@"expextedPointPerPixelRatio %f", expextedPointPerPixelRatio);
        MKMapRect expectedMapRect;
        expectedMapRect.size = MKMapSizeMake(CGRectGetWidth(mapView.bounds)*expextedPointPerPixelRatio, CGRectGetHeight(mapView.bounds)*expextedPointPerPixelRatio);
        expectedMapRect.origin = MKMapPointMake(MKMapRectGetMidX(mapRect) - expectedMapRect.size.width/2, MKMapRectGetMidY(mapRect) - expectedMapRect.size.height/2);
    
        expectedMapRect.origin.x = roundf(expectedMapRect.origin.x / expextedPointPerPixelRatio) * expextedPointPerPixelRatio;
        expectedMapRect.origin.y = roundf(expectedMapRect.origin.y / expextedPointPerPixelRatio) * expextedPointPerPixelRatio;
        return expectedMapRect;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried to set the margin and border to 0,but still not working. <style
I tried set that, but when this, my Form still have greater height. Is
I've tried Set-WSManQuickConfig command in Powershell, but it could not configure the firewall: Set-WSManQuickConfig
I tried set fullScreenMode(false) for my app (LWUIT). But can not get Canvas. 1
I tried to set up my togglebutton properties layout using style.xml. Here's my code:
I've tried to set up a Django model with a python property, like so:
I want to achieve this using html and css: I have tried to set
Capistrano does not work with rvmsudo in my deploy.rb. I tried set :sudo, 'rvmsudo'
I tried to set the parameter value to system.dbnull.value but got some errors. thanks.
I tried to set backcolor to transparent by solution given at msdn but failed

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.