-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rotated icons are shifted in Leaflet 1.0 #8
Comments
Hi, and sorry for taking so long. Most of the time the issues of marker shifts are related to a |
Hi, thank you for getting back to me. Here's where I'm experiencing the problem. I'm loading markers from a GeoJSON and using a custom icon with an anchor that's set at the center of the icon. These markers are on top of a line, similarly to PolylineDecorator. When the markers are rotated, they should still be centered on the line. I tried emulating your fix from Leaflet.PolylineDecorator, and it appears that adding the following lines of code to RotatedMarker fixes my issue. However, I'm not sure that I implemented it correctly.
|
Thanks for posting some code. First, you don't need the fix from PolylineDecorator. The part about the The reason I didn't use an array or a |
Yes, that absolutely fixes it---thank you very much!! And thank you for the quick response! :) In case you are interested, I tracked down some other interesting behavior. I expected Leafelt.RotatedMarker to default to rotating about the custom anchor. As I was replicating this in a JSFiddle, I noticed that the plugin worked correctly without I think that the default behavior Thank you for your help, and thank you for writing a very useful plug-in. :) |
I am having the same problems like @Jmuccigr . Is there any progress ? |
I believe I found my problem. I tried to change the default origin from bottom center to center center, which did not apply because the icons had an anchor by default. So removing the iconAnchor from the InitHook or setting the origin for each marker fixed my problem. |
@ludik0, can you be more specific there? Did you make changes to the rotatedmarker code, or to how you called the script? |
@Jmuccigr in the inithook: Because in my case the marker seemed have an iconAnchor even if I never set one. I made the changes to the code because i wanted this to be the default behavior, but I could have called |
Are you loading from geoJSON? |
Solved my problem: I stupidly had a comma in the rotationOrigin, so |
When I loop through my markers (from a GeoJSON file) and apply marker.setRotationOrigin() and marker.setRotationAngle(), the transformations work correctly in with Leaflet 0.7.7, but not when I upgrade to Leaflet 1.0. The markers are shifted in Leaflet 1.0. Note that the shift is different if I do not set the rotation origin, but if I set the rotation origin, the (different) shift is the same no matter what I choose the origin to be.
Could this be related to this issue with shifted markers on Leaflet.PolylineDecorator?
The text was updated successfully, but these errors were encountered: