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


C# CLLocationManager.StopUpdatingLocation方法代码示例

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


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

示例1: FinishedLaunching

        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            global::Xamarin.FormsMaps.Init();

            locationManager = new CLLocationManager
            {
                DesiredAccuracy = CLLocation.AccuracyBest
            };

            locationManager.Failed += (object sender, NSErrorEventArgs e) =>
            {
                var alert = new UIAlertView(){ Title = "Location manager failed", Message = "The location updater has failed" };
                alert.Show();
                locationManager.StopUpdatingLocation();
            };

            locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) =>
            {
                var newloc = string.Format("{0},{1}", e.Locations[0].Coordinate.Longitude, e.Locations[0].Coordinate.Latitude);
                App.Self.ChangedClass.BroadcastIt("location", newloc);
            };

            locationManager.StartUpdatingLocation();

            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
开发者ID:nodoid,项目名称:GPSPush,代码行数:29,代码来源:AppDelegate.cs

示例2: FinishedLaunching

		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			var what = new EntryElement ("What ?", "e.g. pizza", String.Empty);
			var where = new EntryElement ("Where ?", "here", String.Empty);

			var section = new Section ();
			if (CLLocationManager.LocationServicesEnabled) {
				lm = new CLLocationManager ();
				lm.LocationsUpdated += delegate (object sender, CLLocationsUpdatedEventArgs e) {
					lm.StopUpdatingLocation ();
					here = e.Locations [e.Locations.Length - 1];
					var coord = here.Coordinate;
					where.Value = String.Format ("{0:F4}, {1:F4}", coord.Longitude, coord.Latitude);
				};
				section.Add (new StringElement ("Get Current Location", delegate {
					lm.StartUpdatingLocation ();
				}));
			}

			section.Add (new StringElement ("Search...", async delegate {
				await SearchAsync (what.Value, where.Value);
			}));

			var root = new RootElement ("MapKit Search Sample") {
				new Section ("MapKit Search Sample") { what, where },
				section
			};
			window.RootViewController = new UINavigationController (new DialogViewController (root, true));
			window.MakeKeyAndVisible ();
			return true;
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:33,代码来源:AppDelegate.cs

示例3: Failed

 public override void Failed (CLLocationManager manager, NSError error)
 {
     if (error.Code == (int)CLError.Denied) {
         Console.WriteLine ("Access to location services denied");
         
         manager.StopUpdatingLocation ();
         manager.Delegate = null;
     }
 }
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:9,代码来源:LocationHelper.cs

示例4: Failed

        public override void Failed(CLLocationManager manager, NSError error)
        {
            manager.StopUpdatingLocation ();
            Util.TurnOffNetworkActivity();
            StopTimer();

            if (OnLocationError != null)
            {
                OnLocationError(error);
            }
        }
开发者ID:nicwise,项目名称:londonbikeapp,代码行数:11,代码来源:NearDialogViewController.cs

示例5: UpdateLocation

        static public void UpdateLocation (CLLocation newLocation, CLLocationManager locManager, GetLocationActions locActions, UITextField textField)
        {
            Console.WriteLine(newLocation.Coordinate.Longitude.ToString () + "º");
            Console.WriteLine(newLocation.Coordinate.Latitude.ToString () + "º");

            //FireEvent
            OnLocationChanged (textField, locActions, newLocation.Coordinate.Latitude.ToString (), newLocation.Coordinate.Longitude.ToString ());

            if (CLLocationManager.LocationServicesEnabled)
                locManager.StopUpdatingLocation ();
            if (CLLocationManager.HeadingAvailable)
                locManager.StopUpdatingHeading ();
        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:13,代码来源:TrafficDialogViewController.cs

示例6: Main

	static void Main ()
	{
		NSApplication.Init ();
		
		var locationManager = new CLLocationManager ();
		locationManager.UpdatedLocation += (sender, args) => {
			var coord = args.NewLocation.Coordinate;
			Console.WriteLine ("At {0}", args.NewLocation.Description ());
			locationManager.StopUpdatingLocation ();

			Console.WriteLine (googleUrl, coord.Latitude, coord.Longitude);
			NSWorkspace.SharedWorkspace.OpenUrl (new Uri (String.Format (googleUrl, coord.Latitude, coord.Longitude)));
			
		};
		locationManager.StartUpdatingLocation ();
		NSRunLoop.Current.RunUntil (NSDate.DistantFuture);
	}
开发者ID:xamarin,项目名称:mac-samples,代码行数:17,代码来源:locator.cs

示例7: ViewDidAppear

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

			CLLocationManager locationManager = new CLLocationManager ();
			locationManager.LocationsUpdated += (sender, e) => {
				CLLocation location = locationManager.Location;
				FlurryAgent.SetLocation (
					location.Coordinate.Latitude,
					location.Coordinate.Longitude,
					(float)location.HorizontalAccuracy,
					(float)location.VerticalAccuracy);
				locationManager.StopUpdatingLocation ();

				Debug.WriteLine ("Logged location.");
			};
			locationManager.StartUpdatingLocation ();
		}
开发者ID:Mazooma-Interactive-Games,项目名称:Flurry.Analytics,代码行数:18,代码来源:RootViewController.cs

示例8: ViewDidAppear

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

            locationManager = new CLLocationManager ();
            locationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;

            locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {

                poiData = GeoUtils.GetPoiInformation(e.Locations [e.Locations.Length -1], 20);
                var js = "World.loadPoisFromJsonData(" + this.poiData.ToString() + ")";
                this.arView.CallJavaScript(js);

                locationManager.StopUpdatingLocation();
                locationManager.Delegate = null;
            };
            locationManager.StartUpdatingLocation ();
        }
开发者ID:ancchaimongkon,项目名称:wikitude-xamarin,代码行数:18,代码来源:ApplicationModelARViewController.cs

示例9: LocationManager

        LocationManager()
        {
            locationManager = new CLLocationManager();
            locationManager.DesiredAccuracy = CLLocation.AccuracyKilometer; 

            locationManager.LocationsUpdated += (sender, e) => {
	            var loc  = e.Locations;
                if (loc[0] != null) 
                {
                    return;
                }

                if (stopped)
                {
                    return;
                }

                _currentLocationAquired = loc[0];

                locationManager.StopUpdatingLocation();
                stopped = false;
            };
        }
开发者ID:TheJaniceTong,项目名称:Judo-Xamarin,代码行数:23,代码来源:LocationManager.cs

示例10: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			
			UIButton btnIpConnect = UIButton.FromType (UIButtonType.InfoLight);
			btnIpConnect.Title (UIControlState.Normal);
			btnIpConnect.TouchDown += OnIpConnect;
			this.NavigationItem.RightBarButtonItem = new UIBarButtonItem (btnIpConnect);
			
			
			//this.View.BringSubviewToFront (this.scrollContainer);
			
			scrollContainer.ContentSize = new SizeF (this.View.Bounds.Size.Width, this.View.Bounds.Size.Height - 44);
			
			_locationManager = new CLLocationManager ();
			_locationManager.DesiredAccuracy = CLLocation.AccuracyBest;


			// deprecated in ios 6.0
			_locationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
				_userCoords = e.NewLocation.Coordinate;
				// get the distance from here to Löwenbräukeller
				var distance = e.NewLocation.DistanceFrom (new CLLocation (LATITUDE_LBK, LONGITUDE_LBK));
				string distanceText = Locale.Format("Bis zum Ziel ca: {0}", Util.DistanceToString (distance));
				txtDistance.Text = distanceText;
				if (CLLocationManager.LocationServicesEnabled) {
					_locationManager.StopUpdatingLocation ();
				}
			};

			// for ios 6.0
			_locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {

				CLLocation recentLocation = e.Locations[e.Locations.Length - 1];
				_userCoords = recentLocation.Coordinate;
				// get the distance from here to Löwenbräukeller
				var distance = recentLocation.DistanceFrom (new CLLocation (LATITUDE_LBK, LONGITUDE_LBK));
				string distanceText = Locale.Format("Bis zum Ziel ca: {0}", Util.DistanceToString (distance));
				txtDistance.Text = distanceText;
				if (CLLocationManager.LocationServicesEnabled) {
					_locationManager.StopUpdatingLocation ();
				}
			};
			
			txtPlan.TextColor = UIColor.White;
			txtPlan.BackgroundColor = UIColor.Clear;
			
			scrollContainer.SetLabelsTextColor (UIColor.White);
			scrollContainer.SetLabelsBGColor (UIColor.Clear);
			
			txtAddress.Text = "Löwenbräukeller Gastronomie GmbH\n" +
							"Nymphenburgerstrasse 2\n" + 
							"80335 München";
			txtPhone.Text = "Tel.: +49 (0)89 - 547 2669-0";
			txtFax.Text = "Fax: +49 (0)89 - 547 2669-25";
			txtMail.Text = EMAIL;
		
			
			btnPhone.SetImage (UIImage.FromBundle ("image/buttons/phone.png"), UIControlState.Normal);
			btnPhone.TouchUpInside += delegate {
				var phoneCaller = new PhoneCaller ();
				phoneCaller.Call (PHONE_NUMBER);
			};
			
			btnMail.SetImage (UIImage.FromBundle ("image/buttons/mail.png"), UIControlState.Normal);
			/*
			btnMail.TouchDown += delegate {
				var alert = new UIAlertView (EMAIL, "", null, Locale.GetText ("Cancel"), Locale.GetText ("Mailen"));
				alert.Clicked += (sender, e) => {
					if (e.ButtonIndex == 1) {
						Util.OpenUrl ("mailto:" + EMAIL);
					}
				};
				alert.Show ();
			};
			*/
			btnMail.TouchUpInside += (o, e) =>
			{
				if (MFMailComposeViewController.CanSendMail) {
					var mail = new MFMailComposeViewController ();
					mail.SetToRecipients (new string[] { EMAIL});
					mail.SetSubject ("Löwenbräu");
					mail.SetMessageBody ("", false);
					mail.Finished += HandleMailFinished;
					this.PresentViewController (mail, true, null);
				} 
			};
			
			btnMap.SetImage (UIImage.FromBundle ("image/buttons/map.png"), UIControlState.Normal);
			btnMap.TouchUpInside += delegate {
				this.NavigationController.PushViewController (new LbkMapViewController (_lbkCoords, _userCoords), true);
			};
			
			/*
			lblImpressum = new UILabel (){
				TextColor = UIColor.White,
				Text ="Impressum",
				Font = UIFont.BoldSystemFontOfSize (17f),
				BackgroundColor = UIColor.Clear,
//.........这里部分代码省略.........
开发者ID:bpug,项目名称:LbkIos,代码行数:101,代码来源:KontaktViewController.cs

示例11: RequestLocationServicesAuthorization

		public void RequestLocationServicesAuthorization ()
		{
			locationManager = new CLLocationManager ();
			locationManager.Failed += delegate {
				locationManager.StopUpdatingLocation ();
			};
			locationManager.LocationsUpdated += delegate {
				locationManager.StopUpdatingLocation ();
			};
			locationManager.AuthorizationChanged += delegate (object sender, CLAuthorizationChangedEventArgs e) {
				CheckLocationServicesAuthorizationStatus (e.Status);
			};
			locationManager.StartUpdatingLocation ();
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:14,代码来源:PrivacyClassesTableViewController.cs

示例12: UpdatedLocation

            /// <summary>
            /// Whenever the GPS sends a new location, update text in label
            /// and increment the 'count' of updates AND reset the map to that location 
            /// </summary>
            public override void UpdatedLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
            {
                //MKCoordinateSpan span = new MKCoordinateSpan(0.2,0.2);
                //MKCoordinateRegion region = new MKCoordinateRegion(newLocation.Coordinate,span);
                //_appd.mylocation = newLocation;
                //_mapview.SetRegion(region, true);
                double distanceToConference = MapHelper.Distance (new Coordinate(_appd.ConferenceLocation), new Coordinate(newLocation.Coordinate), UnitsOfLength.Miles); //TODO: Make this Configurable
                string distanceMessage  = "XUnitsFromConference".GetText();
                _appd.labelDistance.TextAlignment = UITextAlignment.Center;
                _appd.labelDistance.Text = String.Format(distanceMessage, Math.Round(distanceToConference,0));
                Debug.WriteLine("Distance: {0}", distanceToConference);

                // only use the first result
                manager.StopUpdatingLocation();
            }
开发者ID:megsoftconsulting,项目名称:MonkeySpace,代码行数:19,代码来源:MapViewController.cs

示例13: UpdatedLocation

            /// <summary>
            /// Whenever the GPS sends a new location, update text in label
            /// and increment the 'count' of updates AND reset the map to that location 
            /// </summary>
            public override void UpdatedLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
            {
                double distanceToConference = MapHelper.Distance (new Coordinate(mapVC.ConferenceLocation.Location.To2D()), new Coordinate(newLocation.Coordinate), UnitsOfLength.Miles);
                mapVC.labelDistance.TextAlignment = UITextAlignment.Center;
                mapVC.labelDistance.Text = String.Format("{0} miles from MonkeySpace!", Math.Round(distanceToConference,0));
                Debug.WriteLine("Distance: {0}", distanceToConference);

                // only use the first result
                manager.StopUpdatingLocation();
            }
开发者ID:bramleffers,项目名称:MonkeySpace,代码行数:14,代码来源:MapViewController.cs

示例14: UpdatedLocation

			public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
			{
				attempts++;
				
				if (newLocation.Timestamp.SecondsSinceReferenceDate < 10 ||
				    attempts >= 3 ||
				    newLocation.HorizontalAccuracy < 200f)
				{
					//System.Threading.Thread.Sleep(100000);
					manager.StopUpdatingLocation ();
					if (callback != null)
						callback (newLocation);
				}
			}
开发者ID:21Off,项目名称:21Off,代码行数:14,代码来源:Util.cs

示例15: UpdatedLocation

	    public override void UpdatedLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
	    {
			Console.WriteLine("Accuracy: " + newLocation.HorizontalAccuracy +", " + newLocation.VerticalAccuracy);
			_controller.SetInfo(string.Format("Funnet innenfor {0}m/{1}m radius", newLocation.HorizontalAccuracy, newLocation.VerticalAccuracy));
			_controller.Latitude = newLocation.Coordinate.Latitude.ToString();
			_controller.Longitude = newLocation.Coordinate.Longitude.ToString();
		
			SetLocation(newLocation, "Din posisjon", "Trykk ned og flytt for å endre posisjon.");

			//Stop updating location if this is close enough...
			if(newLocation.HorizontalAccuracy <= CLLocation.AccuracyHundredMeters &&
			   newLocation.VerticalAccuracy <= CLLocation.AccuracyHundredMeters)
			{
				manager.StopUpdatingLocation();
	   		}
		}		
开发者ID:TheGiant,项目名称:Jaktloggen,代码行数:16,代码来源:FieldLocationScreen.xib.cs


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