GeoCoordinate.Longitude 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 . 的 GeoCoordinate经度。
public:
property double Longitude { double get(); void set(double value); };
public double Longitude { get; set; }
member this.Longitude : double with get, set
Public Property Longitude As Double
属性值
经度。
例外
Longitude 设置为超出有效范围。
示例
以下示例输出从 a GeoCoordinate.
using System;
using System.Device.Location;
namespace LocationEvent1
{
class Program
{
static void Main(string[] args)
{
GeoCoordinateWatcher watcher;
watcher = new GeoCoordinateWatcher();
watcher.PositionChanged += (sender, e) =>
{
var coordinate = e.Position.Location;
Console.WriteLine("Lat: {0}, Long: {1}", coordinate.Latitude,
coordinate.Longitude);
// Uncomment to get only one event.
// watcher.Stop();
};
// Begin listening for location updates.
watcher.Start();
}
}
}
Imports System.Device.Location
Module GetLocationEvent
Public Class CLocation
Private WithEvents watcher As GeoCoordinateWatcher
Public Sub GetLocationDataEvent()
watcher = New System.Device.Location.GeoCoordinateWatcher()
AddHandler watcher.PositionChanged, AddressOf watcher_PositionChanged
watcher.Start()
End Sub
Private Sub watcher_PositionChanged(ByVal sender As Object, ByVal e As GeoPositionChangedEventArgs(Of GeoCoordinate))
PrintPosition(e.Position.Location.Latitude, e.Position.Location.Longitude)
' Uncomment the following to stop receiving updates after the first one.
' watcher.Stop()
End Sub
Private Sub PrintPosition(ByVal Latitude As Double, ByVal Longitude As Double)
Console.WriteLine("Latitude: {0}, Longitude {1}", Latitude, Longitude)
End Sub
End Class
Public Sub Main()
Dim myLocation As New CLocation()
myLocation.GetLocationDataEvent()
Console.WriteLine("Enter any key to quit.")
Console.ReadLine()
End Sub
End Module
注解
经度范围为 -180.0 到 180.0。 经度以主要经线向东或西度测量。 负值是质子午线的西部,正值是质子午线的东部。