I recently had the need to display rotated markers on a map for a project using Leaflet leaflet and Esri Leaflet. After a quick Google search I couldn’t see any standard way to do it so I thought I’d roll my own. My dataset had a bearing value which I could use to set the rotation, so I used that in combination with the L.divIcon and some CSS to get the desired result.
A bastardised version of this Styling Points sample can be seen with the effect .
Now in that sample I am hardcoding the rotated classes since there are only 4 values, but in my real world application it could be between 0 and 359, so rather than type out that I used Less to allow me to specify the same in a much more terse manner
1
2
3
4
5
6
7
8
9
10
11
12
.generate-rotate-rules(359);
.generate-rotate-rules(@n, @i: 0) when (@i =< @n) {