Raised when the ability of the Geolocator to provide updated location changes.
Syntax
function onStatusChanged(eventArgs) { /* Your code */ } // addEventListener syntax geolocator.addEventListener("statuschanged", onStatusChanged); geolocator.removeEventListener("statuschanged", onStatusChanged); - or - geolocator.onstatuschanged = onStatusChanged;
Event information
| Delegate | TypedEventHandler<Geolocator, StatusChangedEventArgs> |
|---|
Remarks
You can access information about the event with the StatusChangedEventArgs object that is passed to your event handler.
When in Connected Standby, Geolocator objects can always be instantiated but the Geolocator object will not find any sensors to aggregate and calls to GetGeopositionAsync will time out after 7 seconds, PositionChanged event listeners will never be called, and StatusChanged event listeners will be called once with the NoData status.
Examples
The following example shows how to handle the StatusChanged event.
loc = new Windows.Devices.Geolocation.Geolocator(); // Add event handlers for the statuschanged event. loc.addEventListener("statuschanged", onStatusChanged); // Handler for statusChanged event. function onStatusChanged(args) { var newStatus = args.status; document.getElementById('geolocatorStatus').innerHTML = getStatusString(newStatus); } // display an appropriate error message function getStatusString(locStatus) { switch (locStatus) { case Windows.Devices.Geolocation.PositionStatus.ready: // Location data is available return "Location is available."; break; case Windows.Devices.Geolocation.PositionStatus.initializing: // This status indicates that a GPS is still acquiring a fix return "A GPS device is still initializing."; break; case Windows.Devices.Geolocation.PositionStatus.noData: // No location data is currently available return "Data from location services is currently unavailable."; break; case Windows.Devices.Geolocation.PositionStatus.disabled: // The app doesn't have permission to access location, // either because location has been turned off. return "Your location is currently turned off. " + "Change your settings through the Settings charm " + " to turn it back on."; break; case Windows.Devices.Geolocation.PositionStatus.notInitialized: // This status indicates that the app has not yet requested // location data by calling GetGeolocationAsync() or // registering an event handler for the positionChanged event. return "Location status is not initialized because " + "the app has not requested location data."; break; case Windows.Devices.Geolocation.PositionStatus.notAvailable: // Location is not available on this version of Windows return "You do not have the required location services " + "present on your system."; break; default: return "Unknown status"; } }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
|
Capabilities |
|
See also
Build date: 2/25/2013