地图api:检查标记是否落在多段线的左侧或右侧 [英] Maps api: check if a marker falls to the left or right of a polyline
问题描述
我目前正在开发一个使用maps API的应用程序,我有一个多段线,开始为LatLnt,最后以LatLng 2结束,创建一条直线。如果我的Marker接近这个折线,我该如何判断这个折线是在折线的左边还是右边?
有没有API utils处理这样的几何计算?
你有坐标L0,L1作为起点和终点的直线和标记坐标P.
找到方向L0-L1和L0-P的方位角(标题,轴承)
AL =方位角(L0,L1)
AP =方位角(L0,P)
并找出它们的差异
DA = AP - AL
如果DA < 0则
DA = DA + 360
如果DA < 180然后
左边
其他
右边
I'm currently developing an app using maps API, I have a polyline that is that start as LatLnt one and ends at LatLng two creating a straight line. If I have a Marker that falls somewhere close to this polyline how would I tell if the marker is to the left or to the right of the polyline?
Are there any API utils that handles such geometric calculations?
You have coordinates L0, L1 for starting and ending points of line and marker coordinate P.
Find azimuths for directions L0-L1 and L0-P (heading, bearing)
AL = Azimuth(L0,L1)
AP = Azimuth(L0,P)
and find their difference
DA = AP - AL
if DA < 0 then
DA = DA + 360
if DA < 180 then
left side
else
right side
这篇关于地图api:检查标记是否落在多段线的左侧或右侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!