-1

Hello i am using the react-google-maps/api library and i want to map some coordinates in my Google Map using the Polygon component. So far i have manage to map Polygons in my map with holes like this:

return polyline.location.map((outerCoords, polyInd) => {
........
<Polygon
  key={`polyline-${i}-${polyInd}`}
  paths={[outerCoords, innerCoords[0], innerCoords[1]}
.........

And the result is like this.

My problem is that i don't know each time the innerCoords array length so i want to add the inner coordinates some how dynamic. How i can do this? I was thinking using this Array.prototype.flat() but this is not solve my problem, (Map without holes). Also i don't know if i can somehow map() the innerCoords array and then use Polygon inside, but i think with this way i will see only one polygon hole at the time.

1 Answer 1

-1

I think i solve my problem, i just did this:

return polyline.location.map((outerCoords, polyInd) => {
  ........
  <Polygon
    key={`polyline-${i}-${polyInd}`}
    paths={[outerCoords, ...innerCoords]}
  .........
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.