CLLocationCoordinate2D start = {currentLat, currentLng};
CLLocationCoordinate2D dest = {pinLat, pinLng};
NSString *urlStr = [NSString stringWithFormat:
@"https://maps.google.com/?saddr=%f,%f&daddr=%f,%f",
start.latitude, start.longitude, dest.latitude, dest.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
優點:零開發成本、導航體驗完整;缺點:跳出 App、需安裝 Google Maps。
https://maps.googleapis.com/maps/api/directions/json?origin=...&destination=...&key=YOUR_KEYroutes[0].overview_polyline.points(編碼後的路徑點)CLLocationCoordinate2D 陣列MKPolyline 加入 MKMapView 顯示MKDirections (iOS 7+) 可離線/免費計算路徑,但僅支援駕車/步行,無大眾運輸