【问题标题】:How do I get Geolocation of a street address in Windows Phone 8.1 Universal App?如何在 Windows Phone 8.1 通用应用程序中获取街道地址的地理位置?
【发布时间】:2014-05-19 12:38:37
【问题描述】:

我的 Windows Phone 用户将在文本字段中输入街道地址。我需要获取该地址字符串的地理位置,以便稍后计算该地理位置和手机当前地址的距离。

所以,我的问题是:
如何在 Windows Phone 8.1 通用应用中获取街道地址的地理位置?

我在 this stackoverflow answer 中找到了一个解决方案,但是,它适用于旧版 Silverlight 应用程序,而不是我当前使用的新 Universal Store 应用程序 API。

【问题讨论】:

    标签: c# windows-runtime windows-phone-8.1


    【解决方案1】:

    这是获取地理位置和启动默认地图的代码

    这里是MSDN link

        // Nearby location to use as a query hint.
    BasicGeoposition queryHint = new BasicGeoposition();
        // DALLAS
    queryHint.Latitude = 32.7758;
    queryHint.Longitude = -96.7967;
    
    Geopoint hintPoint = new Geopoint(queryHint);
    
    MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync(
                            "street, city, state zip",
                            hintPoint,
                            3);
    
    if (result.Status == MapLocationFinderStatus.Success)
    {
        if (result.Locations != null && result.Locations.Count > 0)
        {
            Uri uri = new Uri("ms-drive-to:?destination.latitude=" + result.Locations[0].Point.Position.Latitude.ToString() +
                "&destination.longitude=" + result.Locations[0].Point.Position.Longitude.ToString() + "&destination.name=" + "myhome");
    
            var success = await Windows.System.Launcher.LaunchUriAsync(uri);
        }
    }
    

    【讨论】:

    • 哇,太棒了——我到处找这个链接。我想我错过了“地图服务”这个关键词。谢谢!
    • 测试了它,它就像一个魅力!再次感谢!
    • 如果我没有“查询提示”位置怎么办?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-01
    • 1970-01-01
    • 2016-03-07
    • 1970-01-01
    • 1970-01-01
    • 2015-12-06
    相关资源
    最近更新 更多