I am working with a Mapviewer control and on the most part it is working well but occasionally I get
“Resolving MapLocation timed out.” or “The operation couldn’t be completed. (kCLErrorDomain error 8.)”
error when it hits this code
I took my app into a location without reception and each screen that tried to load map locations crashed, even locations that where the Latitude and longitude were saved in the database.
Would it be the Mobilelocation control or the Mapviewer control? What would the best approach be for testing if an app has reception?
So… making a new Maplocation does what’s called a reverse-geocode, that is, it calls out to Apple’s servers to get the “actual” location for the location you passed. That’s definitely not going to work if you don’t have internet.
How do you stop it from looking if there is no connection?
Would the following prevent a location search until there is a signal?
If MyLocation.AuthorizationState = MobileLocation.AuthorizationStates.AuthorizedAppInUse Then
' we've got our requested authorization state, start getting LocationChanged events
MyLocation.Start
Else
' we don't have authorization yet, so ask for it
MyLocation.RequestUsageAuthorization(MobileLocation.UsageTypes.AppInUse)
End If
What if I do a Socket.send request to get a file off our website and if that fails then we are out of mobile data range set a flag to not get Map data?
That’ll probably tell you, but could give you a false negative if the file simply couldn’t be downloaded. Also, timeouts take the full duration to fail, so you should be prepared for that.
Yes Greg you were correct, it sort of worked but if the user reacted too quickly the test was too slow so it only worked half the time.
I also tried to trap the error that occurred if they got through the check with the following but that didn’t work either
Try
locations.Add(New MapLocation(Mylat, Mylong,MyTag))
Catch e As InvalidArgumentException
MessageBox(e.Message)
End Try