2015-12-02 116 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服务,它们老旧,缓慢且即将结束生命。