I have a GPS cluster (contains many GPS points which are close to each other) and I want to identify it as a place by creating a polygon around its outer points. One way is Convex Hull and I am looking for its implementation in Javascript.
Any idea?
I have a GPS cluster (contains many GPS points which are close to each other) and I want to identify it as a place by creating a polygon around its outer points. One way is Convex Hull and I am looking for its implementation in Javascript.
Any idea?
Share Improve this question asked Jan 4, 2011 at 1:23 ZaheerZaheer 3755 silver badges20 bronze badges 1- 2 it looks relevant: geocodezip./map-markers_ConvexHull_Polygon.asp – Zaheer Commented Jan 4, 2011 at 1:28
2 Answers
Reset to default 3The following demo displays how to calculate a convex hull that will plot an outer boundary or the area for the given coordinates. This demo is implemented in javascript
http://www.geocodezip./v3_map-markers_convexhull.asp
The code for the demo is located at https://github./mgomes/ConvexHull
The convex hull is a concept that has not been provided in google maps API yet.
Yep. Check out the source in the tag. there's two separate scripts: one that executes the hull algorithm, and the other has the google maps API stuff in it.
In the example, the Initiation() function is called by the body's onload event, which sets up all of the listeners for click events, creates the random points and such.
Check out the algorithm for the hull, the chainHull_2D(P,n,H) function. It took me a bit to follow it but once I got a grasp it makes a lot of sense. The function spits H back out with the array of GLatLng of the hull. A GPolygon is then created using the array of GLatLng.
GPolygon implements googles maps overlay interface so you use the Map.addOverlay function to display the polygon.
Check this tutorial out too to better understand the maps API.