当前位置: 首页>>代码示例>>C#>>正文


C# CLLocationManager.StartUpdatingHeading方法代码示例

本文整理汇总了C#中CLLocationManager.StartUpdatingHeading方法的典型用法代码示例。如果您正苦于以下问题:C# CLLocationManager.StartUpdatingHeading方法的具体用法?C# CLLocationManager.StartUpdatingHeading怎么用?C# CLLocationManager.StartUpdatingHeading使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLLocationManager的用法示例。


在下文中一共展示了CLLocationManager.StartUpdatingHeading方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

		public void Start ()
		{
			if (CLLocationManager.LocationServicesEnabled) {
				lman = new CLLocationManager {
					DesiredAccuracy = CLLocation.AccuracyBest,
				};

				lman.RequestWhenInUseAuthorization ();

				lman.LocationsUpdated += (sender, e) => {
					var loc = e.Locations [0];
					Timestamp = loc.Timestamp;
					Location = new Location (loc.Coordinate.Latitude, loc.Coordinate.Longitude, loc.Altitude);
//					Console.WriteLine (Location);
					HorizontalAccuracy = loc.HorizontalAccuracy;
					VerticalAccuracy = loc.VerticalAccuracy;
					LocationReceived (this, EventArgs.Empty);
				};

				lman.UpdatedHeading += (sender, e) => {
					Heading = e.NewHeading.TrueHeading;
//					Console.WriteLine ("Heading: {0}", Heading);
				};

				lman.StartUpdatingLocation ();
				lman.StartUpdatingHeading ();
			}
		}
开发者ID:jorik041,项目名称:ARDemo,代码行数:28,代码来源:LocationSensor.cs

示例2: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // Perform any additional setup after loading the view, typically from a nib.
            iPhoneLocationManager = new CLLocationManager();
            iPhoneLocationManager.Delegate = new LocationDelegate(this);

            iPhoneLocationManager.StartUpdatingLocation();
            iPhoneLocationManager.StartUpdatingHeading();
        }
开发者ID:in-the-keyhole,项目名称:khs-blog-examples,代码行数:11,代码来源:CurrentTemperatureViewController.cs

示例3: PlatformSpecificStart

        protected override void PlatformSpecificStart(MvxLocationOptions options)
        {
            lock (this)
            {
                if (_locationManager != null)
                    throw new MvxException("You cannot start the MvxLocation service more than once");

                _locationManager = new CLLocationManager();
                _locationManager.Delegate = new LocationDelegate(this);

                if (options.MovementThresholdInM > 0)
                {
                    _locationManager.DistanceFilter = options.MovementThresholdInM;
                }
                else
                {
                    _locationManager.DistanceFilter = CLLocationDistance.FilterNone;
                }
                _locationManager.DesiredAccuracy = options.Accuracy == MvxLocationAccuracy.Fine ? CLLocation.AccuracyBest : CLLocation.AccuracyKilometer;
                if (options.TimeBetweenUpdates > TimeSpan.Zero)
                {
                    Mvx.Warning("TimeBetweenUpdates specified for MvxLocationOptions - but this is not supported in iOS");
                }


				if (options.TrackingMode == MvxLocationTrackingMode.Background)
				{
					if (IsIOS8orHigher)
					{
						_locationManager.RequestAlwaysAuthorization ();
					}
					else
					{
						Mvx.Warning ("MvxLocationTrackingMode.Background is not supported for iOS before 8");
					}
				}
				else
				{
					if (IsIOS8orHigher)
					{
						_locationManager.RequestWhenInUseAuthorization ();
					}
				}

                if (CLLocationManager.HeadingAvailable)
                    _locationManager.StartUpdatingHeading();

                _locationManager.StartUpdatingLocation();
            }
        }
开发者ID:Everbridge,项目名称:sm-MvvmCross,代码行数:50,代码来源:MvxTouchLocationWatcher.cs

示例4: ViewDidLoad

		public override void ViewDidLoad ()
		{
			// all your base
			base.ViewDidLoad ();
			
			// load the appropriate view, based on the device type
			this.LoadViewForDevice ();

			// initialize our location manager and callback handler
			iPhoneLocationManager = new CLLocationManager ();
			
			// uncomment this if you want to use the delegate pattern:
			//locationDelegate = new LocationDelegate (mainScreen);
			//iPhoneLocationManager.Delegate = locationDelegate;
			
			// you can set the update threshold and accuracy if you want:
			//iPhoneLocationManager.DistanceFilter = 10; // move ten meters before updating
			//iPhoneLocationManager.HeadingFilter = 3; // move 3 degrees before updating
			
			// you can also set the desired accuracy:
			iPhoneLocationManager.DesiredAccuracy = 1000; // 1000 meters/1 kilometer
			// you can also use presets, which simply evalute to a double value:
			//iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;
			
			// handle the updated location method and update the UI
			if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) {
				iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
					UpdateLocation (mainScreen, e.Locations [e.Locations.Length - 1]);
				};
			} else {
				// this won't be called on iOS 6 (deprecated)
				iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
					UpdateLocation (mainScreen, e.NewLocation);
				};
			}
			
			// handle the updated heading method and update the UI
			iPhoneLocationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) => {
				mainScreen.LblMagneticHeading.Text = e.NewHeading.MagneticHeading.ToString () + "º";
				mainScreen.LblTrueHeading.Text = e.NewHeading.TrueHeading.ToString () + "º";
			};
			
			// start updating our location, et. al.
			if (CLLocationManager.LocationServicesEnabled)
				iPhoneLocationManager.StartUpdatingLocation ();
			if (CLLocationManager.HeadingAvailable)
				iPhoneLocationManager.StartUpdatingHeading ();
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:48,代码来源:MainViewController.cs

示例5: PlatformSpecificStart

        protected override void PlatformSpecificStart(MvxGeoLocationOptions options)
        {
            lock (this)
            {
                if (_locationManager != null)
                    throw new MvxException("You cannot start the MvxLocation service more than once");

                _locationManager = new CLLocationManager();
                _locationManager.Delegate = new LocationDelegate(this);

                // more needed here for more filtering
                // _locationManager.DistanceFilter = options. CLLocationDistance.FilterNone

                _locationManager.DesiredAccuracy = options.EnableHighAccuracy ? CLLocation.AccuracyBest : CLLocation.AccuracyKilometer;

                if (CLLocationManager.HeadingAvailable)
                    _locationManager.StartUpdatingHeading();

                _locationManager.StartUpdatingLocation();
            }
        }
开发者ID:andyci,项目名称:MvvmCross-Plugins,代码行数:21,代码来源:MvxTouchGeoLocationWatcher.cs

示例6: ReturnHeading

        public string ReturnHeading()
        {
            if (_lm != null)
              {
            _lm = new CLLocationManager();
            _lm.UpdatedHeading += HeadingUpdateDelegate;
            _lm.StartUpdatingHeading();
              }

              // block on the search until the async result return
              string result;
              lock (_locker)
              {
            while (location == null)
            {
              Monitor.Pulse(_locker);
            }

            result = location;
            location = null;
              }
              return result;
        }
开发者ID:rsatter,项目名称:MonoCross,代码行数:23,代码来源:GpsAccess.cs

示例7: ViewDidAppear

        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear (animated);

            //Device Rotation
            if((InterfaceOrientation == UIInterfaceOrientation.LandscapeLeft) || (InterfaceOrientation == UIInterfaceOrientation.LandscapeRight))
                SetupUIForOrientation(InterfaceOrientation);
            //Initialize Map View
            mapView.WillStartLoadingMap += (sender, e) =>
            {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            };
            mapView.MapLoaded += (sender, e) =>
            {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
            };
            mapView.LoadingMapFailed += (sender, e) =>
            {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
            };
            mapView.MapType = MKMapType.Hybrid;
            mapView.ShowsUserLocation = true;
            mapView.UserLocation.Title = "Your are here!";
            mapView.UserLocation.Subtitle = "YES!";

            //Initialize location mananger
            locationManager = new CLLocationManager ();
            locationManager.DesiredAccuracy = -1;
            locationManager.DistanceFilter = 50;
            locationManager.HeadingFilter = 1;
            //Add 2 delegates
            locationManager.UpdatedHeading += UpdatedHeading;
            locationManager.UpdatedLocation += UpdatedLocation;
            locationManager.StartUpdatingLocation ();
            locationManager.StartUpdatingHeading ();
        }
开发者ID:aaronhe42,项目名称:MonoTouch-Examples,代码行数:36,代码来源:GPSViewController.cs

示例8: ViewDidLoad


//.........这里部分代码省略.........
            wallCollImg = UIImage.FromBundle("Images/dcsfloorWideDoors.png");

            col = new Collision(floorPlanGraph, new StepDetector());

            ((Collision)col).WallCol = new WallCollision ((x,y) => GetPixelColor(new PointF(x, y), wallCollImg));
            wallColTest = new WallCollision ((x,y) => GetPixelColor(new PointF(x, y), wallCollImg));

            pathView = new PathView (wallColTest);

            col.SetLocation(707.0f, 677.0f);
            col.PassHeading(90);
            col.PositionChanged += HandleStepsTaken;

			//Container for floorplan and any overlaid images
            var container = new UIView();

			//Will contain floorplan images
            floorplanImageView = new UIImageView();

			//Load floorplan images
            floorplanImageNoGrid = UIImage.FromBundle("Images/FinalDcsFloor1.png");
            floorplanImageWithGrid = UIImage.FromBundle("Images/dcsFloorWideDoorsGrid.png");

			//Initiate the location arrow
            locationArrow = new LocationArrowImageView();
            locationArrow.ScaleFactor = floorplanView.ZoomScale;
            pathView.ScaleFactor = floorplanView.ZoomScale;
            setStartPoint(690.0f, 840.0f);

			//Set sizes for floorplan view and path view
            floorplanView.ContentSize = floorplanImageNoGrid.Size;
            pathView.Frame = new CGRect(new CGPoint(0, 0), floorplanImageNoGrid.Size);

			//Add subviews to the container (including pathview and floorplanview)
            container.AddSubview(floorplanImageView);
            container.AddSubview(locationArrow);
            floorplanImageView.AddSubview(pathView);
            changeFloorPlanImage(floorplanImageView, floorplanImageNoGrid);
            container.SizeToFit();

			//Adjust scrolling and zooming properties for the floorplanView
            floorplanView.MaximumZoomScale = 1f;
            floorplanView.MinimumZoomScale = .25f;
            floorplanView.AddSubview(container);
            floorplanView.ViewForZoomingInScrollView += (UIScrollView sv) => { return floorplanImageView; };

			//Variables needed to convert device acceleration to world z direction acceleration
			double accelX = 0, accelY = 0, accelZ = 0;

			//Scale location arrow and paths when zooming the floorplan
            floorplanView.DidZoom += (sender, e) =>
            {
                locationArrow.ScaleFactor = floorplanView.ZoomScale;
                pathView.ScaleFactor = floorplanView.ZoomScale;
            };

			//Pass acceleremoter values to the collision class
            motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue,
                (data, error) =>
                {
					accelX = data.Acceleration.X*9.8;
					accelY = data.Acceleration.Y*9.8;
					accelZ = Math.Sqrt(Math.Pow(accelX, 2) + Math.Pow(accelY, 2) + Math.Pow(data.Acceleration.Z*9.8, 2));

                    col.PassSensorReadings(CollisionSensorType.Accelometer, accelX,
                        accelY, accelZ);
                    //displayAccelVal((float)accelZ);
                });

			/*
			motionManager.StartDeviceMotionUpdates(NSOperationQueue.CurrentQueue, (data, error) =>
				{ 
					//data.Attitude.MultiplyByInverseOfAttitude(data.Attitude);
					var test = data.UserAcceleration.X;
					var accelRelZ = data.Attitude.RotationMatrix.m31 * accelX + data.Attitude.RotationMatrix.m32 * accelY + data.Attitude.RotationMatrix.m33 * accelZ;
					debugLabel.Text = "" + Math.Round(test, 2);//Math.Round(accelRelZ, 2);
				}
			);
			*/

			//LongPressManager will cause the path input menu to appear after a stationary long press
            longPressManager.AllowableMovement = 0;
            longPressManager.AddTarget(() => handleLongPress(longPressManager, floorPlanGraph));
            floorplanView.AddGestureRecognizer(longPressManager);

			//the location manager handles the phone heading
            locationManager = new CLLocationManager();
            locationManager.DesiredAccuracy = CLLocation.AccuracyBest;
            locationManager.HeadingFilter = 1;
            locationManager.UpdatedHeading += HandleUpdatedHeading;
            locationManager.StartUpdatingHeading();

			//Button currently used for testing purposes only

			//Another testing button
            simulationButton.TouchUpInside += delegate { col.StepTaken(false); };

            returnButton.TouchUpInside += delegate{ returnToMenu(); };

        }
开发者ID:dcbright01,项目名称:Navigator,代码行数:101,代码来源:ViewController.cs

示例9: CompassStart

 void CompassStart()
 {
     if (_locationManager != null) {
         _locationManager = new CLLocationManager();
         //_locationManager.Delegate = new CLLocationManagerDelegate();
         _locationManager.UpdatedHeading += delegate(object sender, CLHeadingUpdatedEventArgs e) {
             string javascript = string.Format("compass.onCompassSuccess({0:0.00})", _locationManager.Heading.MagneticHeading);
             _webView.EvaluateJavascript(javascript);
         };
         _locationManager.StartUpdatingHeading();
     }
 }
开发者ID:pazof,项目名称:MonoCross,代码行数:12,代码来源:WebViewDelegate.cs

示例10: ViewWillAppear

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear (animated);

            //Ocultamos el campo de observaciones, ya que por lo visto no se almacena en ningun lado, esperamos respuesta
            this.cmpObservaciones.Hidden = true;
            this.lblObservaciones.Hidden = true;

            //Ocultamos los labels donde se muestran las coordenadas del dispositivo
            this.lblLatitud.Hidden = true;
            this.lblLongitud.Hidden = true;

            //Declarar el Location Manager
            iPhoneLocationManager = new CLLocationManager ();
            iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;

            //Obtener la posicion del dispositivo
            //El metodo es diferente en iOS 6 se verifica la version del S.O.
            if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) {
                iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
                    UpdateLocation (e.Locations [e.Locations.Length - 1]);
                };
            }else{
                iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
                    UpdateLocation (e.NewLocation);
                };
            }

            iPhoneLocationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) => {

            };

            //Actualizar la ubicacion
            if (CLLocationManager.LocationServicesEnabled)
                iPhoneLocationManager.StartUpdatingLocation ();
            if (CLLocationManager.HeadingAvailable)
                iPhoneLocationManager.StartUpdatingHeading ();

            //Se esconde el booton para ir a la vista anterior
            this.NavigationItem.HidesBackButton = true;

            //se crea el boton para regresar a la vista anterior, verificando que la tarea haya sido dada de alta
            UIBarButtonItem regresar = new UIBarButtonItem();
            regresar.Style = UIBarButtonItemStyle.Plain;
            regresar.Target = this;
            regresar.Title = "Lista de tareas";
            regresar.Clicked += (sender, e) => {
                if(this.listo == false){
                    UIAlertView alert = new UIAlertView(){
                        Title = "¿Salir?" , Message = "Si sales se perderá el registro de la tarea"
                    };
                    alert.AddButton("Aceptar");
                    alert.AddButton("Cancelar");
                    alert.Clicked += (s, o) => {
                        if(o.ButtonIndex==0){
                            NavigationController.PopViewControllerAnimated(true);
                        }
                    };
                    alert.Show();
                }else{
                    NavigationController.PopViewControllerAnimated(true);
                }
            };

            //posionamiento del boton
            this.NavigationItem.LeftBarButtonItem = regresar;

            //Se establece un borde para el textarea de la descripcion
            this.cmpDescripcion.Layer.BorderWidth = 1.0f;
            this.cmpDescripcion.Layer.BorderColor = UIColor.Gray.CGColor;
            this.cmpDescripcion.Layer.ShadowColor = UIColor.Black.CGColor;
            this.cmpDescripcion.Layer.CornerRadius = 8;

            //Declaramos el datamodel para los responsables
            pickerDataModelResponsibles = new PickerDataModelResponsibles ();
            //Declaramos el datamodel para las categorias
            pickerDataModelCategories = new PickerDataModelCategories ();
            //Declaramos el datamodel para el picker de prioridades
            pickerDataModel = new PickerDataModel ();
            //Declaramos el datamodel para el picker de buisqueda de personas
            pickerDataModelPeople = new PickerDataModelPeople ();
            //Declaramos el actionsheet donde se mostrara el picker
            actionSheetPicker = new ActionSheetPicker(this.View);

            this.btnResponsable.TouchUpInside += (sender, e) => {
                try{
                    responsibleService = new ResponsibleService();
                    pickerDataModelResponsibles.Items = responsibleService.All();
                    actionSheetPicker.Picker.Source = pickerDataModelResponsibles;
                    actionSheetPicker.Show();
                }catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch(System.Exception){
                    UIAlertView alert = new UIAlertView(){
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
//.........这里部分代码省略.........
开发者ID:saedaes,项目名称:gestion2013,代码行数:101,代码来源:NewTaskView.cs

示例11: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            var locSvc = new ROMPLocation ();
            myFacilities = locSvc.GetLocations (sessionKey, groupID);
            locMan = new CLLocationManager ();

            if (myFacilities.Count () > 0) {
                if (!CLLocationManager.LocationServicesEnabled) {
                    UIAlertView _error = new UIAlertView ("Error", "Location services not enabled, please enable this in your Settings.", null, "Ok", null);
                    _error.Show ();
                } else if (CLLocationManager.Status == CLAuthorizationStatus.Denied) {
                    UIAlertView _error = new UIAlertView ("Error", "App is not authorized to use location data.", null, "Ok", null);
                    _error.Show ();
                } else {
                    //locMan.LocationUpdated += LocationChanged;
                    locMan.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;
                    if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) {
                        locMan.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
                            UpdateLocation (e.Locations [e.Locations.Length - 1]);
                        };
                    } else {
                        #pragma warning disable 618
                        // this won't be called on iOS 6 (deprecated)
                        locMan.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
                            UpdateLocation (e.NewLocation);
                        };
                        #pragma warning restore 618
                    }

                    if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                    {
                        locMan.RequestAlwaysAuthorization ();
                    }

                    if (CLLocationManager.LocationServicesEnabled)
                        locMan.StartUpdatingLocation ();
                    if (CLLocationManager.HeadingAvailable)
                        locMan.StartUpdatingHeading ();
                }
                btnCheckIn.BackgroundColor = new UIColor(new CoreGraphics.CGColor(0.9f,0.9f,0.9f));
                btnCheckIn.Layer.CornerRadius = 1;
                btnCheckIn.TouchUpInside += (object sender, EventArgs e) => {
                    if (currentLocation != null) {
                        if (groupID <= 2) {
                            string absResult = "You Are Not Within A Specified Zone.";
                            string absTitle = "Error";
                            if (btnCheckIn.Title (UIControlState.Normal) == "Check In") {
                                foreach (FacilityCoordinates fc in myFacilities) {
                                    var fenceLat = fc.Latitude;
                                    var fenceLon = fc.Longitude;
                                    var R = 6371; // Radius of the earth in km
                                    var dLat = deg2rad (currentLocation.Coordinate.Latitude - fenceLat);  // deg2rad below
                                    var dLon = deg2rad (currentLocation.Coordinate.Longitude - fenceLon);
                                    var a =
                                        Math.Sin (dLat / 2) * Math.Sin (dLat / 2) +
                                        Math.Cos (deg2rad (fenceLat)) * Math.Cos (deg2rad (currentLocation.Coordinate.Latitude)) *
                                        Math.Sin (dLon / 2) * Math.Sin (dLon / 2);
                                    var c = 2 * Math.Atan2 (Math.Sqrt (a), Math.Sqrt (1 - a));
                                    var d = R * c;
                                    if (d <= 0.25) {
                                        string result = locSvc.CheckIn (sessionKey, fc.LocationID);
                                        if (result == "Success") {
                                            absTitle = "Success";
                                            absResult = "Check In Successful";
                                            btnCheckIn.SetTitle ("CHECK OUT", UIControlState.Normal);
                                            break;
                                        } else {
                                            absTitle = "Error";
                                            absResult = "An Unexpected Error Occurred. Try Again";
                                        }
                                    }
                                }
                            } else if (btnCheckIn.Title (UIControlState.Normal) == "Check Out") {
                                string result = locSvc.CheckOutWithoutLocation (sessionKey);
                                if (result == "Success") {
                                    absTitle = "Success";
                                    absResult = "Check Out Successful";
                                    btnCheckIn.SetTitle ("CHECK IN", UIControlState.Normal);
                                } else {
                                    absTitle = "Error";
                                    absResult = "An Unexpected Error Occurred. Try Again";
                                }
                            }
                            UIAlertView _error = new UIAlertView (absTitle, absResult, null, "Ok", null);
                            _error.Show ();
                        } else if (groupID > 2 && groupID <= 7) {
                            string absResult = "";
                            string absTitle = "";
                            if (btnCheckIn.Title (UIControlState.Normal) == "Check In") {
                                string result = locSvc.CheckInWithLocation (sessionKey, -1, currentLocation.Coordinate.Latitude, currentLocation.Coordinate.Longitude);
                                if (result == "Success") {
                                    absTitle = "Success";
                                    absResult = "Check In Successful";
                                    btnCheckIn.SetTitle ("CHECK OUT", UIControlState.Normal);
                                } else {
                                    absTitle = "Error";
                                    absResult = "An Unexpected Error Occurred. Try Again";
                                }
                            } else if (btnCheckIn.Title (UIControlState.Normal) == "Check Out") {
//.........这里部分代码省略.........
开发者ID:jdrharding,项目名称:ROMPiOS,代码行数:101,代码来源:CheckInViewController.cs


注:本文中的CLLocationManager.StartUpdatingHeading方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。