StartTimer() 공개 메소드

public StartTimer ( CLLocationManager manager ) : void
manager CLLocationManager
리턴 void
예제 #1
0
        public static void GetCurrentLocation(TripLog currentLog, bool isStart, NSAction onFound)
        {
            if (!CLLocationManager.LocationServicesEnabled)
            {
                currentLog.SetLocation(-1, -1, isStart);

                onFound();
            }

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

            locationDelegate = new MyLocationManagerDelegate();

            locationDelegate.OnLocationError += delegate(NSError error) {
                currentLog.SetLocation(-1, -1, isStart);
                locationManager.StopUpdatingLocation();
                onFound();
            };

            locationDelegate.OnLocationUpdate += delegate(CLLocation location) {
                currentLog.SetLocation(location.Coordinate.Latitude, location.Coordinate.Longitude, isStart);
                locationManager.StopUpdatingLocation();

                onFound();
            };

            locationManager.Delegate = locationDelegate;


            locationManager.StartUpdatingLocation();
            locationDelegate.StartTimer(locationManager);
            Util.TurnOnNetworkActivity();
        }
        public void UpdateNearestList()
        {
            if (!CLLocationManager.LocationServicesEnabled)
            {
                alert = new UIAlertView("No Location Available", "Sorry, no location services are available. However, you may still be able to use the timer and map.", null, "Ok");
                alert.Show();
                updating = false;
                return;
            }

            if (locationManager == null)
            {
                locationManager = new CLLocationManager();
                locationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;



                locationDelegate = new MyLocationManagerDelegate();
                locationDelegate.OnLocationError += delegate(NSError error) {
                    alert = new UIAlertView("No Location Available", "Sorry, but there was an error finding your location. However, you may still be able to use the timer and map.", null, "Ok");
                    alert.Show();

                    updating = false;
                };

                locationDelegate.OnHeadingUpdate += delegate(CLHeading heading) {
                    Util.Log("heading: " + heading.TrueHeading);

                    UpdateCompass((int)heading.TrueHeading);
                };
                locationDelegate.OnLocationUpdate += delegate(CLLocation location) {
                    CLLocationCoordinate2D coord = location.Coordinate;
#if DEBUG
                    coord = Locations.BanksideMix;
#endif


                    var bikeList = BikeLocation.FindClosestBikeList(coord.Latitude, coord.Longitude);

                    RootElement root = new RootElement("Nearest Bikes");
                    HasList = true;



                    Section section = new Section();
                    int     i       = 0;

                    if (location.HorizontalAccuracy > 100)
                    {
                        section.Add(new StringElement("Low GPS accuracy!")
                        {
                            Alignment = UITextAlignment.Center
                        });
                    }



                    foreach (BikeLocation bike in bikeList)
                    {
                        var localBike = bike;



                        section.Add(new BikeElement(localBike, delegate {
                            Util.AppDelegate.SetFocusOnLocation(localBike);
                        }));



                        i++;
                        if (i > 20)
                        {
                            break;
                        }
                    }

                    root.Add(section);


                    Root = root;

                    updating = false;

                    BikeLocation.LogSearch();
                };
                locationManager.Delegate = locationDelegate;
            }

            locationManager.StartUpdatingLocation();
            locationDelegate.StartTimer(locationManager);
            Util.TurnOnNetworkActivity();
        }
예제 #3
0
        public static void GetCurrentLocation(TripLog currentLog, bool isStart, NSAction onFound)
        {
            if (!CLLocationManager.LocationServicesEnabled)
            {
                currentLog.SetLocation(-1, -1, isStart);

                onFound();
            }

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

            locationDelegate = new MyLocationManagerDelegate();

            locationDelegate.OnLocationError += delegate(NSError error) {

                currentLog.SetLocation(-1, -1, isStart);
                locationManager.StopUpdatingLocation();
                onFound();
            };

            locationDelegate.OnLocationUpdate += delegate(CLLocation location) {

                currentLog.SetLocation(location.Coordinate.Latitude, location.Coordinate.Longitude, isStart);
                locationManager.StopUpdatingLocation();

                onFound();

            };

            locationManager.Delegate = locationDelegate;

            locationManager.StartUpdatingLocation();
            locationDelegate.StartTimer(locationManager);
            Util.TurnOnNetworkActivity();
        }