GeoPositionStatus 枚举

定义

指示位置提供程序提供位置更新的能力。Indicates the ability of the location provider to provide location updates.

public enum class GeoPositionStatus
public enum GeoPositionStatus
type GeoPositionStatus = 
Public Enum GeoPositionStatus
继承
GeoPositionStatus

字段

Disabled 3

位置提供程序已禁用。The location provider is disabled. 在 Windows 7 上,在组策略禁用了传感器和位置平台之后,就会出现这种情况。On Windows 7, this is the case when the Sensor and Location platform has been disabled by group policy.

Initializing 1

位置提供程序正在初始化。The location provider is initializing. 例如,仍在获取修复的 GPS 就具有此状态。For example, a GPS that is still obtaining a fix has this status.

NoData 2

所有位置提供程序均未提供位置数据。No location data is available from any location provider. 如果 Disabled 的条件不适用,则 GeoCoordinateWatcher 在启动前和停止后均处于 NoData 状态。If the conditions for Disabled do not apply, GeoCoordinateWatcher has the NoData status before it is started and after it is stopped.

Ready 0

一个位置提供程序已准备好提供新数据。A location provider is ready to supply new data.

示例

下面的示例演示如何处理StatusChanged事件并输出当前GeoPositionStatus的。The following example shows how to handle StatusChanged events and print out the current GeoPositionStatus.

using System;
using System.Device.Location;
namespace ShowStatusUpdates
{
    class Program
    {
        static void Main(string[] args)
        {
            ShowStatusUpdates();
        }

        static void ShowStatusUpdates()
        {
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
            watcher.Start();

            watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);

            Console.WriteLine("Enter any key to quit.");
            Console.ReadLine();

        }

        static void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
        {
            switch (e.Status)
            {
                case GeoPositionStatus.Initializing:
                    Console.WriteLine("Working on location fix");
                    break;

                case GeoPositionStatus.Ready:
                    Console.WriteLine("Have location");
                    break;

                case GeoPositionStatus.NoData:
                    Console.WriteLine("No data");
                    break;

                case GeoPositionStatus.Disabled:
                    Console.WriteLine("Disabled");
                    break;
            }
        }

    }
}
Imports System.Device.Location

Module GetLocationEvent

    Sub ShowStatusUpdates()
        Dim Watcher As GeoCoordinateWatcher
        Watcher = New GeoCoordinateWatcher()
        watcher.Start()
        AddHandler Watcher.StatusChanged, AddressOf watcher_StatusChanged

        Console.WriteLine("Enter any key to quit.")
        Console.ReadLine()
    End Sub

    Sub watcher_StatusChanged(ByVal sender As Object, ByVal e As GeoPositionStatusChangedEventArgs)
        Select Case e.Status
            Case GeoPositionStatus.Initializing
                Console.WriteLine("Working on location fix")
            Case GeoPositionStatus.Ready
                Console.WriteLine("Have location")
            Case GeoPositionStatus.NoData
                Console.WriteLine("No data")
            Case GeoPositionStatus.Disabled
                Console.WriteLine("Disabled")
        End Select
    End Sub

    Public Sub Main()
        ShowStatusUpdates()
    End Sub
End Module

适用于