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

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

Open
SFSailor opened this issue Sep 8, 2022 · 3 comments
Open

Comments

@SFSailor
Copy link

SFSailor commented Sep 8, 2022

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
Copy link
Author

SFSailor commented Sep 8, 2022

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
Copy link
Author

SFSailor commented Sep 8, 2022

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

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

2 participants
@SFSailor and others