2011-09-13 44 views
2

標題上藍脈動點(用戶的當前位置)方向我有一個CLLocation管理者如下要顯示而不損失精度圓

myLocation = [[CLLocationManager alloc] init]; 
    myLocation.desiredAccuracy = kCLLocationAccuracyBestForNavigation ; 
    myLocation.delegate=self; 

如果設備支持航向信息然後方法被調用來更新標題

if([CLLocationManager headingAvailable]) 
     [myLocation startUpdatingHeading]; 
在標題

和變化是由以下方法獲取的

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading 
{ 
    [mymap setTransform:CGAffineTransformMakeRotation(-1 * newHeading.trueHeading * 3.14159/180)]; 

} 

我可以使用這個信息(newHeading.trueHeading)來旋轉地圖。但是我怎樣才能顯示一個扇區,用藍點(用戶當前位置的指示)以給定或強制的精度描繪航向。我能夠使用藍色點的自定義圖像,但它失去了光的「準確性圈」。是否有任何方法可以獲得對藍點視圖的引用並對其進行修改,從而不會丟失精度圓。

也可以通過負向旋轉來避免註釋的旋轉,但是當地圖旋轉時,註釋的「標題」和「子標題」會延伸到可見屏幕的視圖之外。有什麼辦法可以限制他們的地圖視圖。

感謝所有幫助提前

回答

1

您可以使用this project作爲指導。它旋轉整個mapView,但可以將其推斷到您的視圖。

編輯:如果你想定製你必須實現viewForAnnotation並檢查給定的註釋是MKUserLocation並返回配置,只要你想自定義annotationView的用戶位置標註。

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    if ([annotation isKindOfClass:[MKUserLocation class]]) { 
     //Configure your custom view to point to the current heading and return it. 

    } 

} 
+0

我可以根據來自newlocation.trueheading獲得的值旋轉地圖,但仍我不能修改藍點(用戶當前的位置)向用戶顯示的標題。我編輯了問題以顯示我所做的更改。 – alekhine

1
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading { 
     if (newHeading.headingAccuracy > 0) { 
       // [newHeading retain]; 
      float heading = newHeading.trueHeading >= 0 ? newHeading.trueHeading : newHeading.magneticHeading; 


      [mymap setTransform:CGAffineTransformMakeRotation(heading)]; 


     } 
    }