Partilhar via


GeoCoordinate.Unknown Campo

Definição

Representa um objeto GeoCoordinate que tem campos de latitude e longitude desconhecidos.

public: static initonly System::Device::Location::GeoCoordinate ^ Unknown;
public static readonly System.Device.Location.GeoCoordinate Unknown;
 staticval mutable Unknown : System.Device.Location.GeoCoordinate
Public Shared ReadOnly Unknown As GeoCoordinate 

Valor do campo

Exemplos

O exemplo de código a seguir verifica se o GeoCoordinate que corresponde a um local é Unknown antes de imprimir sua latitude e longitude.

using System;
using System.Device.Location;

namespace GetLocationPropertyHandleUnknown
{
    class Program
    {
        static void Main(string[] args)
        {
            GetLocationPropertyHandleUnknown();
        }

        static void GetLocationPropertyHandleUnknown()
        {
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
            watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));

            if (watcher.Position.Location.IsUnknown != true)
            {
                GeoCoordinate coord = watcher.Position.Location;

                Console.WriteLine("Lat: {0}, Long: {1}",
                    coord.Latitude,
                    coord.Longitude);
            }
            else
            {
                Console.WriteLine("Unknown");
            }
        }
    }
}
Imports System.Device.Location

Module GetLocationProperty
    Public Sub GetLocationPropertyHandleUnknown()
        Dim watcher As New System.Device.Location.GeoCoordinateWatcher()
        watcher.TryStart(False, TimeSpan.FromMilliseconds(1000))
        If watcher.Position.Location.IsUnknown <> True Then
            Dim coord As GeoCoordinate = watcher.Position.Location
            Console.WriteLine("Lat: {0}, Long: {1}", coord.Latitude, coord.Longitude)
        Else
            Console.WriteLine("Unknown latitude and longitude.")
        End If
    End Sub

    Public Sub Main()
        GetLocationPropertyHandleUnknown()
        Console.ReadLine()
    End Sub

End Module

Comentários

A IsUnknown propriedade pode ser usada para verificar se um GeoCoordinate não contém dados.

Aplica-se a