Answer the question
In order to leave comments, you need to log in
How to calculate the center of a polygon?
I displayed a conditional contour on the map and now I would like to display a balloon in it. Creating a balloon is not a problem, not placing it in the center of a polygon is a problem.
JSFIDDLE
There are quite complex formulas in mathematics for calculating the center of mass of a polygon, I don't know how to use them. but Yandex api has poly.geometry.getBounds(), which takes the largest possible contour and finds the center. I also can’t apply it because I created the polygon not in the standard way ( new ymaps.Polygon()), but through map.geoObjects.add(objectManager);
Please help me get the coordinates of the center of the polygon.
If needed, here is a fiddle that demonstrates getBounds().
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question