angular-leaflet-directive icon indicating copy to clipboard operation
angular-leaflet-directive copied to clipboard

marker lat lng doesn't change when marker is dragged

Open CatchSandeepVaid opened this issue 8 years ago • 3 comments

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?

CatchSandeepVaid avatar Jul 25 '16 11:07 CatchSandeepVaid

    $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.

tuncagurkan avatar May 05 '17 13:05 tuncagurkan

Obvioulsy, do not forget

<leaflet id="leaflet_map" markers="markers" height="480px" width="480px"></leaflet>

landru29 avatar Sep 12 '18 07:09 landru29

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...

shnigi avatar Nov 07 '18 10:11 shnigi