ReverseGeocodeQuery给出错误

时间:2013-08-19 14:09:24

标签: windows-phone-8 maps geocoding bing-maps reverse-geocoding

ReverseGeocodeQuery给出错误

1.in“GeoCoordinate(47.60887,-122.34094);”方法必须有返回类型

2.in“reverseGeocode.GeoCoordinate line”reverseGeocode是一个字段,但它的使用类似于..

ReverseGeocodeQuery reverseGeocode = new ReverseGeocodeQuery();
reverseGeocode.GeoCoordinate = new GeoCoordinate(47.60887, -122.34094);
reverseGeocode.QueryCompleted += reverseGeocode_QueryCompleted;
reverseGeocode.QueryAsync();
void reverseGeocode_QueryCompleted(objectsender,QueryCompletedEventArgs<IList<MapLocation>> e)
{
MapAddress geoAddress = e.Result[0].Information.Address;           
}

我使用了namespace--使用Microsoft.Phone.Maps.Services;

如何纠正这个错误..

1 个答案:

答案 0 :(得分:1)

GOT THE ANSWER

GeoCoordinateWatcher myLocationWatcher;
private GeoCoordinate MyCoordinate = null;
private async void GetCurrentCoordinate()
    {
        Geolocator geolocator = new Geolocator();
        geolocator.DesiredAccuracy = PositionAccuracy.High;

        try
        {
            Geoposition currentPosition = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10));
            _accuracy = currentPosition.Coordinate.Accuracy;

            MyCoordinate = new GeoCoordinate(currentPosition.Coordinate.Latitude, currentPosition.Coordinate.Longitude);

            if (MyReverseGeocodeQuery == null || !MyReverseGeocodeQuery.IsBusy)
            {
                MyReverseGeocodeQuery = new ReverseGeocodeQuery();
                MyReverseGeocodeQuery.GeoCoordinate = new GeoCoordinate(MyCoordinate.Latitude, MyCoordinate.Longitude);
                LongitudeTextBlock.Text = MyCoordinate.Longitude.ToString();
                LatitudeTextBlock.Text = MyCoordinate.Latitude.ToString();
                MyReverseGeocodeQuery.QueryCompleted += ReverseGeocodeQuery_QueryCompleted;
                MyReverseGeocodeQuery.QueryAsync();
            }

        }
        catch (Exception ex)
        {
            // ...

        }

    }


    public void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
    {
        if (e.Error == null)
        {
            if (e.Result.Count > 0)
            {
                MapAddress address = e.Result[0].Information.Address;
                labelResults.Text = "Current Location: " + address.City + ", " + address.State;
            }
        }
    }


    public void Button_Click(object sender, RoutedEventArgs e)
    {
        GetCurrentCoordinate();

    }