Windows phone 7 WP7中地理坐标记录器中的位置更改事件
我正在使用GeoCoordinateWatcher检测WindowsPhone7中的登录度和纬度 我做了以下几件事Windows phone 7 WP7中地理坐标记录器中的位置更改事件,windows-phone-7,gps,Windows Phone 7,Gps,我正在使用GeoCoordinateWatcher检测WindowsPhone7中的登录度和纬度 我做了以下几件事 GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); // Add event handlers for StatusChanged and PositionChanged events watcher.StatusChanged += new
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();
}
当移动距离为100或更多时,是否会调用watcher_PositionChanged方法
但这并没有发生
注意:我正在使用emulator测试我的代码如果我理解正确,请每隔10秒再次启动geowatcher,以便每10秒重新启动一次,并生成实际坐标
如果希望仅在位置发生更改时每隔10秒调用一个方法,则可以使用currentCoordinates和lastCoordinates值。使用每个PositionChanged事件写入currentCoordinates,如果与lastCoordinates不同,则每10秒测试一次。或者更好,您可以使用被动扩展来组合事件。但是我正在设置watcher.MovementThreshold,并且我更改了我的位置,并且没有触发positionChanged事件
watcher.MovementThreshold = 100;