2013-02-10 72 views
1

有時需要將用戶當前位置的地圖中心設置爲藍色,但不顯示藍點。假設您只想擁有該區域,但不想要該用戶專注於他在地圖上的位置。你想讓他們專注於地圖的其他對象。獲取設備位置時不顯示藍點單擊

我們如何獲取用戶位置,但不顯示藍點?

回答

1

您可以

mapView.userLocation 

因此,獲得位置設置mapView的中心,它:

MKCoordinateRegion region; 
MKCoordinateSpan span; 
span.latitudeDelta=0.02/10; // zoom level 
span.longitudeDelta=0.02/10; 

CLLocationCoordinate2D location; 
location.latitude = mapView.userLocation.coordinate.latitude; 
location.longitude = mapView.userLocation.coordinate.longitude; 

region.span=span; 
region.center=location; 

[mapView setRegion:region animated:TRUE]; 
[mapView regionThatFits:region]; 

然後,您可以隱藏與藍點:

[mapView setShowUserLocation:NO]; 

不確定實際的MonoTouch等效於這個Objective-C代碼是什麼,但它應該命名爲simi larly。

5

的MonoTouch相當於添的回答是:

mapView .ShowsUserLocation =true ; 
     mapView.DidUpdateUserLocation += (sender, e) => { 
      if (mapView.UserLocation != null) { 
       CLLocationCoordinate2D location; 
       location.Latitude = mapView.UserLocation .Coordinate .Latitude ; 
       location.Longitude = mapView.UserLocation .Coordinate.Longitude; 
       mapView .CenterCoordinate =location ; 
       mapView .ShowsUserLocation =false ; 

      } 
     };