inocan-group / vue3-google-map

A set of composable components for easy use of Google Maps in your Vue 3 projects.
https://vue3-google-map.com
MIT License
295 stars 60 forks source link

Dynamic Polyline Change #242

Open HusamElbashir opened 8 months ago

HusamElbashir commented 8 months ago

Discussed in https://github.com/inocan-group/vue3-google-map/discussions/241

Originally posted by **Krada88** March 28, 2024 Hello, Friends. Tell me I have a problem. I'm doing something like a geotracker, I need to periodically update the Polyline in real time. But I came across the fact that it doesn't work. Maybe I'm doing something wrong? I will be grateful for the hint. And thanks a lot for earlier. Here is my code. I created a small sample code that doesn't work. In real life, the Polyline update should occur when the geolocation is changed, but it doesn't work there either. I deleted the api key from the code =) ``` ```
Krada88 commented 7 months ago

Hi. Guys, can you tell me if the problem is solvable? Unfortunately, I can't beat her myself =(

HusamElbashir commented 7 months ago

As a workaround you can create a new path array every time instead of pushing to the old one

const addNewCoordinate = () => {
  const newCoordinate = {
    lat: Math.random() * 180 - 90,
    lng: Math.random() * 360 - 180,
  }

  flightPath.value = {
    ...flightPath.value,
    path: [...flightPath.value.path, newCoordinate],
  }
}
Krada88 commented 7 months ago

Thank you very much. It just happened!