且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Windows Phone 8.1 通用应用程序中获取街道地址的地理位置?

更新时间:2023-01-26 09:56:42

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

Here is the code to get geolocation and also to launch the default map for directions

这里是 MSDN 链接

    // 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);
    }
}