Below is my coding when I am trying to get the coordinates of the polygon from react-google-maps:
const coords = { lat:{}, lng:{} }
getCoordinates: () => (polygon) => {
const paths = polygon.getPath()
const coor = paths.b
{coor.map(function(coor, i){
coords.lat= coor.lat()
coords.lng= coor.lng()
})}
return console.log(coords)
}
I'm trying to get the object array for "coords"like below:
coords = [
{ lat: 3.1323583333745533, lng: 101.62676453590393 },
{ lat: 3.1318226928949433, lng: 101.62672162055969 },
{ lat: 3.131753059612469, lng: 101.6274243593216 }
]
But using the code will give me this:
coords = {
lat: 3.131753059612469,
lng: 101.6274243593216
}
which is the last coordinates out of the three.
How do I can get all three coordinates under "coords"?