2016-07-13 10 views
8

私はアプリケーションを開発しています.Apple Mapsセッションを開き、緯度と経度の座標を渡して、その場所のユーザーの現在地からの道順を取得する必要があります。iOS - 緯度と経度のある方向のApple Mapsを開きます

これは私がすでにやっているGoogleマップで行うことができますが、アップルマップでURLを開くと、ユーザーの現在地から目的地までの道順ではなく場所が開きます。

http://maps.apple.com/?ll=(someLatitude),(someLongitute) 

コード:

UIApplication.sharedApplication().openURL(NSURL(string:"http://maps.apple.com/?ll=\(locationLat),\(locationlong)")!) 

を任意の助けをいただければ幸いです。ここ

は、私が使用しているURLスキームですありがとう!

+1

あなたは理にかなっているリンゴのマップに – dan

+0

ああを開くために 'openInMapsWithLaunchOptions()'メソッドを使用して、あなたの場所に 'MKMapItem'を作成する必要があります。ありがとう! – randomorb2110

+0

このコードを試してみてください:[link](https://gist.github.com/matthijsotterloo/3def603f224d83f2b8f620f2174c535e) –

答えて

5

currentLat currentLongで

NSURL(string:"http://maps.apple.com/?saddr=\(currentLat),\(currentLong)&daddr=\(destinationLat),\(destinationLong)")! 

を使用しようとは、ユーザーが現在の場所で、destinationLat destinationLongは、宛先の場所です。 (例:トランスポート・タイプ)

以上のパラメータhere

17

を見ては、このコードを試してみてください、AppleMapは座標を指定された場所に、デバイスの現在の場所からマークさ方向に開きます。

 let coordinate = CLLocationCoordinate2DMake(currentLat, currentLong) 
     let mapItem = MKMapItem(placemark: MKPlacemark(coordinate: coordinate, addressDictionary:nil)) 
     mapItem.name = “Destination/Target Address or Name” 
     mapItem.openInMapsWithLaunchOptions([MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving]) 
関連する問題