This repository was archived by the owner on Nov 30, 2018. It is now read-only.
This repository was archived by the owner on Nov 30, 2018. It is now read-only.
Marker dragend event in markers directive pushes outdated values. #1398
Open
Description
I noticed an issue when dealing with markers and events. Assuming the following scope:
$scope.map = {
center: { latitude: 45, longitude: -73 },
markers: [
{ coords: { latitude: 45, longitude: -73 } }
],
markersEvents: {
dragend: function (mapModel, eventName, marker, orignalEventArgs) {
console.log(marker.coords);
console.log(originalEventArgs[0].latLng);
}
}
};
$scope.trigger = function () {
$scope.map.markers = [
{ coords: { latitude: 40, longitude: -70 } }
];
console.log('TRIGGER');
};
And the following view:
<ui-gmap-google-map data-center="map.center" data-zoom="12">
<ui-gmap-markers data-models="map.markers" data-coords="'coords'" data-options="{ draggable: true }" data-events="map.markersEvents"></ui-gmap-markers>
</ui-gmap-google-map>
<button ng-click="trigger()">trigger</button>
Once the trigger function is executed, the two values logged by the dragend event will start to differ. Effectively, the marker object will stick to the value set by the trigger. Here is the log that I get when I run the code and play around a little.
Object {latitude: 45.45791405079439, longitude: -73.65212889990232}
of {A: 45.45791405079439, F: -73.65212889990232}
Object {latitude: 45.50485398823643, longitude: -73.57488128027342}
of {A: 45.50485398823643, F: -73.57488128027342}
TRIGGER
Object {latitude: 40, longitude: -70}
of {A: 45.4789105674028, F: -73.6386108398437}
Object {latitude: 40, longitude: -70}
of {A: 45.46157547003231, F: -73.60839843749994}
Object {latitude: 40, longitude: -70}
of {A: 45.48420633926945, F: -73.66470336914057}