简体   繁体   English

使用经度和纬度搜索bing地图-C#

[英]Search bing maps with latitude and longitude - c#

I currently have the following method being called whenever a location is selected. 当前,无论何时选择位置,我都会调用以下方法。

Instead of passing the city name as the parameter to search by, I would like to search locations by using latitudes and longitudes. 我不想通过传递城市名称作为参数来搜索,而是想使用纬度和经度来搜索位置。

I will be retrieving the latitude and longitude of the selected city. 我将检索所选城市的经度和纬度。

How would I need to modify this code in order to obtain this? 我将如何修改此代码以获得此代码?

Thank you 谢谢

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;
            }
        }

If you want to get the city that a latitude/longitude value is in, you can use the Reverse Geocoding. 如果您想获取经度/纬度值所在的城市,则可以使用反向地理编码。 The Bing Maps REST Location API has such a feature. Bing Maps REST位置API具有此功能。 https://msdn.microsoft.com/en-us/library/ff701710.aspx https://msdn.microsoft.com/en-us/library/ff701710.aspx

You can also find documentation on how to use the REST services in .NET here: https://msdn.microsoft.com/en-us/library/jj819168.aspx 您还可以在这里找到有关如何在.NET中使用REST服务的文档: https : //msdn.microsoft.com/zh-cn/library/jj819168.aspx

Not sure, but it looks like you might be using the old legacy SOAP services in your application to do the geocoding currently. 不确定,但是看起来您可能正在应用程序中使用旧的旧SOAP服务来进行地理编码。 Avoid the SOAP services, they are old, slow and nearing end of life. 避免使用SOAP服务,因为它们过时,缓慢并且即将终止生命。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM