吴佳鑫的个人专栏

当日事当日毕,没有任何借口

导航

修炼九阴真经Windows Phone开发 (17):Tip与技巧2

如果需要准确定位的位置,设备每移动100米就进行数据更新,可以这样写:

GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Hight);
watcher.MovementThreshold =100;
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
watcher.Start();

private void watcher_PositionChanged(object sender , GeoPositionChangedEventArgs<GeoCoordinate> e)
{
Deployment.Current.Dispatcher.BiginInvoke( ()=>MyPositionChanged(e));
}

private void MyPositionChanged(GeoPositionChangedEventArgs<GeoCoordinate> e)
{
LongitudeTextBlock.Text = e.Position.Location.Longitude.ToString("0");
LatitudeTextBlock.Text = e.Position.Location.Latitude.ToString("0");
}

posted on 2012-09-18 21:44  _eagle  阅读(219)  评论(0编辑  收藏  举报