Esempio n. 1
0
        private async void BtnLocalizacao_Clicked(object sender, EventArgs e)
        {
            try
            {
                var lastLocation = await Geolocation.GetLastKnownLocationAsync();

                var request = new GeolocationRequest(GeolocationAccuracy.Medium, TimeSpan.FromSeconds(10));
                cts = new CancellationTokenSource();

                var newLocation = await Geolocation.GetLocationAsync(request, cts.Token);

                if (lastLocation != null && newLocation != null)
                {
                    await DisplayAlert("Informçaões do GPS:",
                                       $"Última localização:\n\n" +
                                       $"Latitude: {lastLocation.Latitude}\n" +
                                       $"Longitude: {lastLocation.Longitude}\n" +
                                       $"Altitude: { lastLocation.Altitude}\n\n" +
                                       $"Localização atualizada:\n\n" +
                                       $"Latitude: { newLocation.Latitude}\n" +
                                       $"Longitude: { newLocation.Longitude}\n" +
                                       $"Altitude: {newLocation.Altitude}\n", "Ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Erro no GPS:", $"Erro ao mostrar localização do dispositivo", "Ok");
            }
        }
Esempio n. 2
0
        public Location GetDeviceLocationAsync()
        {
            //var request = new GeolocationRequest(GeolocationAccuracy.Best);
            var location = Geolocation.GetLastKnownLocationAsync().Result;

            return(location);
        }
Esempio n. 3
0
        async Task GetClosestAsync()
        {
            if (IsBusy || Monkeys.Count == 0)
            {
                return;
            }

            try
            {
                // Get cached location, else get real location.
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location == null)
                {
                    location = await Geolocation.GetLocationAsync(new GeolocationRequest
                    {
                        DesiredAccuracy = GeolocationAccuracy.Medium,
                        Timeout         = TimeSpan.FromSeconds(30)
                    });
                }

                // Find closest monkey to us
                var first = Monkeys.OrderBy(m => location.CalculateDistance(
                                                new Location(m.Latitude, m.Longitude), DistanceUnits.Miles))
                            .FirstOrDefault();

                await Application.Current.MainPage.DisplayAlert("", first.Name + " " +
                                                                first.Location, "OK");
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Unable to query location: {ex.Message}");
                await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK");
            }
        }
Esempio n. 4
0
        public async void Button_Clicked(object sender, EventArgs e)
        {
            try
            {
                var request  = new GeolocationRequest(Xamarin.Essentials.GeolocationAccuracy.Best, TimeSpan.FromSeconds(10));
                var request1 = new GeolocationRequest(Xamarin.Essentials.GeolocationAccuracy.Lowest, TimeSpan.FromSeconds(10));

                var location = await Geolocation.GetLastKnownLocationAsync();

                var location1 = await Geolocation.GetLocationAsync(request);

                var location2 = await Geolocation.GetLocationAsync(request1);

                lblLocation.Text  = $"Lat: {location.Latitude} .-. Long: {location.Longitude}";
                lblLocation1.Text = $"Lat: {location1.Latitude} .-. Long: {location1.Longitude}";
                lblLocation2.Text = $"Lat: {location2.Latitude} .-. Long: {location2.Longitude}";
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
                throw fnsEx;
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
                throw pEx;
            }
            catch (Exception ex)
            {
                // Unable to get location
                throw ex;
            }
        }
Esempio n. 5
0
        private async void getLocation_Clicked(object sender, EventArgs e)
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location == null)
                {
                    location = await Geolocation.GetLocationAsync(new GeolocationRequest
                    {
                        DesiredAccuracy = GeolocationAccuracy.Medium,
                        Timeout         = TimeSpan.FromSeconds(30)
                    });
                }

                if (location == null)
                {
                    locationLabel.Text = "No GPS";
                }
                else
                {
                    locationLabel.Text = $"{location.Latitude} -- {location.Longitude}";
                }
            }catch (Exception ex)
            {
            }
        }
Esempio n. 6
0
        public async Task <Location> GetPositionAsync()
        {
            Location position = null;

            try
            {
                position = await Geolocation.GetLastKnownLocationAsync();

                if (position != null)
                {
                    // Got a cahched position, so let's use it.
                    return(position);
                }

                position = await Geolocation.GetLocationAsync(new GeolocationRequest
                {
                    DesiredAccuracy = GeolocationAccuracy.Medium,
                    Timeout         = TimeSpan.FromSeconds(30)
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Unable to get location: " + ex);
            }

            var defaultLocation = AppSettings.DefaultFallbackMapsLocation.ParseLocation();

            return(defaultLocation);
        }
        public async static Task <Location> GetMyLocation()
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    return(location);
                }
                else
                {
                    var request = new GeolocationRequest(GeolocationAccuracy.Low, TimeSpan.FromMilliseconds(10000));
                    location = await Geolocation.GetLocationAsync(request);

                    return(location);
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
                return(null);
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
                return(null);
            }
            catch (Exception ex)
            {
                // Unable to get location
                return(null);
            }
        }
        public async Task GetLocation()
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    ViewModel.latitude = location.Latitude;

                    ViewModel.longitude = location.Longitude;

                    Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
        }
        /* private async void Button_OnClicked(object sender, EventArgs e)
         * {
         *   var Locator = CrossGeolocator.Current;
         *   Locator.DesiredAccuracy = 50;
         *
         *   var Position = await Locator.GetPositionAsync(TimeSpan.FromSeconds(500000), null, true);
         *
         *   LonLabel.Text = Position.Longitude.ToString();
         *   LatLabel.Text = Position.Latitude.ToString();
         * }*/


        private async void Button_OnClicked(object sender, EventArgs e)
        {
            try {
                var hasPermission = await CheckPermissions();

                if (!hasPermission)
                {
                    return;
                }

                var position = await Geolocation.GetLastKnownLocationAsync();

                if (position == null)
                {
                    // get full location if not cached.
                    position = await Geolocation.GetLocationAsync(new GeolocationRequest
                    {
                        DesiredAccuracy = GeolocationAccuracy.Best,
                        Timeout         = TimeSpan.FromSeconds(50)
                    });
                }

                LonLabel.Text = position.Longitude.ToString();
                LatLabel.Text = position.Latitude.ToString();
            }

            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Get the current posistion of the device
        /// </summary>
        /// @author Gabriele Ursini
        /// <returns>A wrapper containing the position of the user or an error</returns>
        public async Task <positionWrapper> getPositionAsync()
        {
            var positionRequest = await authorizeGeolocationAsync();

            if (!positionRequest.isSuccessFull())
            {
                return new positionWrapper()
                       {
                           code = positionRequest.code, message = positionRequest.message
                       }
            }
            ;

            try
            {
                //var request = new GeolocationRequest(GeolocationAccuracy.Medium);


                var position = await Geolocation.GetLastKnownLocationAsync();

                return(new positionWrapper()
                {
                    code = "200", message = "ok", position = position
                });
            }
            catch (Exception e)
            {
                return(new positionWrapper()
                {
                    code = "500", message = e.Message
                });
            }
        }
Esempio n. 11
0
        public async void distance(int i)
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                model[i].distance = (int)Location.CalculateDistance(location, new Location(model[i].latitude, model[i].longitude), DistanceUnits.Kilometers);
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
        }
Esempio n. 12
0
        private async Task <Location> GetLocation()
        {
            Location location = null;

            try
            {
                location = await Geolocation.GetLastKnownLocationAsync();

                if (location == null)
                {
                    var request = new GeolocationRequest(GeolocationAccuracy.High);
                    location = await Geolocation.GetLocationAsync(request);
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }

            return(location);
        }
Esempio n. 13
0
        private async void Find_Us(object sennder, EventArgs e)
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location == null)
                {
                    location = await Geolocation.GetLocationAsync(new GeolocationRequest
                    {
                        DesiredAccuracy = GeolocationAccuracy.Medium,
                        Timeout         = TimeSpan.FromSeconds(30)
                    });
                }
                if (location == null)
                {
                    LocationLabel.Text = "Brak zasięgu GPS";
                }
                else
                {
                    LocationLabel.Text = $"{location.Latitude} {location.Longitude}";
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Coś poszło nie tak: {ex.Message}");
            }
        }
Esempio n. 14
0
    public async Task <Location> GetLastKnownLocationAsync()
    {
        Location location = null;

        try
        {
            location = await Geolocation.GetLastKnownLocationAsync();

            loggingService.Debug($"{nameof(GeolocationService)} : Location is successful");
        }
        catch (FeatureNotSupportedException fnsEx)
        {
            loggingService.Error(fnsEx);
        }
        catch (PermissionException pEx)
        {
            loggingService.Error(pEx);
        }
        catch (Exception ex)
        {
            loggingService.Error(ex);
        }

        return(location);
    }
Esempio n. 15
0
 private void ShareLocation(string User)
 {
     try
     {
         using var otherRealm = DatabaseHelper.GetDatabaseInstance();
         var location = Geolocation.GetLastKnownLocationAsync().GetAwaiter().GetResult();
         if (location != null)
         {
             otherRealm.Write(() =>
             {
                 otherRealm.Add(new AlertRealm
                 {
                     Id        = User,
                     Event     = "location",
                     Date      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                     Latitude  = location.Latitude,
                     Longitude = location.Longitude
                 });
             });
         }
     }
     catch (Exception e)
     {
         //Crashes.TrackError(e);
     }
 }
Esempio n. 16
0
        private async Task ExecuteStartGetGeolocationCommand()
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location == null)
                {
                    location = await Geolocation.GetLocationAsync(new GeolocationRequest()
                    {
                        DesiredAccuracy = GeolocationAccuracy.Medium,
                        Timeout         = TimeSpan.FromSeconds(30),
                    });
                }
                if (location == null)
                {
                    this.GeolocationText = "No GPS";
                }
                else
                {
                    this.GeolocationText = $"{ location.Latitude}, {location.Longitude}";
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 17
0
        /*
         * zobrazeni mapu tam kde se hrac nachazi
         */
        static public async void PoziceHrace()
        {
            try
            {
                var lokace = await Geolocation.GetLastKnownLocationAsync();

                if (lokace != null)
                {
                    Position pozice  = new Position(lokace.Latitude, lokace.Longitude);
                    MapSpan  mapSapn = MapSpan.FromCenterAndRadius(pozice, Distance.FromKilometers(.444));
                    Hra.mapa.MoveToRegion(mapSapn);
                    Console.WriteLine($"Latitude: {lokace.Latitude}, Longitude: {lokace.Longitude}, Altitude: {lokace.Altitude}");
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
        }
Esempio n. 18
0
        private async Task GetUserLocationAsync()
        {
            var locationStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);

            if (locationStatus != PermissionStatus.Granted)
            {
                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Location });

                locationStatus = results[Permission.Location];
            }
            if (locationStatus == PermissionStatus.Granted)
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    ToMap.MoveToMapRegion(MapSpan.FromCenterAndRadius(
                                              new Position(location.Longitude, location.Longitude), Distance.FromKilometers(50)), true);
                }
            }
            else
            {
                await DisplayAlert(AppResources.PermissionsDenied, AppResources.PermissionLocationDetails,
                                   AppResources.Ok);

                //On iOS you may want to send your user to the settings screen.
                CrossPermissions.Current.OpenAppSettings();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnGetLastKnownLocation_ClickedAsync(object sender, EventArgs e)
        {
            try
            {
                var ret      = "";
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    ret = $"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}";
                    Console.WriteLine(ret);
                    this.lblResult.Text = ret;
                }
                else
                {
                    this.lblResult.Text = ret;
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
                this.lblResult.Text = fnsEx.ToString();
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
                this.lblResult.Text = pEx.ToString();
            }
            catch (Exception ex)
            {
                // Unable to get location
                this.lblResult.Text = ex.ToString();
            }
        }
Esempio n. 20
0
        public async void Search_Clicked(object sender, EventArgs e)
        {
            searchpage myHomePage = new searchpage();

            NavigationPage.SetHasNavigationBar(myHomePage, true);
            await Navigation.PushModalAsync(myHomePage);

            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
        }
Esempio n. 21
0
 async Task Locate()
 {
     await Task.Run(() => Device.BeginInvokeOnMainThread(async() =>
     {
         this.IsBusy = true;
         try
         {
             Location location = await Geolocation.GetLastKnownLocationAsync();
             if (location == null)
             {
                 location = await Geolocation.GetLocationAsync(new GeolocationRequest(GeolocationAccuracy.Best));
             }
             if (location != null)
             {
                 Position position           = new Position(location.Latitude, location.Longitude);
                 this.MapsViewModel.Position = position;
             }
         }
         catch (Exception exception)
         {
             MessagingCenter.Send("Aviso", "Message", "Não foi possível obter a localização.");
             Debug.WriteLine(exception);
         }
         this.IsBusy = false;
     }));
 }
Esempio n. 22
0
        async void GpsCache_Clicked(System.Object sender, System.EventArgs e)
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    txtLatCache.Text       = location.Latitude.ToString();
                    txtLongCache.Text      = location.Longitude.ToString();
                    txtAltitudCache.Text   = location.Altitude.ToString();
                    txtVelocidadCache.Text = location.Speed.ToString();
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
                await DisplayAlert("Mi App", "Mi dispositivo no soporta GPS", "Continuar");
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
                await DisplayAlert("Mi App", "Mi dispositivo genero un error", "Continuar");
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
                await DisplayAlert("Mi App", "Mi dispositivo no tiene permiso para el gps", "Continuar");
            }
            catch (Exception ex)
            {
                // Unable to get location
                await DisplayAlert("Mi App", "Mi dispositivo fallo al traer mi ubicación", "Continuar");
            }
        }
        private async void BtnObtenerUbicacion_Clicked(object sender, EventArgs e)
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    ubicacionLatitudEntry.Text  = location.Latitude.ToString();
                    ubicacionLongitudEntry.Text = location.Longitude.ToString();
                    ubconfirmacionEntry.Text    = "Ubicacion Guardada";
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
            }
            catch (PermissionException pEx)
            {
                await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", "Algo salio mal, intentelo de nuevo", "OK");
            }
        }
Esempio n. 24
0
        public static async Task <Location> GetLocationAsync()
        {
            try
            {
                //var request = new GeolocationRequest(GeolocationAccuracy.Medium);
                var location = await Geolocation.GetLastKnownLocationAsync();

                return(location);
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
                Console.WriteLine("GetLocationAsync() failed: FeatureNotSupportedException:" + fnsEx.Message);
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
                Console.WriteLine("GetLocationAsync() failed: FeatureNotEnabledException:" + fneEx.Message);
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
                Console.WriteLine("GetLocationAsync() failed: PermissionException:" + pEx.Message);
            }
            catch (Exception ex)
            {
                // Unable to get location
                Console.WriteLine("GetLocationAsync() failed: Exception:" + ex.Message);
            }
            return(null);
        }
Esempio n. 25
0
        public static async Task <Location> GetCurrentLocation()
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}");
                    return(location);
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
                Console.WriteLine("Feature not supported");
                throw;
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
                Console.WriteLine("Permission not granted");
                throw;
            }
            catch (Exception ex)
            {
                // Unable to get location
                Console.WriteLine(ex);
                throw;
            }

            Console.WriteLine("Could not get location");
            return(null);
        }
Esempio n. 26
0
        public static async Task <Location> GetMyLocation()
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
                }

                return(location);
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
            return(null);
        }
        private async void GetCurrentLocation()
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
                    await DisplayAlert($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}", "Location", "Cancel");
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
        }
Esempio n. 28
0
        private async void BtnLoc_Click(object sender, EventArgs e)
        {
            try
            {
                currentLocation = await Geolocation.GetLastKnownLocationAsync();

                if (currentLocation != null)
                {
                    txtLoc.Text = $"Latitude={currentLocation.Latitude} , Longitude={currentLocation.Longitude} ";
                    Console.WriteLine($"Latitude: {currentLocation.Latitude}, Longitude: {currentLocation.Longitude}, Altitude: {currentLocation.Altitude}");

                    //mapView.GetMapAsync(this);


                    Com.Mapbox.Geojson.Point point = Com.Mapbox.Geojson.Point.FromLngLat(currentLocation.Longitude, currentLocation.Latitude);
                    mapbox.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(point.Latitude(), point.Longitude()), 15));

                    var options = new SymbolOptions();
                    options.WithIconImage("airport-15");
                    options.WithGeometry(point);
                    options.WithIconSize(new Float(2f))
                    .WithDraggable(true);

                    var symbol = symbolManager.Create(options);
                }
            }
            catch
            {
            }
        }
Esempio n. 29
0
        public async void MoveCamera()
        {
            try
            {
                if (_locationService.LocationEnabled)
                {
                    await GetPermissions();

                    var location = await Geolocation.GetLastKnownLocationAsync();

                    if (location != null)
                    {
                        Map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(location.Latitude, location.Longitude),
                                                                     Distance.FromMiles(1)));
                    }
                }
            }
            //catch (FeatureNotSupportedException fnsEx)
            //{
            //    // Handle not supported on device exception
            //}
            //catch (PermissionException pEx)
            //{
            //    // Handle permission exception
            //}
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                await DisplayAlert("Error", ex.Message, "Ok");

                // Unable to get location
            }

            // Map.MoveCamera(CameraUpdateFactory.NewCameraPosition(new CameraPosition(position, 3)));
        }
Esempio n. 30
0
        public async void PegaGPS()//ainda n funciona
        {
            var location = await Geolocation.GetLastKnownLocationAsync();

            try
            {
                if (location != null)
                {
                    Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
            HorVer = (location.Latitude + location.Longitude).ToString();
        }