C# Windows Phone GetGeopositionAsync()返回错误位置

C# Windows Phone GetGeopositionAsync()返回错误位置,c#,windows-phone-8,location,C#,Windows Phone 8,Location,我有一个按钮,每当按下时就会调用CurrentLocation private async void CurrentLocation() { try { Geolocator myGeolocator = new Geolocator(); Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.From

我有一个按钮,每当按下时就会调用
CurrentLocation

private async void CurrentLocation()
{
    try
    {
        Geolocator myGeolocator = new Geolocator();
        Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(3));
        Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
        GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);
        this.MyMap.Center = myGeoCoordinate;
    }
    catch
    { }

}
我一直在Windows Phone emulator上测试该应用程序,一切正常。但是今天,当我在车里开车的时候,在Lumina 640上运行的应用程序中按下按钮时,应用程序开始显示不同的位置

有人知道我的代码有什么问题吗

编辑:

承包商

public MainPage()
{
    InitializeComponent();
    distanceTextBox.Visibility = Visibility.Collapsed;

    CreateStandardApplicationBar();

    pointNamePrompt = new InputPrompt()
    {
        Title = "Point",
        Message = "Name the point",
    };
    try
    {
        CurrentLocation();
        MyMap.ZoomLevel = 10;
    }
    catch { }

    LoadAppSettings();
}
钮扣

private void CurrentLocation_Click(object sender, EventArgs e)
{
    CurrentLocation();
}
最后,新代码在应用程序启动时仍能首次使用:

private async void CurrentLocation()
{
    try
    {
        Geolocator myGeolocator = new Geolocator();
        Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(maximumAge: TimeSpan.FromMinutes(5), timeout: TimeSpan.FromSeconds(10));

        ReverseGeocodeQuery query = new ReverseGeocodeQuery();
        query.GeoCoordinate = new System.Device.Location.GeoCoordinate(myGeoposition.Coordinate.Latitude, myGeoposition.Coordinate.Longitude);

        query.QueryCompleted += (s, e) =>
        {
            if (e.Error != null && e.Result.Count == 0)
                return;
            MessageBox.Show(e.Result[0].Information.Address.PostalCode);
        };
        query.QueryAsync();

        double lat = 0.00, lng = 0.00;
        lat = Convert.ToDouble(myGeoposition.Coordinate.Latitude);
        lng = Convert.ToDouble(myGeoposition.Coordinate.Longitude);

        this.MyMap.Center = new GeoCoordinate(lat, lng);
    }
    catch
    { }

}
请尝试以下代码:

private async void CurrentLocation()
{
    try
    {
        Geolocator myGeolocator = new Geolocator();
        Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(maximumAge: TimeSpan.FromMinutes(5),timeout: TimeSpan.FromSeconds(10));

        ReverseGeocodeQuery query = new ReverseGeocodeQuery();
        query.GeoCoordinate = new System.Device.Location.GeoCoordinate(myGeoposition.Coordinate.Latitude, myGeoposition.Coordinate.Longitude);

        query.QueryCompleted += (s, e) =>
        {
            if (e.Error != null && e.Result.Count == 0)
                return;
            MessageBox.Show(e.Result[0].Information.Address.PostalCode);
        };
        query.QueryAsync();

        double lat = 0.00, lng = 0.00;
        lat = Convert.ToDouble(myGeoposition.Coordinate.Latitude);
        lng = Convert.ToDouble(myGeoposition.Coordinate.Longitude);

        this.MyMap.Center = new GeoCoordinate(lat, lng);
        this.MyMap.ZoomLevel = 7;
        this.MyMap.Show();
    }
    catch
    { }

}

@我选择如果我的answare满足了你的问题,那么接受这个。用于Emulator-始终显示相同的位置;(您是否更改了当前位置或停留在与以前相同的位置?是,使用emulator manager{编辑:重新打开应用程序后,它向我显示了新位置,让我检查它是否正常工作}您尝试了哪些代码?请将其签入设备。