Windows Phone的ReverseGeocoding从纬度和长期获得地址 [英] Windows Phone ReverseGeocoding to get Address from Lat and Long
问题描述
我使用以下服务引用摆脱纬度和longnitude
i am using the following service reference to get location details from latitude and longnitude
的 http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc
我添加了上面的URL到我的服务引用类,并尝试通过调用下面的方法
i added the above URL to my Service reference class and try to get the location details by calling the below method
public void reverse()
{
string Results = "";
try
{
// Set a Bing Maps key before making a request
string key = "Bing Maps Key";
ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();
// Set the credentials using a valid Bing Maps key
reverseGeocodeRequest.Credentials = new GeoCodeService.Credentials();
reverseGeocodeRequest.Credentials.ApplicationId = key;
// Set the point to use to find a matching address
GeoCodeService.Location point = new GeoCodeService.Location();
point.Latitude = 47.608;
point.Longitude = -122.337;
reverseGeocodeRequest.Location = point;
// Make the reverse geocode request
GeocodeServiceClient geocodeService = new GeocodeServiceClient();
**GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest);**
}
catch (Exception ex)
{
Results = "An exception occurred: " + ex.Message;
}
但我收到以下错误消息
but i am getting the following error message
-
GeoCodeService.GeoCodeServiceClient不包含ReverseGeocode的定义,并没有扩展方法
GeoCodeService.GeoCodeServiceClient does not contain a definition for ReverseGeocode and no extension method
GeoCodeService.GeoCodeServiceClient找不到。
GeoCodeService.GeoCodeServiceClient could not be found.
帮我解决的问题;还告诉我是这个找位置细节的最佳方式。
help me in solving the problem.and also tell me is this a best way to find location details .
推荐答案
在的Windows Phone 8已经内置了对反向地理编码API,而不需要添加一个服务引用到Bing地图的:
In Windows Phone 8 you have built-in API for reverse geocoding, without the need of adding a Service Reference to Bing Maps:
List<MapLocation> locations;
ReverseGeocodeQuery query = new ReverseGeocodeQuery();
query.GeoCoordinate = new GeoCoordinate(47.608, -122.337);
query.QueryCompleted += (s, e) =>
{
if (e.Error == null && e.Result.Count > 0)
{
locations = e.Result as List<MapLocation>;
// Do whatever you want with returned locations.
// e.g. MapAddress address = locations[0].Information.Address;
}
};
query.QueryAsync();
这篇关于Windows Phone的ReverseGeocoding从纬度和长期获得地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!