0
我开发了一个用于windows phone 7.1的导航应用程序。那里运行良好。更新到8.0后,我的GeoCoordinateWatcher不再工作。我知道我可以使用Geolocator,但我拒绝这么做,因为时间不够。GeoCoordinateWatcher在迁移到WP8后无法工作
对于我的应用程序,我读取了我的观察器的当前位置,以便将其存储为具有位置信息的对象实例。当我保存我的对象实例时,经度和纬度都是0.0。即使我改变模拟器的位置仍然是0.0。我使用GeoCoordinateWatcher的其他页面也出现同样的问题。它不起作用。正如我已经说过的那样,在WP7.1-7.8中它工作得很好。
public Map()
{
InitializeComponent();
watcher = new GeoCoordinateWatcher();
watcher.MovementThreshold = 20;
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
}
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
if (e.Position.Location.IsUnknown)
{
MessageBox.Show("Please wait while your prosition is determined.");
return;
}
geo.Latitude = e.Position.Location.Latitude;
geo.Longitude = e.Position.Location.Longitude;
}