0
我從@DanS下面的代碼,在此鏈接how-to-display-a-map-still-image-file-with-a-moving-current-location如何計算斜邊和軸承
onCurrentPosition(Location current){
double hypotenuse = upperLeft.distanceTo(current);
double bearing = upperLeft.bearingTo(current);
double currentDistanceX = Math.cos(bearing) * hypotenuse;
// "percentage to mark the position"
double currentPixelX = (currentDistanceX/upperLeft.distanceTo(lowerRight) * Math.cos(upperLeft.bearingTo(lowerRight))) * mapWidth;
moveIndicatorX(currentPixelX);
}
這裏是值:
- 電流:41.850033,-87.65005229999997
- upperLeft: 41.866514127810355,-87.6720142364502
- lowerRight:41.83397145565242,-87.62824058532715
- mapWidth:512×512像素
這裏有計算器在線位置,斜邊(距離),軸承(方位角)
- convert LatLng to Location format(e.g. 41° 51′ 59.45″ N 87° 40′ 19.25″ W)
- compute distance & azimuths from the given Location
我得到了結果:
- hyp otenuse = 2581
- 軸承= 135.21
- currentDistanceX = -2562
- currentPixelX = 311.9
想問一下你們到:
- 確認,如果我的計算結果正確。
- 關於如何計算currentPixelY(另一個點)?
順便說一句,我打算用它來計算給定現實生活中的位置,經緯度(電流)對與粘接靜止圖像的upperLeft和lowerRight角落到現實生活中我的靜態圖像地圖經緯度。
如果你想看到實際的&預期輸出,並且想要輕鬆理解整個圖片。請參考此鏈接 - >How to mark the current location into a still image map
你會介意如何顯示圖像映射並標記給定的當前座標嗎?你有樣本eclipse項目分享嗎? – eros
你有任何你已經開始的代碼嗎? –