Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!