2013-07-10 54 views
0

我想打,在最大变焦水平对苹果地图获取当前位置的功能,然后自动采取从该部分获取当前位置

我搜索对谷歌照片,但大多数结果是使用谷歌地图。但我需要在Apple Map上做。 向我解释如何做到这一点

回答

0

您需要设置delegate方法,并添加此mapView.showsUserLocation = YES;

,然后加入这轻松设置缩放级别只复制MKMapView-ZoomLevel.h.m

MKMapView Zoom Level

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation 
{ 
    [mapView setCenterCoordinate:userLocation.coordinate zoomLevel:20 animated:NO]; 

    UIGraphicsBeginImageContextWithOptions(mapView.bounds.size, mapView.opaque, 0.0); 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    [mapView.layer renderInContext:context]; 
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    //save to Photo Album 
    UIImageWriteToSavedPhotosAlbum(UIImagePNGRepresentation(image), nil, nil, nil); 
} 
+0

如何拍摄这个快照。你可以给我一个示例代码 – user2434837

+0

快照与UIGraphicsBeginImageContextWithOptions(mapView.bounds.size,mapView.opaque,0.0); CGContextRef context = UIGraphicsGetCurrentContext(); [mapView.layer renderInContext:context]; UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();你可以用图像做任何你想做的事情。 – soryngod

+0

如果我不使用mapview,只需点击一个按钮,所有的事情都在背景下做,然后在imageview中显示一张照片? – user2434837