Problem

Users can provide up to four latitude and longitude coordinates, in any order. They do so with Google Maps. Using Google's Polygon API (v3), the coordinates they select should highlight the selected area between the four coordinates.

Question

How do you sort an array of latitude and longitude coordinates in (counter-)clockwise order?

Solutions and Searches

StackOverflow Questions

Related Sites

Known Algorithms

  • Graham's scan (too complicated)
  • Jarvis March algorithm (handles N points)
  • Recursive Convex Hull (removes a point)

Code

Here is what I have so far:


                    
                    
                    
Edit
Report