You can pass the values through the as options or use the two functions on the marker! setRotationAngle() setRotationOrigin()
Be aware with custom marker to set the anchor correct!
Good debugging code:
self.rot_angle = 45
# Two marker at the same postion
self.marker1 = L.marker([12.934056, 77.610029], options={"draggable": "true"})
self.marker2 = L.marker([12.934056, 77.610029], options={"draggable": "true"})
# Set your custom icon to one of the markers
self.marker1.setIcon(self.custom_icon)
# Connect to the moveend event of the other marker
self.marker2.moveend.connect(self.marker_moved)
# Add both marker to the map
self.map.addLayer(self.marker1)
self.map.addLayer(self.marker2)
def marker_moved(self, kwargs: dict = None):
self.marker1.setLatLng(kwargs.get("latLng"))
self.rot_angle = (self.rot_angle + 90) % 360
self.marker1.setRotationAngle(self.rot_angle)
Extended functionality to use RotatedMarker from https://github.com/bbecquet/Leaflet.RotatedMarker.
You can pass the values through the as
options
or use the two functions on the marker!setRotationAngle()
setRotationOrigin()
Be aware with custom marker to set the anchor correct! Good debugging code: