LeafletHtmlIcon icon indicating copy to clipboard operation
LeafletHtmlIcon copied to clipboard

Setting iconAnchor makes no effect

Open raapperez opened this issue 9 years ago • 4 comments

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

raapperez avatar Aug 24 '16 13:08 raapperez

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 avatar May 22 '17 17:05 john-landgrave

@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 avatar May 22 '17 17:05 john-landgrave

@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.

john-landgrave avatar Jun 02 '17 21:06 john-landgrave

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.

sagacitysite avatar Nov 14 '17 13:11 sagacitysite