fnicollet / Leaflet

:leaves: JavaScript library for mobile-friendly interactive maps
http://leafletjs.com
BSD 2-Clause "Simplified" License
48 stars 20 forks source link

Add rotation support for Markers #28

Closed laobubu closed 7 years ago

laobubu commented 7 years ago

Currently I'm working on a webapp based on OpenLayers, displaying in-door map. However OpenLayers is too heavy and I need a lightweight map library. The original Leaflet doesn't support rotation, and I found your mods which works like a charm. Thanks!

However, it doesn't support rotated markers yet, which OpenLayers supports. So I modified the code, adding rotation and rotateWithView options, and setRotation(rad) method for Marker.

And BTW improved L.Point.rotateFrom(theta, pivot) 's performance.

Demo

laobubu commented 7 years ago

@fnicollet The readability is not as good as the original one, that's the fact. However, in this version, the count of temporary objects is reduced, and their is no need to invoke extra methods like add(), subtract() and rotate(). Everything is done in a single function. Maybe adding some comments will help developers understand the algorithm.

laobubu commented 7 years ago

Vector won't disappear when panning and zooming now. Repainting shall not be earlier than resizing canvas, or everything you just painted would be cleared.

fnicollet commented 7 years ago

Thanks a lot for your contribution !