2013-07-10 237 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