2012-11-07 3 views
0

저는 MapView가 있으며 사용자의 위치와 주변에는 관광 명소와 관련된 다양한 유형의 annotationView가 있습니다. MapView가 스크롤 할 수 있고 확대/축소되어 도시의 모든 annotationView를 보길 원하지만, MapView를 움직이면 즉각적인 중심의 촬영을 반환합니다. MKMapView는 스크롤하지 않고 확대/축소하지 않습니다.

은 MapViewController.m

- (void)viewDidLoad{ 

     //..... 

    self.mapView.zoomEnabled=YES; 
    self.mapView.scrollEnabled = YES; 

     //...... 
    } 


- (void) locationManager:(CLLocationManager *) manager 
didUpdateToLocation:(CLLocation *) newLocation 
     fromLocation:(CLLocation *) oldLocation { 

     //...... 
    self.coordinate = CLLocationCoordinate2DMake(self.latitudine, self.longitudine); 
    CLLocationCoordinate2D min = CLLocationCoordinate2DMake(self.coordinate.latitude -0.005, 
     self.coordinate.longitude-0.005); 

CLLocationCoordinate2D max = CLLocationCoordinate2DMake(self.coordinate.latitude+0.005, 
     self.coordinate.longitude+0.005); 

CLLocationCoordinate2D center = CLLocationCoordinate2DMake((max.latitude + min.latitude) 
    /2.0, (max.longitude + min.longitude)/2.0); 
MKCoordinateSpan span = MKCoordinateSpanMake(max.latitude - min.latitude, max.longitude - 
     min.longitude); 
MKCoordinateRegion region = MKCoordinateRegionMake(center, span); 

self.mapView.region= region; 

    [mapView setRegion:region animated:TRUE]; 

    //...... 

} 
+0

나는 이것이 문제라고 생각하지 않지만 [mapView setRegion : region animated : TRUE]; 잘못되었습니다. [mapView setRegion : region animated : YES]; – jcesarmobile

+1

@jcesar TRUE 또는 YES를 전달할 때 차이점이 없습니다. 그들이 동일하기 때문에 그것은 전혀 중요하지 않습니다. –

+0

@ConicaDegenere touchesBegan/end 메서드에서 무언가를하고 있는지 확인하십시오. –

답변

2

나는 업데이트가 지속적으로 불리는지고 있기 때문에 생각의 코드, 그래서 그것은 당신의지도보기 setregion 비트와 함께 화면을 항상 중심에 있습니다.

locationManager를 선언 할 때 민감도를 설정해야합니다.

self.locationManager.distanceFilter = 10.0f; 

변경 사항이 10 미터 이상 변경된 경우에만 업데이트를 호출합니다.

+0

고맙습니다. –

0

장치가 변경된 위치를 알게 될 때마다지도를 self.latitudine 및 self.longitudine으로 확대합니다. 코드에서 보여준 바에 따르면 이러한 값을 새로운 것으로 설정하지 않습니다. newLocation 좌표가 확대되고 있음을 의미합니까?

관련 문제