2012-01-28 3 views
3

私はAndroidを使い始め、それを学ぶのがとても新しいです。だから私は、固定位置が固定されている場所を示すためのポインタのような矢印を作成したい、ユーザーがデバイスを移動すると、矢印は自動的に(コンパスのように)更新する必要があります。Androidが定位置にあることを発見しました

私はリソースのためにグーグルを見つけましたが、私はそれを見つけることができませんでした。誰でもここでそれを行う方法を知っていますか?任意の例やチュートリアルは非常に高く評価されます。

例:

fixed location: 20 latitude, 50 longitude 
my location: 5 latitude 25, longitude 
So how do i find the arrow pointed to fixed location? 

答えて

6

curLatとcurLonは、現在位置の緯度及び経度とrefLatとrefLonは、基準位置の緯度と経度である場合は、同様の参照位置に現在位置から軸受を得ることができている場合これ:

final float[] results= new float[3]; 
// The computed distance in meters is stored in results[0]. 
// If results has length 2 or greater, the initial bearing is stored in results[1]. 
// If results has length 3 or greater, the final bearing is stored in results[2]. 
Location.distanceBetween(curLat, curLon, refLat, refLong, results); 
final float bearing = results[1]; 

距離がもたらす成長場合は[2]の結果から、より多くの異なる現在位置から基準位置までコースは等角航路(又はloxodromeを以下のない限り、[1]、ここで参照:http://en.wikipedia.org/wiki/Rhumb_line)。

関連する問題