LeafletPlayback icon indicating copy to clipboard operation
LeafletPlayback copied to clipboard

Marker offset from track (incorrect position) if orientIcons:true

Open SFSailor opened this issue 2 years ago • 3 comments

Well, the title says it all. I have tried a full range of nearly random choices for iconanchor. I can get it to center nicely on the track without orientIcons:true, but once I start with the rotated icons they are displaced from the track by a consistent number of pixels.

Is this a bug? A setting?

SFSailor avatar Sep 08 '22 13:09 SFSailor

Hack solution.

With a marker that is 12x30, with centers set at 6,15, the existing code would give me a value for "a" of 0,0.

My core hack below indicates I needed -6,-15

So now I just gotta figure out what formula gets me there the neatest way

_updateImg: function (i, a, s) { //a is the anchor. s is the size
    a = L.point(s).divideBy(2)._subtract(L.point(a)); 
    a=L.point([-6,-15]); //this is my hack

SFSailor avatar Sep 08 '22 13:09 SFSailor

Okay. Here it is.

  1. the code uses "_subtract" but the documented function is "subtract"
  2. I revised the code around line 184 of the .js as follows. This gives me the negative values that appear to work in my application. Should this go into core?
_updateImg: function (i, a, s) {
        //a = L.point(s).divideBy(2)._subtract(L.point(a));
        a=a.subtract(s);

SFSailor avatar Sep 08 '22 14:09 SFSailor