Android的GoogleMap的V2:怎样绘制具有特定长度的线?长度、Android、GoogleMap

2023-09-03 22:04:34 作者:初春旖旎

我在我的项目中的GoogleMap的。它在缩放级别18集我想画一条线,1米长。我看到并使用code这样的:

I have a GoogleMap in my project. It's set in zoom level 18. I want to draw a line that is 1 meter in length. I saw and use a code Like this:

googleMap.addCircle(new CircleOptions()
     .center(latLng1)
     .radius(5)
     .fillColor(Color.BLUE));     

我给它的半径米。 ?我怎么能做到这一点用一根线(折线没有这个选项),具体经纬度和具体方向(例如:从北标题)线和具体的长度是多少? 我可以通过正弦和余弦指定方向..但我能做些什么的线长?

I gave it's radius in meters. how can I do it with a line?(polyLine doesn't have this options) a line with specific LatLng and specific direction(for example: Heading from north) and specific length? I can specify direction by sin and cos.. but what can I do for length of the line?

推荐答案

对于给定的点,只有一个给定半径的圆。但随着线路的情况有点不同。对于给定的点也有从这个点和给定长度开始行数限制。因此,你不能简单的得出这样的行。

For given point there is only one circle with given radius. But with lines the situation is a bit different. For given point there are infinite number of lines starting from this points and given length. Therefore you can't simple draw such line.

要做到这一点的方法之一是挑对半径1米圆点和中心你的观点。 Here就是一个很好的例子,如何来计算给定半径的圆点。比只画在两个点之间的线。

One way to do it is to pick a point on the circle with radius 1 meter and center your point. Here is a good example how to calculate point on a circle with given radius. Than just draw a line between the two points.

更新:

这可能会帮助你如何找到在圆LatLng点在机器人圆圈面罩地图V2

This may help you how to find the LatLng points on the circle LatLng Points on circle on Goggle Map V2 in android