我计算了多边形的中心:
<script>
google.maps.Polygon.prototype.getPolygoneBounds = function () {
var bounds = new google.maps.LatLngBounds();
this.getPath().forEach(function (element, index) { bounds.extend(element); });
return bounds;
}
...
var marker = new MarkerWithLabel({
map: map_,
position: new google.maps.LatLng(polygone.getPolygoneBounds().getCenter().lat(), polygone.getPolygoneBounds().getCenter().lng()),
icon: 'none',
labelContent: '<div style="background-color: #222b37; padding: 3px 5px; color: white; font-size: 13px;">axe : '+axe_libelle+'</div>',
labelInBackground: false
});
...
在运行时我得到了:
我想将标签放置在面积较大的多边形区域中(在下图中用红色圈出):
如何实现?