1

場合によっては、マップの中心をユーザーの現在の場所に設定する必要がありますが、青い点は表示されません。エリアだけを表示したいが、ユーザーがマップ上の自分の場所に集中したくないとします。マップの他のオブジェクトに集中してもらいたい。

ユーザーの場所を取得するにはどうすればよいですかが、青いドットを表示しませんか?

4

2 に答える 2

5

ティムの答えに相当するモノタッチは次のとおりです。

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 ;

            }
        };
于 2013-02-10T20:24:28.753 に答える
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];

この Objective-C コードに相当する実際の MonoTouch が何であるかはわかりませんが、同様の名前にする必要があります。

于 2013-02-10T19:26:42.453 に答える