場合によっては、マップの中心をユーザーの現在の場所に設定する必要がありますが、青い点は表示されません。エリアだけを表示したいが、ユーザーがマップ上の自分の場所に集中したくないとします。マップの他のオブジェクトに集中してもらいたい。
ユーザーの場所を取得するにはどうすればよいですかが、青いドットを表示しませんか?
場合によっては、マップの中心をユーザーの現在の場所に設定する必要がありますが、青い点は表示されません。エリアだけを表示したいが、ユーザーがマップ上の自分の場所に集中したくないとします。マップの他のオブジェクトに集中してもらいたい。
ユーザーの場所を取得するにはどうすればよいですかが、青いドットを表示しませんか?
ティムの答えに相当するモノタッチは次のとおりです。
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 ;
}
};
で場所を取得できます
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];
この Objective-C コードに相当する実際の MonoTouch が何であるかはわかりませんが、同様の名前にする必要があります。