2010-05-11 46 views

回答

0

你是否設置了?

mapView.showsUserLocation = YES; 

設置一個特定的位置有點困難,但肯定可以在沒有未記錄的API的情況下使用。請參閱以下代碼:

- (void)animateToSelectedPlace:(CGFloat)zoomLevel { 
    MKCoordinateRegion region; 
    region.center = [self getCoordinateFromComponents:chosenLatitude:chosenLongitude]; 

    MKCoordinateSpan span = {zoomLevel,zoomLevel}; 
    region.span = span; 

    [mapView setRegion:region animated:YES]; 
} 

-(CLLocationCoordinate2D)getCoordinateFromComponents:(NSNumber*)latitude:(NSNumber*)longitude { 
    CLLocationCoordinate2D coord; 
    coord.latitude = latitude.doubleValue; 
    coord.longitude = longitude.doubleValue; 
    return coord; 
} 
+0

我與showsUserLocation測試= YES。但我需要將藍點設置爲特定位置。 任何想法,示例代碼? – fvisticot 2010-05-11 16:54:31

+0

編輯答案包括示例代碼,看你如何去 – 2010-05-11 23:19:02

+0

謝謝你的幫助。 它不工作。 如果我理解的很好,animateToSelectPlace函數用於設置地圖位置(以區域定義爲中心)和動畫。 我已經設置了mapView.showsUserLocation = YES,但不是藍色點顯示在地圖的中心... 任何其他的想法? – fvisticot 2010-05-12 15:33:54

0

不確定是否可以設置CUSTOM用戶位置(通常人們使用圖像模擬藍色用戶點)。我雖然不是100%肯定,讓你有機會嘗試這樣的事情來檢查它是否能夠應對用戶位置與MKAnnotation ...

CLLocationCoordinate2D c = self.mapView.userLocation.location.coordinate; 
[[self.mapView userLocation] setCoordinate:c]; 
+0

'setCoordinate'方法是隻讀的。 – chicobermuda 2016-06-06 17:40:09

相關問題