首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Windows 8中,当我点击地图中的任何地方时,我会检索Lattiand经度和特定的位置名称

在Windows 8中,当我点击地图中的任何地方时,我会检索Lattiand经度和特定的位置名称
EN

Stack Overflow用户
提问于 2014-04-16 12:29:14
回答 1查看 366关注 0票数 0

我的windows-phone-8项目。

XAML代码:

代码语言:javascript
复制
<Controls:Map x:Name="MyMap" Tap="MyMap_Tap"/>

当点击事件的火,我可以得到长和Lat在消息框,像这样

C#代码:

代码语言:javascript
复制
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);
}

我还需要得到这个职位的名字,加上它的长和拉特,所以我怎么能做到这一点。

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-16 12:32:37

您可以使用从坐标到地址的反向地理编码转换:

代码语言:javascript
复制
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());
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23109513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档