我无法在wp7中创建ReverseGeocodeRequest即时

时间:2012-05-02 17:35:17

标签: windows-phone-7

我在wp7中使用Geocode Service从纬度和经度中获取CountryName 我写了以下内容: -

GeoCoordinate location1 = null;
    private GeoCoordinateWatcher watcher;
    public void FindCountryUsingGps()
    {
        progressbar.Visibility = Visibility.Visible;
        watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
        watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
        watcher.Start(); 

    }

    void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
    {
        if (watcher != null)
        {

            watcher.Stop();
            watcher.Dispose();
            watcher = null;

            location1 = e.Position.Location;
            ObtainCountry();//by this function you obtain country region
        }
    }

然后添加以下参考: - enter image description here 之后 我写了

public void ObtainCountry()
        {
            if (location == null)
                return;

            ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();

但我不能写这个 ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();  线,它是红色的

在wp7中,这是什么?

1 个答案:

答案 0 :(得分:0)

尝试删除/重新添加服务引用。有时我遇到代码无法正确生成的问题。代码应位于ServiceReference文件夹下,名为Reference.cs。

的代码文件中