开发者

How to set the zoom value to the map?

I am new to iphone development.I am creating a map application.I want to load the map with a desired location with desired type and zoom.I am able to load the map at desired location by setting the coordinates.i want the zoom to be 18 and the map type to hybrid.

- (void)viewDidLoad {
MKCoordinateRegion region;
region.center.latitude=31.825;
region.center.longitude=-31.402;
region.span.latitudeDelta=0.001;
region.span.longitudeDelta=0.0054;

mapView.region=regi开发者_开发百科on;

}

How to achieve it .Please help me out.Thanks.


MKMapView does not work with zoom levels. It uses regions instead. But judging from your code, you have already discovered that. What exactly is it that doesn't work in your code? It looks correct.

For a hybrid map:

mapView.mapType = MKMapTypeHybrid;


If you want to change the map type you can change that in map type =Hybrid in Xib.

+ (NSUInteger)zoomLevelForMapRect:(MKMapRect)mRect withMapViewSizeInPixels:(CGSize)viewSizeInPixels

{

NSUInteger zoomLevel = 18;
MKZoomScale zoomScale = mRect.size.width / viewSizeInPixels.width; 
double zoomExponent = log2(zoomScale);
zoomLevel = (NSUInteger)(18 - ceil(zoomExponent));
return zoomLevel;

}

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜