【发布时间】:2011-08-19 06:57:46
【问题描述】:
我从@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
- 左上:41.866514127810355,-87.6720142364502
- 右下:41.83397145565242,-87.62824058532715
- 地图宽度:512 x 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
我得到了以下结果:
- 斜边 = 2581
- 轴承 = 135.21
- currentDistanceX = -2562
- currentPixelX = 311.9
想请大家:
- 确认我的计算结果是否正确。
- 关于如何计算 currentPixelY(另一个点)?
顺便说一句,我打算用它来计算给定现实生活 LatLng(current) 的位置,并与我的静止图像地图结合起来,将静止图像的左上角和右下角结合到现实生活 LatLng 中。
如果您想查看实际和预期的输出并想轻松了解整个情况。请参考此链接->How to mark the current location into a still image map
【问题讨论】:
标签: android geolocation imagemap bearing hypotenuse