Git Product home page Git Product logo

Comments (6)

EllanVhow avatar EllanVhow commented on August 17, 2024 1

The icons are fixed size and the arrowhead just touches the icon no matter what length the arrow polyline is. Thanks!

from leaflet.polylinedecorator.

EllanVhow avatar EllanVhow commented on August 17, 2024

Apologies, but this prompted a simple question. I have been told that it is not possible to draw a simple arrow ... line with an arrowhead at the end ... with PolylineDecorator. Could you clarify if it is possible to draw a simple arrow? Thanks.

I assumed endOffset = 0 and no offset parameter, but I am told that doesn't work.

from leaflet.polylinedecorator.

bbecquet avatar bbecquet commented on August 17, 2024

Hi @EllanVhow.

Yes you can, but you have to use a 100% offset instead of using endOffset. Like this:

var arrow = L.polyline([[57, -19], [60, -12]]).addTo(map);
var arrowHead = L.polylineDecorator(arrow, {
    patterns: [
        {
            offset: '100%',
            repeat: 0,
            symbol: L.Symbol.arrowHead({pixelSize: 15, polygon: false, pathOptions: {stroke: true}})
        }
    ]
}).addTo(map);

endOffset has been introduced quite late in the project, now I understand it may be counter-intuitive that it doesn't behave like you thought.

(BTW, sorry @cladocora for never having answered your question in the first place :/)

from leaflet.polylinedecorator.

EllanVhow avatar EllanVhow commented on August 17, 2024

Yes. Thank you. I should have clarified that we were trying to use the fixed pixel offset. The problem is that we need to hold the arrowhead back from the destination icon so that it is not covered by the icon. When we try to choose a percentage to hold the arrowhead back, it is just right for short segments and then is held way back from the destination in the long segments. It is not consistently "at the end" of the line. We could calculate a shorter polyline and hold back the actual end point, but again, we have to figure out that hold back in pixels somehow rather than in geo-coordinates.

If we had two decorations .. perhaps a dot for the start and an arrowhead for the end, would the endOffset in pixels work? ... be applied to the arrowhead?

Thank you!

from leaflet.polylinedecorator.

EllanVhow avatar EllanVhow commented on August 17, 2024

Alternatively, could we 'draw' the polyline from End to Start and then put a Reverse Arrowhead at a pixel offset from the start of the line (which is actually our End point)?

from leaflet.polylinedecorator.

EllanVhow avatar EllanVhow commented on August 17, 2024

The latter worked. Reversed the start and end in the point list, then set headAngle to -290 in L.Symbol.ArrowHead and adjusted the offset for the pixel size of the arrowhead.

reversedarrowhead290

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.