如何在Windows 8.1应用程序中使用地理编码
本文关键字:编码 应用程序 Windows | 更新日期: 2023-09-27 17:51:02
我需要从地址获取地理坐标。我试着这样做:http://www.braincastexception.com/wp7-web-services-first-part-geocodeservice/但是有一些错误
1)错误参数:
GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
2)事件不存在:
geocodeService.GeocodeCompleted += (sender, e) => geoCode_GeocodeCompleted(sender, e);
这篇文章涉及Windows Phone 7,但我与Windows 8.1应用程序工作。也许有一个Windows 8.1应用程序的另一个解决方案?我该怎么办?
按如下方式进行地理编码:
async void GetLocation(string address, Geopoint queryHintPoint)
{
var result = await MapLocationFinder.FindLocationsAsync(address, queryHintPoint);
// Get the coordinates
if(result.Status == MapLocationFinderStatus.Success)
{
double lat = result.Locations[0].Point.Position.Latitude;
double lon = result.Locations[0].Point.Position.Longitude;
}
}
和反转地理编码:
async void GetLocationName(Geopoint yourLocation)
{
var result = await MapLocationFinder.FindLocationsAtAsync(yourLocation);
// Get the address
if(result.Status == MapLocationFinderStatus.Success)
{
string address = result.Locations[0].Address.StreetNumber + result.Locations[0].Address.Street;
}
}
查看这篇文章:http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn631249.aspx
它解释了如何在Windows Phone 8.1地图中获取位置。
尝试使用Bing Maps的REST API。
查找地址
的例子:
http://dev.virtualearth.net/REST/v1/Locations/YOUR_ADDRESS_HERE?o=json&关键= BING_MAP_KEY