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。
的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 ;
}
};