2

다음 코드를 사용하여 줌하려면 두 번 탭을 구현했습니다.MKMapView setVisibleMapRect가 처음으로 작동하지 않습니다.

CLLocation* currentLocation = [myArray objectAtIndex:5]; 
MKMapPoint annotationPoint = MKMapPointForCoordinate(currentLocation.coordinate); 
MKMapRect zoomRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0.1, 0.1); 
[mapView setVisibleMapRect:zoomRect animated:YES]; 

처음 두 번 살짝 두드리면 특정 핀 위치가 작동하지 않을 때까지 확대하고 다음 번에는 정상적으로 작동합니다.

다른 위치에서 핀 위치와 멀리 떨어져 두 번 탭하면 같은 문제가 발생합니다. 즉, 특정 핀 위치를 확대/축소하면 작동하지 않습니다.

아무도 아이디어가 있으십니까?

감사

+0

아무쪼록 바랍니다. –

+0

'MKMapRectMake' 호출시 유닛이 섞여있는 것 같습니다. 'MKMapRect'의 너비와 높이는'MKMapView'의 맵 투영과 관련된 맵 포인트에 있습니다. 0.1 값은지도 포인트가 아닌 작은 위도와 경도 값을 사용하는 것처럼 보입니다. –

+0

@Jeffrey가 응답 해 주셔서 감사합니다. 비록 내가 영향을 미치지 않는 동일한 값을 얻는 0.1 값을 변경하더라도. 모든 샘플 코드를 공유하십시오. 응답을 주셔서 감사합니다 –

답변

1

를지도 중앙 좌표와 약간의 경도를 보여 축소하고 양쪽 위도은 An MKCoordinateRegion 개체를 만들고, 조정하고 새로운 영역을 표시하기 위해 MKMapView를 업데이트

CLLocation* currentLocation = [myArray objectAtIndex:5]; 
// Create a span covering 0.1 degrees east to west and north to south 
MKCoordinateSpan degreeSpan = MKCoordinateSpanMake(0.1, 0.1); 
// Create a region that centers the span on currentLocation 
MKCoordinateRegion region = MKCoordinateRegionMake(currentLocation.coordinate, degreeSpan); 
// Update the map to show the new region 
[mapView setRegion:region animated:YES]; 

MKCoordinateSpan degreeSpan = MKCoordinateSpanMake(0.05, 0.05); 

또한 미터의 영역을 만들 수 있습니다 :

는 예를 들어, 더 확대 정도 범위의 크기를 줄이려면 그것은 쉽게 추론 할 수 있습니다. 다음은 1000 x 1000 미터 영역을 만듭니다.

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(currentLocation.coordinate, 1000, 1000); 

추가로 확대하려면 미터 수를 줄이십시오.

+0

. 그러나이 코드는 작동하지 않습니다. 최대 줌 레벨로 설정하지 마십시오. –

+0

코드가 특수 효과를 전혀 확대하지 않는다는 것을 의미합니까? 또는 코드가 주석을 충분히 확대하지 않았습니까? –

+0

코드는 주석을 충분히 확대하지 않으며 주석을 최대로 확대 표시하지 않고 초기 위치로 다시 두 번 연속 두드리면됩니다. –

관련 문제