我想在MKMapView中添加功能。如何在觸摸任何註釋時更改視圖
我現在有一個帶有許多註釋的mapView我想要..當我觸及任何註釋時,整個視圖應該關注該註釋。即註釋A位於右上角,當我觸摸MapView應該在中心顯示A時。
我想在MKMapView中添加功能。如何在觸摸任何註釋時更改視圖
我現在有一個帶有許多註釋的mapView我想要..當我觸及任何註釋時,整個視圖應該關注該註釋。即註釋A位於右上角,當我觸摸MapView應該在中心顯示A時。
在註釋代表你必須設置該地區的MapView指定中心
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
MKAnnotation *annotation= view.annotation; // Get your annotaion here
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude=annotation.coordinate.latitude;
region.center.longitude=annotation.coordinate.longitude;
region.span.latitudeDelta=0.001f;
region.span.longitudeDelta=0.001f;
[mapView setRegion:region animated:YES];
//Do your other stuffs here
}
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
MKAnnotation *annotation= view.annotation; // Get your annotaion here
[map setCenterCoordinate:annotation.coordinate];
}
//This will set the annotation in the centre of the map without zooming the map.
謝謝,正是我在找的! – Mateus 2013-01-21 15:27:56
@whySoSerious ......我不希望它放大這麼多...傳染,沒有任何放大......只是它應該以註釋爲中心。怎麼做? – 2012-03-20 11:03:00
設置區域時,地圖將移動到我們給出的位置爲中心。只是嘗試我給的東西 – iPrabu 2012-03-20 11:14:28
是的,我試過..但是當我觸摸任何位置時,它在該位置放大得太多......所以:( – 2012-03-20 11:28:54