简体   繁体   中英

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. 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

Not sure, but it looks like you might be using the old legacy SOAP services in your application to do the geocoding currently. Avoid the SOAP services, they are old, slow and nearing end of life.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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