在 Windows phone 7 上获取 GPS 坐标 [英] Getting GPS coordinates on Windows phone 7

查看:22
本文介绍了在 Windows phone 7 上获取 GPS 坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Windows Phone 7 上获取当前 GPS 坐标?

How can I get the current GPS coordinates on Windows Phone 7?

推荐答案

这是一个简单的例子:

GeoCoordinateWatcher watcher;

watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default)
                   {
                       MovementThreshold = 20
                   };

watcher.PositionChanged += this.watcher_PositionChanged;
watcher.StatusChanged += this.watcher_StatusChanged;
watcher.Start();


private void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
{
    switch (e.Status)
    {
        case GeoPositionStatus.Disabled:
            // location is unsupported on this device
            break;
        case GeoPositionStatus.NoData:
            // data unavailable
            break;
    }
}

private void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
    var epl = e.Position.Location;

    // Access the position information thusly:
    epl.Latitude.ToString("0.000");
    epl.Longitude.ToString("0.000");
    epl.Altitude.ToString();
    epl.HorizontalAccuracy.ToString();
    epl.VerticalAccuracy.ToString();
    epl.Course.ToString();
    epl.Speed.ToString();
    e.Position.Timestamp.LocalDateTime.ToString();
}

这篇关于在 Windows phone 7 上获取 GPS 坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆