Skip to content

Conversation

@nblu
Copy link
Contributor

@nblu nblu commented Mar 1, 2014

My project needed to be able to rotate markers so I thought it would be good to contribute this small change in case anyone else needs the same feature. A really simple example is included which shows where the iconAngle is set. I'm still finding my feet with angular so I might have missed something.

…tate

Included example markers-rotation-example.html
@houqp
Copy link
Contributor

houqp commented Mar 1, 2014

Thanks for the patch. Tested on FF and Chrome, I don't see the marker rotated. What's the expected behaviour?

@nblu
Copy link
Contributor Author

nblu commented Mar 1, 2014

Hi, this is how it looks on Chrome on my fork rotation_example
I've just realised I didn't commit the updated libraries from the dist directory. I'm just committing them.

@houqp
Copy link
Contributor

houqp commented Mar 1, 2014

nice, now it works :)

houqp added a commit that referenced this pull request Mar 1, 2014
Added support for icon rotation using leaflet-plugins/layer/Marker.Rotate
@houqp houqp merged commit c8f8e3f into tombatossals:master Mar 1, 2014
@houqp
Copy link
Contributor

houqp commented Mar 1, 2014

I know developers hate writing test, but it will be awesome if you can write a regression test for rotate when you have time :)

@nblu
Copy link
Contributor Author

nblu commented Mar 1, 2014

I'll give it a go, this is my first attempt at contributing on github so I'm unsure of the correct flow.

@houqp
Copy link
Contributor

houqp commented Mar 1, 2014

you are doing good. just send another PR for the test.

@khfayzullaev
Copy link
Contributor

In my code, when I am trying to use Rotate Function and Icon Customization (custom icons, and etc.) together, it fails with an error (t undefined). Have you tried to use these features simultaneously?

@nblu
Copy link
Contributor Author

nblu commented Sep 24, 2014

I've just been looking at the example markers-rotation-example.html and you should be able to edit the entry for the marker m3 as follows:

                    m3: {
                        lat: 41.85,
                        lng: -87.05,
                        message: "I'm a static marker at 90 degrees",
                        focus: false,
                        iconAngle: 90,
                        icon: {
                            iconUrl: 'img/leaf-green.png',
                            shadowUrl: 'img/leaf-shadow.png',
                            iconSize:     [38, 95], // size of the icon
                            shadowSize:   [50, 64], // size of the shadow
                            iconAnchor:   [22, 94], // point of the icon which will correspond to marker's location
                            shadowAnchor: [4, 62],  // the same for the shadow
                            popupAnchor:  [-3, -76] // point from which the popup should open relative to the iconAnchor
                        },
                    },

The result should be as follows:
image
Hopefully that works for you. I've not updated my fork recently but I'll look into adding that to the example next time I'm working on this (unless someone beats me to it).

@khfayzullaev
Copy link
Contributor

Thx! It is still not working. I have to check one more time.

@diegoM86
Copy link

Hi is there a way to use the iconAngle with a variable like iconAngle: changeAngle, instead of a constant number?
The angle I will obtain of a velocity propertie, called course.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants