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

Setting iconAnchor makes no effect #1

Open
raapperez opened this issue Aug 24, 2016 · 4 comments
Open

Setting iconAnchor makes no effect #1

raapperez opened this issue Aug 24, 2016 · 4 comments

Comments

@raapperez
Copy link

Hi, great work in this!

I am having a little problem here, when I try to set an iconAnchor, the html icon doesn't change its position. What is wrong?

const newIcon = new L.HtmlIcon({
   html: getUserIcon(user.photo, user.status),
   iconAnchor: [90, 90]                
});
const marker = new L.Marker([user.position.lat, user.position.lng], { icon: newIcon });
map.addLayer(marker);
@john-landgrave
Copy link

I'm seeing the same issue. Setting the popupAnchor appears to work properly, but setting the iconAnchor appears to have no effect. Any chance there's an obvious fix for this? I'm happy to do the work and submit a PR, just not super familiar enough with Leaflet to know what's wrong.

@john-landgrave
Copy link

@dwnoble

I found the issue by comparing against the L.Icon source code and have implemented a fix that appears to be working for me. I have added a PR #2 and would appreciate if you could merge it to help out @raapperez and whoever else may use this!

Thanks!
John

@john-landgrave
Copy link

@dwnoble

Would you mind to merge the PR I submitted? It solves this issue that probably affects more people than are looking for the solution here.

@sagacitysite
Copy link

I struggled a while with this and afterwards figured out that Leaflet has DivIcon (http://leafletjs.com/reference-1.2.0.html#divicon). Probably this plugin here is not necessary anymore.

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

3 participants