本文整理汇总了C#中CLLocationManager类的典型用法代码示例。如果您正苦于以下问题:C#CLLocationManager类的具体用法?C#CLLocationManager怎么用?C#CLLocationManager使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:ViewDidLoad
publicoverridevoidViewDidLoad()
{
base.ViewDidLoad();
//Performanyadditionalsetupafterloadingtheview,typicallyfromanib.
ConfigureView();
_iPhoneLocationManager=newCLLocationManager();
if(UIDevice.CurrentDevice.CheckSystemVersion(8,0))
{
_iPhoneLocationManager.RequestWhenInUseAuthorization();
}
mapView.ShowsUserLocation=true;
if(mapView.UserLocationVisible)
{
UpdateUiCoords();
}
_iPhoneLocationManager.DesiredAccuracy=1000;//1000meters/1kilometer
mapView.DidUpdateUserLocation+=(sender,e)=>
{
if(mapView.UserLocation!=null)
{
CLLocationCoordinate2Dcoords=mapView.UserLocation.Coordinate;
MKCoordinateSpanspan=newMKCoordinateSpan(MilesToLatitudeDegrees(2),MilesToLongitudeDegrees(2,coords.Latitude));
mapView.Region=newMKCoordinateRegion(coords,span);
UpdateUiCoords();
}
};
}
原文链接:
http://www.jxszl.com/biancheng/C/556773.html