我試圖用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'? –