bbecquet / Leaflet.RotatedMarker

Leaflet plugin to enable the rotation of map marker icons
MIT License
257 stars 101 forks source link

Are rotationAngle and rotationOrigin broken for custom icons? #28

Open HodellersHedge opened 4 years ago

HodellersHedge commented 4 years ago

With the following code everything appears to work correctly: var You = L.latLng([500, 500]); L.marker(You, {rotationAngle: 25}, {rotationOrigin: [32, 33]}).addTo(map); default-icon

Now, by adding an icon and passing it as second argument, the rotationAngle appears to have no effect: var You = L.latLng([500, 500]); var greenIcon = L.icon({iconUrl: 'favicons/tarkov/Legend/green-icon.png'}); L.marker(You, {icon: greenIcon}, {rotationAngle: 25}, {rotationOrigin: [32, 33]}).addTo(map); custom-icon

btw the green icon looks that way by default as png. it didnt rotate at all.

evaseemefly commented 4 years ago

the same question

federicoalvarez-github commented 4 years ago

same here.

And for non custom Icons I cannot get it to work either.

yuanyuan-xy commented 3 years ago

If it not work, how do I rotate the icon, please ?

federicoalvarez-github commented 3 years ago

I ended up creating 32 icons, each one with a different rotation angle, and loading the one closest to the angle needed. Not the most elegant solution but works...

jaguardo commented 3 years ago

anyone able to solve this? improve it?

ghybs commented 3 years ago

Hi,

I am not familiar with this plugin, but the README says that it "extends the L.Marker class with two new options", therefore I would simply expect the usage with custom icon to be:

L.marker(You, {
  icon: greenIcon,
  rotationAngle: 25,
  rotationOrigin: [32, 33]
}).addTo(map);

whereas OP separated each option in a different argument:

L.marker(You, {
  icon: greenIcon
}, {
  rotationAngle: 25
}, {
  rotationOrigin: [32, 33]
}).addTo(map);
jaguardo commented 3 years ago

Looks like that works... Thanks!