我正在尝试实现一个使用方向传感器的箭头来指向特定位置。 Google Places 在 ListView 中为它找到的每个地点实现此箭头。
我已经设法获得方位角,但给定位置,我不知道如何继续计算我需要的角度。此外,我需要进行真北和磁北的转换。有人有这样的实现的例子吗?
提前致谢。
I'm trying to implement an arrow that uses the orientation sensor in order to point towards a specific location. Google Places implements this arrow in a ListView for each place it finds.
I've managed to get the azimuth, but given a location, I don't know how to proceed to calculate the angle I need. Moreover, I need to make the conversions from real north and magnetic north. Does anybody have an example of such implementation?
Thanks in advance.
发布评论
评论(1)
我解决了。
如果您要绘制箭头或其他东西来指向方向,请使用canvas.rotate(-direction)。我们传递一个负参数,因为画布旋转是逆时针的。
I solved it.
If you're going to draw an arrow or something else to point to the direction, use canvas.rotate(-direction). We pass a negative argument because canvas rotations are anti-clockwise.