angular-leaflet-directive
angular-leaflet-directive copied to clipboard
marker lat lng doesn't change when marker is dragged
When i drag a marker, its lat lng (w.r.t $scope.model) doesnt change. The same issue was reported by someone else [https://github.com/tombatossals/angular-leaflet-directive/issues/690] but that issue was closed without providing a solution or workaround. Can someone please let me know a solution or a workaround?
$scope.$on('leafletDirectiveMarker.leaflet_map.dragend', function(e, args){
var updatedLat = '', updatedLng = '';
if( args.model.lat.toString().length > 9){
updatedLat = args.model.lat.toString().substring(0,9);
} else {
updatedLat = args.model.lat.toString();
}
if( args.model.lng.toString().length > 9){
updatedLng = args.model.lng.toString().substring(0,9);
} else {
updatedLng = args.model.lng.toString();
}
$scope.locations[$scope.draggedMarkerRowIndex].lat = updatedLat; //args.model.lat;
$scope.locations[$scope.draggedMarkerRowIndex].lng= updatedLng; //args.model.lng;
});
Additionally, You may need to inject leafletData to controller.
Obvioulsy, do not forget
<leaflet id="leaflet_map" markers="markers" height="480px" width="480px"></leaflet>
For me the args: lat and lng are always the same. They don't change with drag, even though the event move is different. Trying to figure out why the args are same...