ערוך

שתף באמצעות


GeoCoordinate.Unknown Field

Definition

Represents a GeoCoordinate object that has unknown latitude and longitude fields.

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 

Field Value

Examples

The following code example verifies whether the GeoCoordinate that corresponds to a location is Unknown before printing out its latitude and 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

Remarks

The IsUnknown property can be used to verify whether a GeoCoordinate contains no data.

Applies to