GeoLocation and VB.NET RRS feed

  • Question

  • Hello Everyone!

    I am trying to use GeoLocation with my VB.NET Windows 8.1 Store App. This is my code :

    Imports Windows.Devices.Geolocation
    Imports Windows.UI.Core
    Imports System.Threading
    Imports System.Threading.Tasks
        Private WithEvents glGeo As New Geolocator
        Private ctsCancel As CancellationTokenSource
        Private Async Sub btGetLocation_Click(sender As Object, e As RoutedEventArgs) Handles btGetLocation.Click
                ' Get cancellation token
                ctsCancel = New CancellationTokenSource()
                Dim canToken As CancellationToken = ctsCancel.Token
                ' Carry out the operation
                Dim gpPos As Geoposition = Await glGeo.GetGeopositionAsync().AsTask(canToken)
                tbEnterAccuracy.IsEnabled = True
                tbLatitude.Text = gpPos.Coordinate.Point.Position.Latitude.ToString()
                tbLongitude.Text = gpPos.Coordinate.Point.Position.Longitude.ToString()
                tbAccuracy.Text = gpPos.Coordinate.Accuracy.ToString()
                tbSource.Text = gpPos.Coordinate.PositionSource.ToString()
                If gpPos.Coordinate.PositionSource = PositionSource.Satellite Then
                    'show labels and satellite data
                    tbPrecision.Text = gpPos.Coordinate.SatelliteData.PositionDilutionOfPrecision.ToString()
                    tbHorzPrecision.Text = gpPos.Coordinate.SatelliteData.HorizontalDilutionOfPrecision.ToString()
                    tbVertPrecision.Text = gpPos.Coordinate.SatelliteData.VerticalDilutionOfPrecision.ToString()
                End If
            Catch eu As System.UnauthorizedAccessException
                tbLatitude.Text = "No data"
                tbLongitude.Text = "No data"
                tbAccuracy.Text = "No data"
            Catch et As TaskCanceledException
                tbStatus.Text = "Canceled"
            Catch err As Exception
                tbStatus.Text = "UNKNOWN"
                ctsCancel = Nothing
            End Try
        End Sub

    However, On this line :

                Dim gpPos As Geoposition = Await glGeo.GetGeopositionAsync().AsTask(canToken)

    I get an HRESULT E_FAIL error. I have tried identifying the cause through this forum and google, to no avail.

    Can anyone please help me?

    Thursday, November 7, 2013 10:01 AM


  • Solved. :)

    Seems like there was an issue with my pc and its security settings. weird, but after I solved my PC's Network access it has shown everything perfectly.

    Thanks for all your efforts in any case :)

    • Marked as answer by Anne Jing Friday, November 8, 2013 9:09 AM
    Friday, November 8, 2013 6:21 AM

All replies