Getting the user's location from their mobile device
The Location control provides a way for you to get location information for the device. This is not a visual control, so dragging it appears on the Shelf when dragged to the layout.
Use the Debug > Location menu in the iOS Simulator to provide locations for testing.
Frequently getting the location can cause significant battery drain, so only be sure to set Enabled = False when it is not needed.
Below is a list of commonly used events, properties and methods. Refer to MobileLocation for the complete list.
LocationChanged: Called when a location update is received from the OS.
Accuracy: Specifies the level of accuracy for the location using the Accuracies enum. The "Best" accuracy is used by default, but you can increase or decrease the accuracy as necessary to manage battery usage.
AuthorizationState: Indicates the level of authorization that is allowed for location. Check this before enabling.
Enabled: When enabled is True, the LocationChanged event is called with location updates. You should set this to False when the location is not needed.
RequestUsageAuthorization: Requests approval to use location either always or when the app is in use.
Before you can get the location you must request authorization. This is typically done like this:
If MyLocation.AuthorizationState = MobileLocation.AuthorizationStates.AppInUse Then
' we've got our requested authorization state, start getting LocationChanged events
MyLocation.Enabled = True
' we don't have authorization yet, so ask for it
Once the control is enabled you will start getting LocationChanged events when the location is updated.