Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
Change marker position when data change

I am working with google map api on vue js project. I have a table of data containing positions i want when my data changes change marker position change position without refreshing card. This is my code i want to add the fonctionality of changing marker poisition and how impliment it in my component. this is my code:

      this.initMap(
        this.$refs.googleMaps as HTMLElement,
        this.points
      )
    }
  }

  initMarker(map: google.maps.Map, pList: points[]) {
    const bounds = new google.maps.LatLngBounds()
    pList.forEach(
      (pElement: pElement, index: number) => {

        const marker = new google.maps.Marker({
          position: {
            lat: pElement.geoPoint?.latitude as number,
            lng: pElement.geoPoint?.longitude as number
          },
          icon: { url: 'url' },
          map
        })

        const position = new google.maps.LatLng(
          pElement.geoPoint?.latitude,
          pElement.geoPoint?.longitude
        )

        marker.addListener('click', () => {
          map.panTo(position)
        })

        bounds.extend(position)
      }
    )

    map.fitBounds(bounds)
  }

  initMap(mapElement: HTMLElement, pList: points[]) {
    const gestureOption: GoogleMapsGestureHandlingOptions = 'cooperative'
    const mapProp: google.maps.MapOptions = {
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      gestureHandling: gestureOption,
      disableDefaultUI: true,
      clickableIcons: false,
      minZoom: 20
    }
    this.googleMaps = new google.maps.Map(mapElement, mapProp)
    this.initMarker(this.googleMaps, pList)
  }


  mounted() {
    this.renderMap(
      () =>
        this.initMap(
          this.$refs.googleMaps as HTMLElement,
          this.pList
        )
    )
  }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Here I dont know which data represents table data. But I suggest you to use computed property with setter and getter for your case. You had covert both Marker and Table Data to computed property to achieve what you want

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda