0
我正在使用GPS在Windows手机7.1,我得到了当前位置上冰淇淋地图,并得到最近的餐厅显示在冰上地图。但现在我想要在路上行驶时,向我展示的图钉也随我移动。 即当前位置也想随着我的动作而改变。全球定位系统在窗口手机(从当前位置移动,当我在路上移动,如何?)
我正在使用GPS在Windows手机7.1,我得到了当前位置上冰淇淋地图,并得到最近的餐厅显示在冰上地图。但现在我想要在路上行驶时,向我展示的图钉也随我移动。 即当前位置也想随着我的动作而改变。全球定位系统在窗口手机(从当前位置移动,当我在路上移动,如何?)
我希望this来帮助你。简而言之,您必须使用对象GeoCoordinateWatcher
。
private void startLocationButton_Click(object sender, RoutedEventArgs e)
{
if (watcher == null)
{
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
watcher.MovementThreshold = 20;
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
}
watcher.Start();
}
void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
{
switch (e.Status)
{
case GeoPositionStatus.Disabled:
MessageBox.Show("Location Service is not enabled on the device");
break;
case GeoPositionStatus.NoData:
MessageBox.Show(" The Location Service is working, but it cannot get location data.");
break;
}
}
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
if (e.Position.Location.IsUnknown)
{
MessageBox.Show("Please wait while your prosition is determined....");
return;
}
}