如何使mapview缩放到当前位置的5英里半径 [英] how to make mapview zoom to 5 mile radius of current location

查看:84
本文介绍了如何使mapview缩放到当前位置的5英里半径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个非常常见的问题,但我没有得到这个问题的确切答案。

I know its a very common issue but I am not getting the exact answer for this thing.

如何使MKMapView默认为5英里半径的缩放当前的位置。

How to make MKMapView defaults to a zoom of a 5 mile radius of current location.

提前致谢。

推荐答案

以下使用以下代码你想缩放到半径5英里:

Use the following code when ever you want to zoom to 5 miles radius:

double miles = 5.0;
double scalingFactor = ABS( (cos(2 * M_PI * newLocation.coordinate.latitude / 360.0) ));

MKCoordinateSpan span; 

span.latitudeDelta = miles/69.0;
span.longitudeDelta = miles/(scalingFactor * 69.0); 

MKCoordinateRegion region;
region.span = span;
region.center = newLocation.coordinate;

[mapView setRegion:region animated:YES];

这篇关于如何使mapview缩放到当前位置的5英里半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆