我正在尝试为我的 MKMapItem
设置字典,以使用特定方向模式(步行、驾驶、交通等)打开设置为特定位置的 native map 应用程序。
当我尝试做类似的事情时:
NSMutableDictionary *launchOptions = [[NSMutableDictionary alloc] init];
[launchOptions setObject:MKLaunchOptionsDirectionsModeDriving forKey:MKLaunchOptionsDirectionsModeKey];
在 C# 中,我在 Xamarin 中找不到 key MKLaunchOptionsDirectionsModeKey
。
我的 DirectionsMode
值在这里,并根据传递给我的函数的参数进行更改。
MapKit.MKDirectionsMode LaunchOptionsDirectionsMode;
switch (sMode)
{
case 1:
LaunchOptionsDirectionsMode = MKDirectionsMode.Driving;
break;
case 2:
LaunchOptionsDirectionsMode = MKDirectionsMode.Driving;
break;
case 3:
LaunchOptionsDirectionsMode = MKDirectionsMode.Walking;
break;
default:
LaunchOptionsDirectionsMode = MKDirectionsMode.Driving;
break;
}
var emptyDict = new NSDictionary();
var endingCoord = new CoreLocation.CLLocationCoordinate2D(sLat, sLng);
var endLocation = new MKPlacemark(endingCoord, addressDictionary: emptyDict);
var endingItem = new MKMapItem(endLocation);
var launchOptions = new NSMutableDictionary();
var t = new MKMapItem();
launchOptions.Add(??????, LaunchOptionsDirectionsMode);
最佳答案
您正在寻找 MKDirectionsMode
枚举。
launchOptions.Add(MKDirectionsMode.Driving, LaunchOptionsDirectionsMode);
这是在 MapKit
命名空间中找到的。
更新
您不需要使用字典,在您的情况下,您可以使用 MKLaunchOptions
类来设置方向。
var launchOptions = new MKLaunchOptions();
launchOptions.DirectionsMode = LaunchOptionsDirectionsMode;
endingItem.OpenInMaps(launchOptions);
关于c# - Xamarin.iOS MKLaunchOptionsDirectionsModeKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44806903/