如何在多边形最大面积的中心得到点?

时间:2019-12-02 11:38:32

标签: google-maps-api-3

我计算了多边形的中心:

<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
            });
...

在运行时我得到了:

enter image description here

我想将标签放置在面积较大的多边形区域中(在下图中用红色圈出):

enter image description here

如何实现?

0 个答案:

没有答案