xkjyeah / vue-google-maps

Google maps component for vue with 2-way data binding
https://xkjyeah.github.io/vue-google-maps/
1.88k stars 474 forks source link

Marker position two way data binding is not working! nether using .sync or the @position_changed event #480

Open mazyvan opened 6 years ago

mazyvan commented 6 years ago

I'm stuck with this.
I just need to update my current local marker position after any drag.

I'm using Vue version 2.5.17 with webpack and laravel mix (2.1.11)

Using @position_changed the updateMaker method gets called forever and the functions lat() and lng() doesn't returns values.

// Inside template

<GmapMarker
  :position="markerPosition"
  :clickable="true"
  :draggable="true"
  @position_changed="updateMaker"
  @click="markerClicked"
 />

// Inside methods object

updateMaker: function(latLng) {
  this.markerPosition = {
    lat: latLng.lat(),
    lng: latLng.lng(),
  }
  console.log('updateMaker, ', latLng);
},

and using :position.sync="markerPosition" doesn't do anything. Why??

In the documentation there's nothing about this synchronization

mazyvan commented 6 years ago

Update: Seams like using the @dragend event I can actually get the maker data. It's this the proper way to get that?

updateMaker: function(event) {
  console.log('updateMaker, ', event.latLng);
  this.markerPosition = {
    lat: event.latLng.lat(),
    lng: event.latLng.lng(),
  }
},

Also, this events are not in the readme. They must be there. This Saturday I can make a PR to the file if you wish

eregnier commented 5 years ago

Maybe this component may help do the trick (but not reallu sure) https://github.com/eregnier/vue2-gmap-custom-marker