angular-ui / ui-leaflet

AngularJS directive to embed an interact with maps managed by Leaflet library
http://angular-ui.github.io/ui-leaflet
Other
314 stars 134 forks source link

Marker position binding is not updated when dragging a marker #82

Open nmccready opened 9 years ago

nmccready commented 9 years ago

From @HarelM on July 3, 2015 12:26

Please see below plunker: http://plnkr.co/edit/MyH7NOhKUCRftQKvGSQu?p=preview When dragging the marker the position is not updated...

Copied from original issue: tombatossals/angular-leaflet-directive#838

nmccready commented 9 years ago

From @tombatossals on July 3, 2015 12:30

Hi, please take a look at this example: http://tombatossals.github.io/angular-leaflet-directive/examples/0500-markers-simple-example.html

There's no direct binding between the markers properties and the scope for performance reasons, but you can listen to marker events to be able to get the new marker coordinates, and update its model if needed.

nmccready commented 9 years ago

From @HarelM on July 3, 2015 12:47

Will it work if I change it the other way around? meaning I'll change the model behind, will it change the position on the map?

nmccready commented 9 years ago

From @tombatossals on July 3, 2015 13:10

Yes, it will work if you change the lat/lng of the marker on the scope.

nmccready commented 9 years ago

From @HarelM on July 3, 2015 13:23

Thanks, what field of args do I need to use when I want to update my scope while dragging, it seems that "model" is not defined - is it defined only in dragend?

nmccready commented 9 years ago

From @ageblade on October 19, 2015 17:47

What's the latest on this one ? Is there any way to get the new marker position after 'dragend' ? It looks like it is applied on a variable called 'model' however he is local and not part of the scope

nmccready commented 9 years ago

I don't think anyone is looking at it yet. This could be due to the model being cloned. But disabling the clone can cause update issues. So just removing cloning is not just the easy solution. Anyway feel free to dig in.

nmccready commented 9 years ago

From @ageblade on October 20, 2015 7:57

For the record I was able to overcome this by listening to the leafletDirectiveMarker.dragend event which passes the leaflet object as an argument and has a getLatLng() method.