2012-02-16 4 views
0

주석에서 공개 버튼을 클릭하면 정보이라는보기로 끝납니다. 이 화면의 왼쪽 상단 모서리에는 현재 위치의 스냅 샷 인 작은 이미지가 있습니다. 아무도지도에서 스냅 샷을 가져와 정보 화면에 표시하는 방법을 알고 있습니까? 내가 말하는 것에 대해 쉽게 알 수 있도록 이미지가 있습니다. 도와주세요. 모든 대답을 환영합니다. enter image description here주석에서 공개를 클릭 한 후 현재지도의 스냅 샷을 표시하는 방법

답변

0

CoreGraphics를 사용하여지도를 이미지로 렌더링하려고합니다. 당신이 정보 버튼은 단지 중앙에지도를 설정 클릭하면

if (UIGraphicsBeginImageContextWithOptions != NULL) { 
    UIGraphicsBeginImageContextWithOptions(frameYouWantToCopy.size, NO, 0.0); 
} 
else { 
    UIGraphicsBeginImageContext(frameYouWantToCopy.size); 
} 
[mapView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

return result; 
+0

감사를 게시하고있다. 지금 작업 중입니다. – tranvutuan

+0

시도했지만 이미지의 크기가 좋지 않습니다. 내가 한 것은 ** UIGraphicsBeginImageContextWithOptions (CGSizeMake (32, 32), NO, 0.0); ** – tranvutuan

+0

시도했지만 이미지의 크기가 좋지 않습니다. 길이가 높이의 두 배이며 주석을 표시하지 않습니다. 그 위에 ... 내가 한 것은 * UIGraphicsBeginImageContextWithOptions (CGSizeMake (32, 32), NO, 0.0); * ... 나머지는 당신의 코멘트에서와 같다. – tranvutuan

0

내가이 시점 에 대한 해결책을 가지고있다. 그리고 거기에서 이미지를 받아들이십시오. 제가 지금까지 한 것은 입니다. 하나의 이미지를 .h로 가져 와서 해당 이미지 뷰를 사용하여 주석 이미지를 저장합니다. 먼저 핀 좌표를 기억하십시오. 그리고 그 중점 난 당신이 지금 uptill하지만 다른 사람의 흔들림에 대한 답을 얻을 알고있는 기능

-(void)setMaptocentre:(double)lat (double)long 
{ 
    MKCoordinateRegion region; 
    region.center.latitude=lat; 
    region.center.longitude=long; 

    MKCoordinateSpan span; 
    span.latitudeDelta=10; 
    span.longitudeDelta=10; 
    region.span =span; 
    [MapView setRegion:region animated:YES]; 
} 

-(IBAction)infoPressed:(id)sender 
{ 
    [self setMaptocentre: rememberedLat rememberdLong]; 
    //here the rememberedlat and rememberedLong are the latitude and longitude you have 
    // saved at the time of pin drop. the function brings the pin to centre of map 
    // and then does the following part to take the image, where it includes the pin 

    UIGraphicsBeginImageContext(CGRectMake(150, 200, 100, 100).size); 
    CGContextRef c = UIGraphicsGetCurrentContext(); 
    CGContextTranslateCTM(c,-105, -130); 
    [self.view.layer renderInContext:c]; 
    UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    NSData *imageData = UIImagePNGRepresentation(viewImage); 
    mapImageview.image = [UIImage imageWithData:imageData]; 
} 

를 호출하여 지역, 난 여기 감사 의견에 대한

관련 문제