Пример #1
0
		private void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
		{
			if (LocationUpdated != null)
				LocationUpdated(GetLocationResult(), null);

			UpdateLocation(e.Locations[e.Locations.Length - 1]);
		}
        void LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            CLLocation lastLocation = e.Locations[e.Locations.Length - 1];

            SetLastKnownLocation(lastLocation);

            if (Regions.Count > 20 && locationManager.MonitoredRegions.Count == 20)
            {
                RecalculateRegions();
            }
            else
            {
                //Check any current monitored regions not in loaded persistent regions and stop monitoring them
                foreach (CLCircularRegion region in locationManager.MonitoredRegions)
                {
                    if (!Regions.ContainsKey(region.Identifier))
                    {
                        locationManager.StopMonitoring(region);
                        string message = string.Format("{0} - Stopped monitoring region {1} wasn't in persistent loaded regions", CrossGeofence.Id, region.Identifier);
                        System.Diagnostics.Debug.WriteLine(message);
                    }
                }
            }

            System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}: {2},{3}", CrossGeofence.Id, "Location update", lastLocation.Coordinate.Latitude, lastLocation.Coordinate.Longitude));
        }
        void OnLocMgrLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            //if (CustomMapView != null && CustomMapView.IsNavigating)
            //{
            //    CLLocation newLocation = e.Locations[e.Locations.Length - 1];

            //    if (lastUserLocation != null)
            //    {
            //        double dist = newLocation.DistanceFrom(lastUserLocation);

            //        if (dist > 10)
            //        {
            //            //TODO: podonnell: There is an issue on the simulator whereby calculating the route details resets the user location
            //            //it is then updated again by the location manager which calls this method again and results in an infinite loop
            //            System.Diagnostics.Debug.WriteLine(dist);

            //            //we have moved over 10m => update route
            //            sourceMapItem = MKMapItem.MapItemForCurrentLocation();
            //            CalculateRouteDetails(false);
            //        }
            //    }

            //    lastUserLocation = newLocation;
            //}
        }
Пример #4
0
 void _significantLocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     if (_lastLocation < DateTime.Now - TimeSpan.FromMinutes(15))
     {
         SendReminderNotification();
     }
 }
Пример #5
0
        async void LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            await ServiceLayer.SharedInstance.InitalizeSettings();

            CurrentLocation = e.Locations.First();
            UpdateDeviceData();
        }
        private async void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            //currentLocation = new CLLocationCoordinate2D(e.Locations[0].Coordinate.Latitude, e.Locations[0].Coordinate.Longitude);

            //CameraPosition cameraPosition = CameraPosition.FromCamera(e.Locations[0].Coordinate, 15);
            //googleMap.Animate(cameraPosition);

            //pickuplocationLatLng = new CLLocationCoordinate2D(e.Locations[0].Coordinate.Latitude, e.Locations[0].Coordinate.Longitude);
            //pickupButtonBar.SetTitle("Fetching Address...", UIControlState.Normal);

            //pickupAddress = await FindCordinateAddress(pickuplocationLatLng);
            //pickupButtonBar.SetTitle(pickupAddress, UIControlState.Normal);



            // Updated to fix on physical devces.
            currentLocation = new CLLocationCoordinate2D(e.Locations[0].Coordinate.Latitude, e.Locations[0].Coordinate.Longitude);

            if (!drawonce)
            {
                CameraPosition cameraPosition = CameraPosition.FromCamera(e.Locations[0].Coordinate, 15);
                googleMap.Animate(cameraPosition);
                drawonce = true;

                pickuplocationLatLng = new CLLocationCoordinate2D(e.Locations[0].Coordinate.Latitude, e.Locations[0].Coordinate.Longitude);
                pickupButtonBar.SetTitle("Fetching Address...", UIControlState.Normal);

                pickupAddress = await FindCordinateAddress(pickuplocationLatLng);

                pickupButtonBar.SetTitle(pickupAddress, UIControlState.Normal);
            }
        }
Пример #7
0
        /// <summary>
        /// Handles location updated
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void _mgr_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            // Take the last known location
            var nativeLocation = e.Locations[e.Locations.Length - 1];

            // From object
            var coordinates = new Coordinate2D()
            {
                IsValid   = nativeLocation.Coordinate.IsValid(),
                Latitude  = nativeLocation.Coordinate.Latitude,
                Longitude = nativeLocation.Coordinate.Longitude
            };
            var gpsLocation = new GpsLocation()
            {
                Altitude           = nativeLocation.Altitude,
                Coordinates        = coordinates,
                Heading            = nativeLocation.Course,
                HorizontalAccuracy = nativeLocation.HorizontalAccuracy,
                Speed            = nativeLocation.Speed,
                TimeStamp        = utils.Conversion.NSDateToDateTime(nativeLocation.Timestamp),
                VerticalAccuracy = nativeLocation.VerticalAccuracy
            };
            var eventArgs = new LocationUpdatedEventArgs()
            {
                Location = gpsLocation
            };

            // Trigger event
            LocationUpdated(this, eventArgs);
        }
Пример #8
0
        void LocationUpdated(object sender, EventArgs e)
        {
            foreach (UIView view in virtualDropContent.Subviews)
            {
                view.RemoveFromSuperview();
            }

            CLLocationsUpdatedEventArgs locArgs = e as CLLocationsUpdatedEventArgs;
            var currentLocation = locArgs.Locations[locArgs.Locations.Length - 1];

            for (int i = 0; i < mDrops.Count; i++)
            {
                var drop = mDrops[i];

                if (!drop.IsVisibilityByUser())
                {
                    continue;
                }

                CLLocation pointB      = new CLLocation(drop.Location_Lat, drop.Location_Lnt);
                var        distanceToB = pointB.DistanceFrom(currentLocation);

                if (distanceToB < Constants.PURCHASE_DISTANCE)
                {
                    VisibleDrop(drop, currentLocation);
                }
            }
        }
Пример #9
0
        async void _locationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            _newLocationRequestAvailable = true;
            if (this.IsListening)
            {
                if ((e.Locations != null) && (e.Locations.Length > 0))
                {
                    var      location = e.Locations[e.Locations.Length - 1];
                    Position position = ToPosition(location);
                    this.PositionChanged(sender, new PositionEventArgs(position));
                }

                _locationManager.StopUpdatingLocation();
                if ((_includeHeading) && (CLLocationManager.HeadingAvailable))
                {
                    _locationManager.StopUpdatingHeading();
                }

                await Task.Delay((int)_minTime);

                _locationManager.StartUpdatingLocation();
                if (_includeHeading)
                {
                    _locationManager.StartUpdatingHeading();
                }
            }
        }
Пример #10
0
 private void OnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     foreach (CLLocation location in e.Locations)
     {
         UpdatePosition(location);
     }
 }
Пример #11
0
    void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
    {
        locationManager.StopUpdatingLocation();
        var l = e.Locations[0].Coordinate;


        coder = new CLGeocoder();
        coder.ReverseGeocodeLocation(new CLLocation(l.Latitude, l.Longitude), (placemarks, error) =>
        {
            var city    = placemarks[0].Locality;
            var state   = placemarks[0].AdministrativeArea;
            var weather = new XAMWeatherFetcher(city, state);

            var result = weather.GetWeather();

            InvokeOnMainThread(() =>
            {
                info.Text       = result.Temp + "°F " + result.Text;
                latLong.Text    = l.Latitude + ", " + l.Longitude;
                cityField.Text  = result.City;
                stateField.Text = result.State;

                getWeatherButton.Enabled  = true;
                getLocationButton.Enabled = true;
            });
        });
    }
        private void OnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs args)
        {
            var currentLocation = args.Locations[args.Locations.Length - 1];

            _latitude  = currentLocation.Coordinate.Latitude;
            _longitude = currentLocation.Coordinate.Longitude;
        }
Пример #13
0
        void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            var currentLocation = e.Locations[0];

            this.lastLocation = new ClientLocation {
                Latitude = currentLocation.Coordinate.Latitude, Longitude = currentLocation.Coordinate.Longitude, Altitude = currentLocation.Altitude
            };
        }
Пример #14
0
 private void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     LocationManager.StopUpdatingLocation();
     currentPOI.Name      = "Exactly here...";
     currentPOI.Latitude  = e.Locations[0].Coordinate.Latitude;
     currentPOI.Longitude = e.Locations[0].Coordinate.Longitude;
     waitEvent.Set();
 }
		void OnLocationsUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			Region = new MKCoordinateRegion(LocationManager.Location.Coordinate, new MKCoordinateSpan(0.1, 0.1));

			var handler = LocationChanged;
			if (handler != null)
				handler (this, EventArgs.Empty);
		}
Пример #16
0
        private void LocationManagerOnLocationsUpdated(
            object sender,
            CLLocationsUpdatedEventArgs e)
        {
            var location = e.Locations[e.Locations.Length - 1];

            OnLocationChanged(location);
        }
Пример #17
0
 private static void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     if (LocationUpdated != null)
     {
         LocationUpdated(sender, e);
     }
     UpdateLocation(e.Locations[e.Locations.Length - 1]);
 }
Пример #18
0
        private void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            CLLocation          current      = e.Locations[0];
            Position            position     = new Position(current.Coordinate.Latitude, current.Coordinate.Longitude);
            PositionUpdatedArgs positionArgs = new PositionUpdatedArgs();

            positionArgs.position = position;
            OnPositionUpdated(positionArgs);
        }
Пример #19
0
        protected virtual void LocationIsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            var loc = e.Locations.Last();

            if (loc != null && CanGetLocation)
            {
                Location = loc.GetGeoLocationFromCLLocation();
            }
        }
Пример #20
0
 void OnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     // Pass location updates to the map view.
     foreach (var l in e.Locations)
     {
         Console.WriteLine("Location (Floor {0}): {1}", l.Floor, l);
         UpdateViewWithLocation(l);
     }
 }
Пример #21
0
        void OnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            locationMessage.Text = locationManager.Location.ToString();

            //MapView
            MKCoordinateRegion region = new MKCoordinateRegion(locationManager.Location.Coordinate, new MKCoordinateSpan(0.1, 0.1));

            mapView.SetRegion(region, true);
        }
Пример #22
0
 /*
  * Handler for Location updates
  */
 public virtual void LocationHandler(object sender, CLLocationsUpdatedEventArgs e)
 {
     if (LocationUpdated != null)
     {
         //fire event LocationUpdated with the location information as parameters
         LocationEventArgs arg = new LocationEventArgs(e.Locations[e.Locations.Length - 1].Coordinate.Longitude, e.Locations[e.Locations.Length - 1].Coordinate.Latitude);
         LocationUpdated(this, arg);
     }
 }
        /// <summary>
        /// Called when we receive new location data.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void ResolveLocationChange(object sender, CLLocationsUpdatedEventArgs e)
        {
            var len = e.Locations.Length;

            if (len > 0)
            {
                lastKnownLocation = new IosLocation(e.Locations[len - 1]);
                Log.D(this, "New " + lastKnownLocation);
            }
        }
 void OnLocationUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     if (LocationUpdated != null)
     {
         CLLocation location = e.Locations[e.Locations.Length - 1];
         LocationUpdated(this, new LocationUpdatedEventArgs {
             Location = location
         });
     }
 }
Пример #25
0
        private void HandleLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            var location = e.Locations.Last ();

            _stopwatch.Restart ();
            _places = _placeService.GetPlaces (location.Coordinate.Latitude, location.Coordinate.Longitude);
            _stopwatch.Stop ();

            TableView.ReloadData ();
        }
Пример #26
0
        private void LocationUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            if (!(e?.Locations?.Length > 0))
            {
                return;
            }

            lastLoc = e.Locations[e.Locations.Length - 1];
            var suppressAsync = GetFromServer();
        }
Пример #27
0
        private void HandleLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            _locMgr.StopUpdatingLocation();

            if (_locationRecieved != null)
            {
                CLLocation loc = e.Locations == null ? null : e.Locations [e.Locations.Length - 1];
                _locationRecieved.TrySetResult(loc);
            }
        }
Пример #28
0
        void GPS_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            if (e.Locations.Length > 0)
            {
                lblLatitude.Text  = e.Locations[0].Coordinate.Latitude.ToString("0.00000000");
                lblLongitude.Text = e.Locations[0].Coordinate.Longitude.ToString("0.00000000");

                //GPS.StopUpdatingLocation();
            }
        }
Пример #29
0
        void OnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            Region = new MKCoordinateRegion(LocationManager.Location.Coordinate, new MKCoordinateSpan(0.1, 0.1));

            var handler = LocationChanged;

            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
        }
Пример #30
0
        private void UpdateMap(CLLocationsUpdatedEventArgs e)
        {
            var location = e.Locations.LastOrDefault();

            if (location != null)
            {
                map.CenterCoordinate = location.Coordinate;

                SetMapRegion(location.Coordinate);
            }
        }
        private void LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            if (e.Locations.Length > 0)
            {
                JsonArray jsonArray = PoiGenerator.GeneratePoiInformation(e.Locations[0].Coordinate.Latitude, e.Locations[0].Coordinate.Longitude);
                architectView.CallJavaScript("World.loadPoisFromJsonData(" + jsonArray.ToString() + ")"); // Triggers the loadPoisFromJsonData function

                locationManager.StopUpdatingLocation();
                locationManager.LocationsUpdated -= LocationsUpdated;
            }
        }
Пример #32
0
        void LocationManager_InitialLocationUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            LocationManager_LocationsUpdated(sender, e);

            // kick the pump
            this.dataPump.Start();

            // rewire the notifications
            this.locationManager.LocationsUpdated -= LocationManager_InitialLocationUpdated;
            this.locationManager.LocationsUpdated += LocationManager_LocationsUpdated;
        }
Пример #33
0
		void HandleLocationsUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			var location = e.Locations [e.Locations.Length - 1];
			DateTime time = DateTime.SpecifyKind (location.Timestamp, DateTimeKind.Unspecified);
			var args = new LocationEventArgs (location.Coordinate.Latitude, location.Coordinate.Longitude, time, location.Speed, location.Course, 0, location.Altitude);
			OnLocationChanged (args);

			if (_interval != TimeSpan.Zero && _timer == null) {
				_manager.StopUpdatingLocation ();
				_timer = new Timer (new TimerCallback(TurnOnLocationManager), null, (int)_interval.TotalMilliseconds, 0);
			}
		}
Пример #34
0
        private void LocationManager_OnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs args)
        {
            foreach (var loc in args.Locations)
            {
                var geoposition = loc.ToLocalGeoposition();

                this.LastKnownPosition = geoposition;
                this.PositionChanged?.Invoke(this, new PositionChangedEventArgs(geoposition));

                loc?.Dispose();
            }
        }
Пример #35
0
        /// <summary>
        /// The location manager on locations updated.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="clLocationsUpdatedEventArgs">
        /// The locations updated event args.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        private static void LocationManagerOnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs clLocationsUpdatedEventArgs)
        {
            if (locationChanged == null)
            {
                StopMonitoring();
                return;
            }

            foreach (var location in clLocationsUpdatedEventArgs.Locations)
            {
                locationChanged(sender, location.GetCoordinates());
            }
        }
		void OnLocationsUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			currentLocation = e.Locations.LastOrDefault ();

			if (pin != null)
				return;

			pin = new MKPointAnnotation ();
			pin.SetCoordinate (currentLocation.Coordinate);

			map.AddAnnotation (pin);
			map.ShowAnnotations (new [] { pin }, false);

			locationManager.StopUpdatingLocation ();
		}
Пример #37
0
		void OnLocationsUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			locationCoordinate = e.Locations.Last ().Coordinate;

			// Load the HTML for displaying the Google map from a file and replace the
			// format placeholders with our location data
			string path = NSBundle.MainBundle.PathForResource ("HTMLFormatString","html");
			var formatString = File.OpenText (path).ReadToEnd ();
			var htmlString = String.Format (
				formatString,
				locationCoordinate.Latitude,locationCoordinate.Longitude,
				latitudeRangeForLocation (e.Locations.Last ()), longitudeRangeForLocation (e.Locations.Last ()));
		
			webView.MainFrame.LoadHtmlString (htmlString, null);
	
			locationLabel.StringValue = string.Format ("{0}, {1}", locationCoordinate.Latitude, locationCoordinate.Longitude);
			accuracyLabel.StringValue = e.Locations.Last ().HorizontalAccuracy.ToString ();
		}
Пример #38
0
		private void HandleLocationsUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			_locMgr.StopUpdatingLocation();

			if (_locationRecieved != null) {
				CLLocation loc = e.Locations == null ? null : e.Locations [e.Locations.Length - 1];
				_locationRecieved.TrySetResult (loc);
			}
		}
		/// <summary>
		/// Gets called by the location manager if the current location has changed.
		/// </summary>
		/// <param name="sender">Sender.</param>
		/// <param name="e">location arguments</param>
		async void HandleLocationsUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			// Do not use the UserLocation property here. It will not be updated while running in the background.
			var location = e.Locations [e.Locations.Length - 1];

			// Get a readable direction for the current course.
			string direction = Helpers.GetDirectionForCourse (location.Course);

			// Try to find a human readable location description.
			string street = await Helpers.GetStreetForLocation (this.geoCoder, location);

			// Search for restaurants near our location.
			string restaurant = await Helpers.FindNearestRestaurantAsync (location);

			// Constantly output to the console so we see something is going on.
			Console.WriteLine (string.Format ("Coordinates: {0:F3} / {1:F3}", location.Coordinate.Latitude, location.Coordinate.Longitude));

			bool streetChanged = previousStreet != street;
			bool directionChanged = previousDirection != direction;
			bool restaurantChanged = previousRestaurant != restaurant && !string.IsNullOrWhiteSpace (restaurant);

			// If street, direction or restaurant changes, play an audio cue.
			if (streetChanged || directionChanged || restaurantChanged)
			{
				previousStreet = street;
				previousDirection = direction;
				previousRestaurant = restaurant;

				// Update UI.
				var currentLocation = string.Format ("Street: {0}, Direction: {1}", street, direction);
				if (this.updateUi)
				{
					lblLocation.Text = currentLocation;
				}

				// Speech synthesis can be used in the background.
				string speakLocation = streetChanged ? string.Format ("You are now on {0} going {1}.", street, direction) : string.Format ("You're heading {0}.", direction);
				if (restaurantChanged)
				{
					speakLocation += string.Format ("Check out {0} if you're hungry!", restaurant);
				}

				// Say the current location.
				this.Say (speakLocation);

				// Also output to console.
				Console.WriteLine (speakLocation);
			}
		}
        /// <summary>
        /// Locationses the updated.
        /// </summary>
        /// <param name="sender">Sender who fired the event.</param>
        /// <param name="e">Event arguemnts</param>
        private void LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            CLLocation lastLocation = e.Locations[e.Locations.Length - 1];

            this.SetLastKnownLocation(lastLocation);

            if (this.Regions.Count > 20 && this.locationManager.MonitoredRegions.Count == 20)
            {
                this.RecalculateRegions();
            }
            else
            {
                // Check any current monitored regions not in loaded persistent regions and stop monitoring them
                foreach (CLCircularRegion region in this.locationManager.MonitoredRegions)
                {
                    if (!this.Regions.ContainsKey(region.Identifier))
                    {
                        this.locationManager.StopMonitoring(region);
                        string message = string.Format("{0} - Stopped monitoring region {1} wasn't in persistent loaded regions", CrossGeofence.Id, region.Identifier);
                        System.Diagnostics.Debug.WriteLine(message);
                    }
                }
            }

            System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}: {2},{3}", CrossGeofence.Id, "Location update", lastLocation.Coordinate.Latitude, lastLocation.Coordinate.Longitude));
        }
Пример #41
0
		void handleLocationsUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			Log ("handleLocationsUpdated");

			ClLocationManager.LocationsUpdated -= handleLocationsUpdated;
			ClLocationManager.StopUpdatingLocation ();

			Log ("StopUpdatingLocation");

			// If it's a relatively recent event, turn off updates to save power.
			var location = e.Locations.LastOrDefault ();

			if (location != null) {

				var timestamp = location.Timestamp.ToDateTime ();

				var timedelta = DateTime.UtcNow.Subtract (timestamp);

				var timeDeltaSeconds = Math.Abs (timedelta.TotalSeconds);

				Log ($"Location is {Math.Abs (timedelta.TotalSeconds)} seconds old");

				// location was retrieved less than 15 seconds ago
				if (timeDeltaSeconds < 15) {

					Location = location;

					if (!ClLocationTcs.TrySetResult (location)) {

						Log ("ClLocationTcs Failed to Set Result");

					} else {

						Log ("ClLocationTcs Set Result");
					}

				} else {

					Log ($"Location was too old: ({timedelta})");

					ClLocationManager.LocationsUpdated += handleLocationsUpdated;

					ClLocationManager.StartUpdatingLocation ();

					Log ("StartUpdatingLocation");
				}
			}
		}
		void OnLocationsUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			// Pass location updates to the map view.
			foreach (var l in e.Locations) {
				Console.WriteLine ("Location (Floor {0}): {1}", l.Floor, l);
				UpdateViewWithLocation (l);
			}
		}
Пример #43
0
		void OnLocationUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			NativeLocationUpdatedEvent (this, e);
		}
        void OnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            foreach (CLLocation location in e.Locations)
                UpdatePosition(location);

            // defer future location updates if requested
            if ((listenerSettings?.DeferLocationUpdates ?? false) && !deferringUpdates && CanDeferLocationUpdate)
            {
                manager.AllowDeferredLocationUpdatesUntil(listenerSettings.DeferralDistanceMeters == null ? CLLocationDistance.MaxDistance : listenerSettings.DeferralDistanceMeters.GetValueOrDefault(), 
                    listenerSettings.DeferralTime == null ? CLLocationManager.MaxTimeInterval : listenerSettings.DeferralTime.GetValueOrDefault().TotalSeconds);
				
                deferringUpdates = true;
            }			
        }
Пример #45
0
        async void _locationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            _newLocationRequestAvailable = true;
            if (this.IsListening)
            {
                if ((e.Locations != null) && (e.Locations.Length > 0))
                {
                    var location = e.Locations[e.Locations.Length - 1];
                    Position position = ToPosition(location);
                    this.PositionChanged(sender, new PositionEventArgs(position));
                }

                _locationManager.StopUpdatingLocation();
                if ((_includeHeading) && (CLLocationManager.HeadingAvailable))
                    _locationManager.StopUpdatingHeading();

                await Task.Delay((int)_minTime);

                _locationManager.StartUpdatingLocation();
                if (_includeHeading)
                    _locationManager.StartUpdatingHeading();
            }
        }
Пример #46
0
 private void OnLocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     foreach (CLLocation location in e.Locations)
         UpdatePosition(location);
 }
Пример #47
0
 private void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     try
     {
         var position = e.Locations?.FirstOrDefault();
         if (position == null)
         {
             return;
         }
         var currentLocation = new Location {Latitude = position.Coordinate.Latitude, Longitude = position.Coordinate.Longitude};
         world.UpdateLocation(currentLocation);
         foreach (var view in events.Keys)
         {
             var poi = events[view];
             poi.Element.DistanceMetres = currentLocation.DistanceInMetres(poi.Element.GeoLocation);
             var distanceLabel = view.Subviews?.FirstOrDefault(v => v is UILabel) as UILabel;
             if (distanceLabel == null) continue;
             var distance = events[view].Element.DistanceAway;
             distanceLabel.Text = distance;
             var frameWidth = distanceLabel.IntrinsicContentSize.Width;
             distanceLabel.Frame = new CGRect(0, 0, frameWidth, 15);
             view.Bounds = new CGRect(0, 0, frameWidth, 50);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
Пример #48
0
 void LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     UpdateLocation (e.Locations[e.Locations.Length - 1]);
 }
Пример #49
0
		void OnLocationsUpdated (object sender, CLLocationsUpdatedEventArgs e)
		{
			locationCoordinate = e.Locations.Last ().Coordinate;
		}
Пример #50
0
 private void LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
 {
     var position = e.Locations.First().Coordinate;
     LocationChanged?.Invoke(position.Latitude, position.Longitude);
 }