2015-12-02 108 views
1

我目前有下列方法被選中時選擇一個位置。搜索經緯度bing地圖 - c#

而不是傳遞城市名稱作爲參數搜索,我想通過使用緯度和經度搜索位置。

我將檢索所選城市的經度和緯度。

我需要如何修改此代碼才能獲得此代碼?

謝謝

private void xgrdLocation_SelectedItemChanged(object sender, SelectedItemChangedEventArgs e) 
     { 
      this.Cursor = Cursors.AppStarting; 
      lblFooter.Content = "Searching ..."; 
      pushpin = new MapPushpin(); 
      if (xgrdLocation.SelectedItem != null) 
      { 
       City selectedCity = xgrdLocation.SelectedItem as City; 
       //GeocodeService.Location point = new GeocodeService.Location(); 
       pushpin.Text = selectedCity.CityName; 
       searchDataProvider.Search(pushpin.Text); 
       //lblSelectedCity.Content = selectedCity.CityName; 
      } 
     } 
+1

[位置API](https://msdn.microsoft.com/en-gb/library/ff701715.aspx)和[可能相關的現有SO帖子](http://stackoverflow.com/questions/5698014/visual -studio-2010-bing-map-location-finder-by-longitude-latitude) – sab669

+0

這是什麼類型的項目? WPF? ASP.NET? – Greg

+0

@greg wpf。謝謝 – Walking

回答

0

如果你想要得到的城市,經/緯度值是,可以使用反向地址解析。 Bing Maps REST Location API具有這樣的功能。 https://msdn.microsoft.com/en-us/library/ff701710.aspx

您還可以找到有關如何在.NET這裏使用REST服務文檔:https://msdn.microsoft.com/en-us/library/jj819168.aspx

不知道,但它看起來像你可能會使用舊的傳統SOAP服務在您的應用程序做地理編碼目前。避免使用SOAP服務,它們老舊,緩慢且即將結束生命。