Exemple #1
0
 public static double Bearing(this Location p1, Location p2)
 {
     return Bearing(p1.Latitude, p1.Longitude, p2.Latitude, p2.Longitude);
 }
Exemple #2
0
 public static double DistanceInKilometres(this Location p1, Location p2)
 {
     return Math.Abs(HaversineInKM(p1.Latitude, p1.Longitude, p2.Latitude, p2.Longitude));
 }
Exemple #3
0
        private void UpdateLocation(Geoposition position)
        {
            if (world == null)
            {
                return;
            }

            var currentLocation = new Location {Latitude = position.Coordinate.Point.Position.Latitude, Longitude = position.Coordinate.Point.Position.Longitude};
            world.UpdateLocation(currentLocation);
        }
 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);
     }
 }
Exemple #5
0
 public void OnLocationChanged(global::Android.Locations.Location location)
 {
     var position = new Location {Latitude = location.Latitude, Longitude = location.Longitude};
     world?.UpdateLocation(position);
 }