I have a list coordinates same latitude, longitude. I want to divide them into a circle around the original coordinate.
For example I have a list of 6 items the same coordinates, how do i get list vertex point's coordinates of hexagon by use JavaScript with google map
Asked
Active
Viewed 135 times
-1

Ryan Nguyen
- 61
- 8
-
Does this answer your question? [Calculate 6 vertices of randomely generated hexagon](https://stackoverflow.com/questions/25945593/calculate-6-vertices-of-randomely-generated-hexagon). I think the code here can be easily adopted to return the coordinates instead of plotting them. – Ken Y-N Feb 17 '20 at 03:49
-
Look like it was 2D. I want to do with map coordinate – Ryan Nguyen Feb 17 '20 at 04:43
1 Answers
0
It sounds like Ken Y-N's comment is exactly what you are looking for.
fucntion printPoints(latitude, longitude, radius, vertices){
for (var i = 0; i < vertices; i ++){
console.log([latitude + (radius*Math.cos(Math.PI*2/vertices * i)), longitude + (radius*Math.sin(Math.PI*2/vertices * i))]);
}
}
printPoints(0, 0, 10, 6); //prints [10, 0] [5, 8.7] [-5, 8.7] [-10, 0] [-5, -8.7] [5, -8.7]
This function simply prints the coordinates, but you can modify it as you would like to.

Kenta Nomoto
- 839
- 6
- 11
-
Looking at your image, you might like to add 90 degree turn (+ Math.PI/2) to the angles you give to the trigonometric function. So that the vertex will start at the top instead of the right side. – Kenta Nomoto Feb 17 '20 at 06:01