我试图用Apple的地图来显示两个地方的路线。如何设置MKPlacemark的显示名称?
对于这两个地方,我有名字和坐标。
MKMapItem *currentLocation = [[MKMapItem alloc]
initWithPlacemark:[[MKPlacemark alloc]
initWithCoordinate:paramModel.fromCoordinate2D
addressDictionary:nil]];
MKMapItem *toLocation = [[MKMapItem alloc]
initWithPlacemark:[[MKPlacemark alloc]
initWithCoordinate:paramModel.toCoordinate2D
addressDictionary:nil]];
return [MKMapItem openMapsWithItems:@[ currentLocation, toLocation ]
launchOptions:@{
MKLaunchOptionsDirectionsModeKey :
MKLaunchOptionsDirectionsModeDriving
}];
这些名字存储在paramModel
里面。
我认为这可以通过使用addressDictionary
来实现?我尝试了kABPersonAddressStreetKey
和kABPersonAddressCityKey
,但两者都不会显示在最终路线视图中。
对不起,但'title'和'subtitle'字段似乎是'readonly'? –