Geolocation Windows phone中的GPS(我在路上移动时从当前位置移动。如何移动?)

Geolocation Windows phone中的GPS(我在路上移动时从当前位置移动。如何移动?),geolocation,windows-phone,bing-maps,Geolocation,Windows Phone,Bing Maps,我正在windows phone 7.1中使用GPS,我在bing地图上获得了当前位置,并在bing地图上显示了最近的餐厅。但现在我想要的是,当我在路上移动的时候,我的图钉也会跟着我移动。 i、 目前的职位也希望随着我的变动而改变。我希望能帮助你。简而言之,您必须使用objectgeocordinatewatcher private void startLocationButton_Click(object sender, RoutedEventArgs e) { if (watcher

我正在windows phone 7.1中使用GPS,我在bing地图上获得了当前位置,并在bing地图上显示了最近的餐厅。但现在我想要的是,当我在路上移动的时候,我的图钉也会跟着我移动。 i、 目前的职位也希望随着我的变动而改变。

我希望能帮助你。简而言之,您必须使用object
geocordinatewatcher

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;
    }
}
private void startLocationButton_单击(对象发送者,路由目标)
{
如果(观察者==null)
{
watcher=新的地理坐标记录器(GeoPositionAccuracy.Default);
watcher.MovementThreshold=20;
watcher.StatusChanged+=新事件处理程序(watcher\u StatusChanged);
watcher.PositionChanged+=新事件处理程序(watcher\u PositionChanged);
}
watcher.Start();
}
void watcher_status已更改(对象发送器、地理位置StatusChangedEventArgs e)
{
开关(如状态)
{
案例地理位置状态。已禁用:
MessageBox.Show(“设备上未启用位置服务”);
打破
案例地理位置status.NoData:
Show(“位置服务正在工作,但无法获取位置数据。”);
打破
}
}
void watcher_位置已更改(对象发送器,地理位置更改Deventargs e)
{
如果(如位置位置未知)
{
MessageBox.Show(“请稍候,您的主题已确定…”);
回来
}
}