Reputation: 227
I have a collection of Markers in an array which were pushed when user clicked on map, and need to place polygon over map using these markers. it works fine if markers are in proper order, which means when user clicked them in any particular direction.
But if he user clicked on map randomly, markers would be random and the polygon looks as follows.
How can I sort these markers so that how ever the user clicked on map, I get a polygon as depicted in first image??
Upvotes: 2
Views: 2938
Reputation: 52185
You will need to find the Convex Hull of the points. You should find some help on this Google Page (You will need to view the source of the page).
Upvotes: 4