Answered by:
GeoLocation and VB.NET

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 Try ' 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" Finally 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
Answers
-
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
-
It works for me! What are the capabilities you selected for this app?
Can you post a project with a simple repo of this issue?
Jeff Sanders (MSFT)
@jsandersrocks - Windows Store Developer Solutions @WSDevSol
Getting Started With Windows Azure Mobile Services development? Click here
Getting Started With Windows Phone or Store app development? Click here
My Team Blog: Windows Store & Phone Developer Solutions
My Blog: Http Client Protocol Issues (and other fun stuff I support)- Edited by Jeff SandersMicrosoft employee, Moderator Thursday, November 7, 2013 9:25 PM
Thursday, November 7, 2013 9:21 PMModerator -
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