How to sort points in a Google maps polygon so that lines do not cross?

后端 未结 3 438
庸人自扰
庸人自扰 2021-01-19 02:23

I am trying to make a map where a user can outline any shape they would like. But I am running into an issue where users can select points that will make the lines of the p

3条回答
  •  无人及你
    2021-01-19 02:59

    It's not a convex hull.

    Imagine if you had a stop at "Linfield Oaks" near where those two lines cross. A convex hull would skip this and draw a straight line between "international" and "82"

    What you are trying to do is determine if each new point is inside the polygon formed by the existing points - if it is then you need to break the nearest polygon side and insert the new point in that edge. See http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm for point in polygon tests.

提交回复
热议问题