I have a \"place\" object from Google Maps which has a set of coordinates that represent a bounding box for a given location, say London. Each set of coordinates has a latit
To get the bounds of a Polygon (with your data) in the Google Maps API v3 (not tested):
var coords = [
[ -1.2, 5.1 ],
[ -1.3, 5.2 ],
[ -1.8, 5.9 ],
[ -1.9, 5.8 ]
];
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i
var coords = [
[-1.2, 5.1],
[-1.3, 5.2],
[-1.8, 5.9],
[-1.9, 5.8]
];
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < coords.length; i++) {
bounds.extend(new google.maps.LatLng(coords[i][0], coords[i][1]));
}
var center = bounds.getCenter();
var latitude = center.lat();
console.log("latitude=" + latitude);
var longitude = center.lng();
console.log("longitude=" + longitude);
var coordinates = center.toUrlValue();
console.log("coordinates=" + coordinates);