开发者

MKMapView's visibleMapRect property does not set map area correctly?

开发者 https://www.devze.com 2023-03-14 23:27 出处:网络
I am using the visibleMapRect property of MKMapView to set the bound开发者_Python百科s of the visible area in my app. But for some reason, the MKMapRect value of the map is different

I am using the visibleMapRect property of MKMapView to set the bound开发者_Python百科s of the visible area in my app. But for some reason, the MKMapRect value of the map is different

//setting the bounds
MKMapRect bounds = MKMapRectMake(x, y, width, height);
[map setVisibleMapRect:bounds];

- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
    MKMapRect mpRect = [mapView visibleMapRect];
    NSLog(@"Origin: %f, %f", mpRect.origin.x, mpRect.origin.y);
    NSLog(@"Size: %f, %f", mpRect.size.width, mpRect.size.height);
}

The value printed by the mapView:regionDidChangeAnimated: method is different from what I had set.

How do I change this and ensure what I set as the visibleRect is what really is visible?

Thanks.


I would imagine that this is because the aspect ratio of your MKMapView is different from the ratio of your MKMapRect but without further information it's hard to tell.

Could you provide logs of the MapRect you are trying to set and the one that is getting returned?

0

精彩评论

暂无评论...
验证码 换一张
取 消