How to convert a cit开发者_开发技巧y/state to a geo location (lat/long) using bing?
This example uses Yahoo's API but gets the job done for me. Will work if you just submit a zipcode or city,state. I use a dataset because I'm addicted to them.
private void YahooParseLatLon(string address_)
{
HttpWebRequest feed =
HttpWebRequest.Create("http://local.yahooapis.com/MapsService/V1/geocode?
appid=YOUR_APID&street=" + address_) as HttpWebRequest;
WebResponse feedresponse = default(WebResponse);
feedresponse = feed.GetResponse();
DataSet data = new DataSet();
data.ReadXml(feedresponse.GetResponseStream());
if (!string.IsNullOrEmpty(data.Tables(0).Rows(0).Item("Address"))) {
//process lat lon values
string lat = data.Tables(0).Rows(0).Item("Latitude");
string lon = data.Tables(0).Rows(0).Item("Longitude");
}
else {
//process no address found
}
data.Dispose();
feedresponse = null;
feed = null;
}
I use this to collect lat/lon for addresses on new orders placed in my company's system. I then use this data to populate a map integrated into a scheduling application for our field agents.
I've found a geotag generator use can use.
Here is a complete tutorial on MSDN to do what you are looking for.
Note you want to make sure you are linking to 7.0 and NOT 6.3.
精彩评论