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

你可能感兴趣的:(google map)