问题
I get the latitude and longitude value using
void _watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
latitude = e.Position.Location.Latitude;
longitude = e.Position.Location.Longitude;
MessageBox.Show("Latitude & Longitude:" + latitude + " " + longitude);
}
Result like: Latitude & Longitude: 12.56 77.34
Now i want to these value to relevant address. Is it possible. Please give the brief explanation. Thanks in advance.
回答1:
In Windows Phone 8 you can do it easily using the integrated ReverseGeocodeQuery class. For example:
string address;
ReverseGeocodeQuery query = new ReverseGeocodeQuery();
query.GeoCoordinate = new GeoCoordinate(12.56, 77.34);
query.QueryCompleted += (s, e) =>
{
if (e.Error != null)
return;
address = e.Result[0].Information.Address.Street;
};
query.QueryAsync();
As simple as that.
For Windows Phone 7, however, you would need to use Bing services.
回答2:
Firstly, Your question is not clear, I think your requirement is from this lat/long you need to fetch the corresponding address. For doing so you can use Bing services, Bing is providing several API's that support the same. In you case you can use the following API
http://dev.virtualearth.net/REST/v1/Locations/47.64324%2c-122.14197?includeEntityTypes=Address,Postcode1,AdminDivision1,AdminDivision2&key={Bing Map Key}&o=json
From this the 47.64, and -122.11 are my sample geocodes, For achieving complete functionality you need to create a Bing Map key (here is the link for your reference )
after creating the key use it on the {Bing Map Key}
area. Without brackets. Then a simple http GET method will solve your problem.
OR
Simply you can use,
var query = new ReverseGeocodeQuery {GeoCoordinate = new GeoCoordinate(12.56, 77.34)};
query.QueryCompleted += (s, e) =>
{
if(e.Error != null)
return;
var address = e.Result[0].Information.Address.Street;
};
query.QueryAsync();
来源:https://stackoverflow.com/questions/18613578/how-to-convert-longitude-and-latitude-value-to-address-in-windows-phone