## Google Maps API Tutorial© 2007, 2008, 2009 Mike Williams |

Translate this page: |

## EPolysThe EPoly extension adds seven extra methods to the GPolygon and GPolyline Classes.
To use it, copy the <script src="epoly.js" type="text/javascript"> </script>
Here's an
[Here's an
[The XML file that they use is ## .Contains(latlng)Returns true if the GLatLng is inside the poly and false if the GLatLng is outside.The method works for closed or open polygons and polylines. If the shape is open, it considers there to be an additional virtual line from the last point to the first. If the point happens to lie exactly on the boundary of the polygon, then it may return either true or false. ## .Area()Returns the approximate area of the poly in square metres.The method works for closed or open polygons and polylines. If the shape is open, it considers there to be an additional virtual line from the last point to the first. The method doesn't fully account for spherical geometry, so the areas of large regions will be less accurate. ## .Distance()Returns the total length of the path in metres## .Bounds()Returns the bounds of the polygon or polyline as a GLatLngBounds Object.## .GetPointAtDistance(metres)Returns the GLatLng of a point at the specified distance along the path.
## .GetPointsAtDistance(metres)Returns an array of GLatLngs of points at the specified interval along the path.By calculating all the points in a single pass, this runs a lot faster than calling GetPointAtDistance() in a loop. If the path is shorter than the specified distance, then it returns null. You could use this for placing mile markers along a route, like this: var points = poly.GetPointsAtDistance(1609.344); for (var i=0; i<points.length; i++) { map.addOverlay(new GMarker(points[i])); }[There are 1609.334 metres in a mile.] ## .GetIndexAtDistance(metres)Returns the vertex number at or after the specified distance along the path.## .Bearing(v1?,v2?)Returns the bearing between vertex v1 and vertex v2. Both parameters are optional.
If you omit v1, then the bearing from the first to last vertex is calculated. The returned values are in degrees, rounded to one decimal place (because that's about the accuracy of the method used). |