我正在使用 GeoCoordinateWatcher 来检测 windows phone 7 中的对数和纬度
我做了以下
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
// Add event handlers for StatusChanged and PositionChanged events
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
watcher.MovementThreshold = 100;
// Create A Timer for Getting the GPS Cooradinate every 10 seconds only
System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
// Start the Location service in the First time when the Application run
StartLocationService();
// 15 minutes the interval of timer
dt.Interval = new TimeSpan(0, 0, 0, 10, 0);
// Add the Tick Method for event Handler
dt.Tick += new EventHandler(Start_Service);
// Start the Timer
dt.Start();
}
在 start_service 方法中我调用 watcher.start
问题是即使位置没有改变,watcher_PositionChanged 也会每 10 秒调用一次!!!我知道
watcher.MovementThreshold = 100;
当行进距离为 100 或更多时会调用 watcher_PositionChanged 方法但这并没有发生
注意:我正在使用模拟器测试我的代码