我的windows-phone-8项目。
XAML代码:
<Controls:Map x:Name="MyMap" Tap="MyMap_Tap"/>当点击事件的火,我可以得到长和Lat在消息框,像这样
C#代码:
private void MyMap_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
GeoCoordinate location = MyMap.ConvertViewportPointToGeoCoordinate(e.GetPosition(MyMap));
MessageBox.Show("latitude :" + location.Latitude +", longitude : " + location.Longitude);
}我还需要得到这个职位的名字,加上它的长和拉特,所以我怎么能做到这一点。
谢谢
发布于 2014-04-16 12:32:37
您可以使用从坐标到地址的反向地理编码转换:
private void Maps_ReverseGeoCoding(object sender, RoutedEventArgs e)
{
ReverseGeocodeQuery query = new ReverseGeocodeQuery()
{
GeoCoordinate = new GeoCoordinate(YourLatitude, YourLongitude)
};
query.QueryCompleted += query_QueryCompleted;
query.QueryAsync();
}
void query_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
{
StringBuilder placeString = new StringBuilder();
foreach (var place in e.Result)
{
placeString.AppendLine(place.GeoCoordinate.ToString());
placeString.AppendLine(place.Information.Name);
placeString.AppendLine(place.Information.Description);
placeString.AppendLine(place.Information.Address.BuildingFloor);
placeString.AppendLine(place.Information.Address.BuildingName);
placeString.AppendLine(place.Information.Address.BuildingRoom);
placeString.AppendLine(place.Information.Address.BuildingZone);
placeString.AppendLine(place.Information.Address.City);
placeString.AppendLine(place.Information.Address.Continent);
placeString.AppendLine(place.Information.Address.Country);
placeString.AppendLine(place.Information.Address.CountryCode);
placeString.AppendLine(place.Information.Address.County);
placeString.AppendLine(place.Information.Address.District);
placeString.AppendLine(place.Information.Address.HouseNumber);
placeString.AppendLine(place.Information.Address.Neighborhood);
placeString.AppendLine(place.Information.Address.PostalCode);
placeString.AppendLine(place.Information.Address.Province);
placeString.AppendLine(place.Information.Address.State);
placeString.AppendLine(place.Information.Address.StateCode);
placeString.AppendLine(place.Information.Address.Street);
placeString.AppendLine(iplaceem.Information.Address.Township);
}
MessageBox.Show(placeString.ToString());
}https://stackoverflow.com/questions/23109513
复制相似问题