Creates a polygon, with the given array of coordinates in in format
[lng, lat].
- Source:
Example
//From https://developers.google.com/maps/documentation/javascript/examples/polygon-simple const myPolygon = polygonFactory([ [-80.190, 25.774], [-66.118, 18.466], [-64.757, 32.321], [-80.190, 25.774] ]); let { lat, lng } = myPolygon.getPolygonCenter(); consle.log(`Center is: ${lat}, ${lng}`); myPolygon.getCoordinates().forEach(elem => { console.log(`Coord is ${elem.lat}, ${elem.lng}`); });
Methods
-
<inner> getCoordinates()
-
Returns the array of coordinates of this polygon. It is calculated only once during the polygon's creation.
- Source:
Returns:
The array of coordinates from the polygon.- Type
- Array
-
<inner> getPolygonCenter()
-
Returns the center coordinate of this polygon. It is calculated only once during the polygon's creation.
- Source:
Returns:
The coordinate that represents the geometric center of the polygon.- Type
- Coordinate