Skip to content

Commit 7e5c557

Browse files
author
Nicolò Maria Mezzopera
committed
feat: on marker move emit update:latLng
fixes: #274
1 parent 77bb931 commit 7e5c557

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/components/LMarker.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script>
22
import propsBinder from '../utils/propsBinder.js';
33
import findRealParent from '../utils/findRealParent.js';
4+
import debounce from '../utils/debounce.js';
45
import { optionsMerger } from '../utils/optionsUtils.js';
56
import Layer from '../mixins/Layer.js';
67
import Options from '../mixins/Options.js';
@@ -48,6 +49,7 @@ export default {
4849
}, this);
4950
this.mapObject = L.marker(this.latLng, options);
5051
L.DomEvent.on(this.mapObject, this.$listeners);
52+
this.mapObject.on('move', debounce(this.latLngSync, 100));
5153
propsBinder(this, this.mapObject, this.$options.props);
5254
this.parentContainer = findRealParent(this.$parent);
5355
this.parentContainer.addLayer(this, !this.visible);
@@ -74,6 +76,9 @@ export default {
7476
this.mapObject.setLatLng(newLatLng);
7577
}
7678
}
79+
},
80+
latLngSync (event) {
81+
this.$emit('update:latLng', event.latlng);
7782
}
7883
},
7984
render: function (h) {

0 commit comments

Comments
 (0)