Google Map Api V3 系列之 Polygon 获取中心点方法

var bounds = new google.maps.LatLngBounds();
var i;

// The Bermuda Triangle
var polygonCoords = [
  new google.maps.LatLng(25.774252, -80.190262),
  new google.maps.LatLng(18.466465, -66.118292),
  new google.maps.LatLng(32.321384, -64.757370),
  new google.maps.LatLng(25.774252, -80.190262)
];

for (i = 0; i < polygonCoords.length; i++) {
  bounds.extend(polygonCoords[i]);
}
/// alert the center
alert(bounds.getCenter());  //the center is polygon center
posted @ 2012-05-04 15:23  Sam.山子  阅读(2231)  评论(0编辑  收藏  举报