Git Product home page Git Product logo

Comments (3)

bbecquet avatar bbecquet commented on August 17, 2024 1

Ok, forget what I've written previously, I missed the obvious!
PolylineDecorator itselft inherits from LayerGroup, so of course you can access individual layers. All symbols created by a PolylineDecorator will be exposed by the getLayers method, in the order they are created.
Here is how to open a popup on the first symbol:

    var pl = L.polyline([[51.51462, -0.12377], [51.5133, -0.12207]], {color: "#ff7800", weight: 1}).addTo(map);
    var pd = L.polylineDecorator(pl, {
        patterns: [
            {offset: 0, repeat: '10%', symbol: L.Symbol.marker()}
        ]
    }).addTo(map);

    pd.getLayers()[0].bindPopup('Hello world!').openPopup();

But it may be confusing if you're using multiple patterns or multiple paths on the same PolylineDecorator object, as all the different symbols will be returned by getLayers.

from leaflet.polylinedecorator.

bbecquet avatar bbecquet commented on August 17, 2024

Hi,
I think it's not possible with the way things are working right now, as symbol layers are not exposed.
I'm considering adding a method on the decorator to access the symbol objects individually, but i don't know yet how to do it cleanly, especially with the multiple path support.
As a workaround, you could create your own Symbol class, storing the Layer objects it produces in the buildSymbol method before returning them, to access them later.

from leaflet.polylinedecorator.

transducer avatar transducer commented on August 17, 2024

For me your solution leads to:

Uncaught TypeError: layer.getLatLng is not a function
    at NewClass.openPopup (leaflet.inc.js:9672)

from leaflet.polylinedecorator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.