Leaflet.RotatedMarker icon indicating copy to clipboard operation
Leaflet.RotatedMarker copied to clipboard

Are rotationAngle and rotationOrigin broken for custom icons?

Open HodellersHedge opened this issue 4 years ago • 7 comments

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.

HodellersHedge avatar Jul 07 '20 13:07 HodellersHedge

the same question

evaseemefly avatar Sep 15 '20 06:09 evaseemefly

same here.

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

federicoalvarez-github avatar Sep 29 '20 23:09 federicoalvarez-github

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

yuanyuan-xy avatar Nov 26 '20 01:11 yuanyuan-xy

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

federicoalvarez-github avatar Nov 26 '20 12:11 federicoalvarez-github

anyone able to solve this? improve it?

jaguardo avatar Jul 29 '21 18:07 jaguardo

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

ghybs avatar Jul 30 '21 05:07 ghybs

Looks like that works... Thanks!

jaguardo avatar Aug 02 '21 12:08 jaguardo