Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PolylineDecorator always top layer even when calling bringToBack() #96

Open
TLDC opened this issue Jul 11, 2019 · 3 comments
Open

PolylineDecorator always top layer even when calling bringToBack() #96

TLDC opened this issue Jul 11, 2019 · 3 comments

Comments

@TLDC
Copy link

TLDC commented Jul 11, 2019

Got an issue using polylineDecorator with arrowHead symbols as sometimes the arrows heads can overlap other layers on the map and prevent you from being able to hover them to read an associated tooltip. I've tried to use bringToBack() on the polylineDecorator layer but it just seems to do absolutely nothing, the arrow heads are always the very top layer.

@stharvey
Copy link

Hello @TLDC did you find a solution to this? I am having the same issue.

@Michael-372
Copy link

Michael-372 commented Jan 13, 2022

@TLDC @stharvey
I think this had to do with the way the polyline decorator works. It appears to be drawing each pattern on a map level layer. So doing something like myDecorator.addTo(myFeatureGroup) is essentially doing nothing.

For my use case, I want the decorators at the bottom of the layer stack at all times so I was able to resolve this issue by overriding the "onAdd" function. More specifically, the this._map.on('moveend') event:

    const myDecorator = L.polylineDecorator(yourOptions);
    
    myDecorator.onAdd = function(map) {
      this._map = map;
      this._draw();

      // original line:
      // this._map.on('moveend', this.redraw, this)

      // new line:
      this._map.on('moveend', () => { this.redraw(); this.bringToBack(); }, this);  
    }
    
    myDecorator.addTo(myLayer);

The polyline decorator attempts to redraw on pan/zoom which moves everything back to the top of the stack but if you make this change, it will send it all back to the bottom.

I admit this is a hacky solution, and probably 3 years too late, but Im using this tool and just hit the snag

@RoboVij
Copy link

RoboVij commented Nov 17, 2022

The above workaround isn't working. Is there any solution for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants