导出 (0) 打印
全部展开
信息
您所需的主题如下所示。但此主题未包含在此库中。

StatusChangedEventArgs Class

StatusChanged 事件提供信息。

语法


/* 有关创建或访问此对象的信息,请参见“备注”。 */

特性

[MarshalingBehavior(Agile)]
[Version(0x06020000)]

成员

StatusChangedEventArgs类 具有这些类型的成员:

方法

The StatusChangedEventArgs 类 继承这些方法于:Object 类 (C#/VB/C++).

属性

StatusChangedEventArgs类 具有这些属性。

属性访问类型说明

Status

只读The updated status of the Geolocator object.

 

备注

此对象是传递给 StatusChanged 事件处理程序的参数。

示例

此代码示例演示如何处理 StatusChanged 事件。



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 location device is still initializing
         return "Location devices are 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.";
     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";
    }
}


要求

最低支持客户端

Windows 8 [仅 Windows 应用商店应用程序]

最低支持服务器

不支持“无” [仅 Windows 应用商店应用程序]

最低支持电话

Windows Phone 8

命名空间

Windows.Devices.Geolocation
Windows::Devices::Geolocation [C++]

元数据

Windows.winmd

Capabilities

location
ID_CAP_LOCATION [Windows Phone]

 

 

Microsoft 正在进行一项网上调查,以了解您对 MSDN 网站的意见。 如果您选择参加,我们将会在您离开 MSDN 网站时向您显示该网上调查。

是否要参加?
显示:
© 2015 Microsoft