修炼九阴真经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");
}