Find the center of gravity coordinates of different coordinates (polygons) on the map

Asked 2 years ago, Updated 2 years ago, 48 views

Currently, we are trying to draw a polygon with javascript through the following map api and find the center point of that polygon.

I've done drawing a polygon.

I'm struggling to find the center point of this polygon.

Is there a way to find the center point through the next map api? Does anyone know the algorithm to find the center point?

algorithm javascript

2022-09-22 20:39

1 Answers

Knowing the minimum/maximum 4 points of the polygon gives you the center point.

center.x = x1 + ((x2 - x1) / 2);
center.y = y1 + ((y2 - y1) / 2);


2022-09-22 20:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.