hallahan / LeafletPlayback

This is a Leaflet plug-in that plays back points that have a time stamp synchronized to a clock.
http://leafletplayback.theoutpost.io
Other
483 stars 167 forks source link

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

Open SFSailor opened 2 years ago

SFSailor commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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);