ui-leaflet icon indicating copy to clipboard operation
ui-leaflet copied to clipboard

Changin markers on scope, the model is different

Open pabloalcaraz opened this issue 8 years ago • 2 comments

Hi,

I have a map with a filter that shows or hide depending of category of the marker you choose.

so, depending of the choose i have to update the $scope.markers variable.

I have a function on click on marker and the model the first time the map is loaded is the correct but when I apply a filter and put the new markers on scope variable the model is different.

In the leafletEvent object when click i get the good lat,lng, the label and icon correctly, but not the model.

I've tested with object {} instead of array [], I've done controls.markers.clean(), etc without success.

Can anyone tell me what I have to do for do this change of markers correctly?

Thanks.

pabloalcaraz avatar Jul 09 '17 17:07 pabloalcaraz

Same issue here. If I change markers, I get wrong model on marker mouserOver, but in leafletEvent lat, lng are correct.

8Duke8 avatar Jul 25 '17 12:07 8Duke8

I may have found the issue. When markers detects a change it checks watchTrap and aborts if this is true. watchTrap comes from modelChangeInDirective and acts as a throttling mechanism. The issue is if you abort you will miss your change until some other future change happens beyond the throttle timeout.

As a workaround I decorated leafletHelpers.modelChangeInDirective to do no throttling as i would much rather eat a possible performance hit then have wrong data.

in coffee:

.config ($provide) ->
    'ngInject'
    $provide.decorator 'leafletHelpers', ($delegate) ->
        'ngInject'
        $delegate.modelChangeInDirective = (trapObj, trapField, cbToExec) ->
            trapObj[trapField] = false
            cbToExec()
        $delegate

bdirito avatar Aug 09 '17 20:08 bdirito