在WP8.1应用程序中使用地址调用导航/地图/驱动器

本文关键字:导航 调用 地图 驱动器 地址 WP8 应用程序 | 更新日期: 2023-09-27 18:10:30

我想知道是否可以在我的Windows Phone 8.1应用程序中调用默认导航应用程序。我有一个地址,我想让用户按下一个按钮,并能够导航到该地址通过默认的导航应用程序。如果这是可能的,我怎么做?

谢谢你的时间,

Johan

在WP8.1应用程序中使用地址调用导航/地图/驱动器

你可以使用ms-drive-to和ms-walk-to方案启动逐向导航应用程序(取决于你想要的方向类型),但你首先需要获得你所拥有的地址的地理坐标。因为你的目标是Windows Phone 8.1,你可以使用Windows. services . maps命名空间中的MapLocationFinder类。

string locationName = "Empire State Building";
string address = "350 5th Avenue, New York City, New York 10018";
var locFinderResult = await MapLocationFinder.FindLocationsAsync(
    address, new Geopoint(new BasicGeoposition()));
// add error checking here
var geoPos = locFinderResult.Locations[0].Point.Position;
var driveToUri = new Uri(String.Format(
     "ms-drive-to:?destination.latitude={0}&destination.longitude={1}&destination.name={2}", 
     geoPos.Latitude, 
     geoPos.Longitude, 
     locationName));
Launcher.LaunchUriAsync(driveToUri);                    

官方的解决方案是:

Uri uri = new Uri("ms-drive-to:?destination.latitude=" + latitude.ToString(CultureInfo.InvariantCulture) +
            "&destination.longitude=" + longitude.ToString(CultureInfo.InvariantCulture))
        var success = await Windows.System.Launcher.LaunchUriAsync(uri);
        if (success)
        {
            // Uri launched.
        }
        else
        {
            MessageBox.Show("error");
        }

但是,这个解决方案有一个问题。

如果你使用诺基亚程序(这里),它工作良好。

如果你想使用waze,你必须添加origin。纬度和原点经度

在MSDN页面,他们说这是没有必要的,但实际上,你必须写它。

我已经不能加载movit,但如果有人有问题,它会帮助我很多。