Touqeer
Touqeer

Reputation: 654

How to rotate marker in rails using gmaps4rails?

I have set car as a marker and want to rotate it. Is there any way to rotate it in the defined code. If not, what other options do I have?

handler = Gmaps.build('Google');
handler.buildMap({
    provider: {},
    internal: {
        id: "map"
    }
}, function() {
    marker = handler.addMarkers([{
        lat: lat,
        lng: lng,
        "picture": {
            "url": "/assets/car.png",
            "width": 17,
            "height": 38
        }
    }]);
});

Upvotes: 1

Views: 115

Answers (2)

Touqeer
Touqeer

Reputation: 654

I have used the solution from this answer. It uses the canvas to rotate the image. See the jsfiddle link for live example at the end of the answer.

Upvotes: 1

Gabriel Mesquita
Gabriel Mesquita

Reputation: 2391

Look at this question:

How to rotate a marker in Google Maps?

path takes an SVG-element I'd say thats how they manage to rotate it. If you create your custom marker using SVG it can be done quite easily using

transform="rotate(deg centerX centerY").

Upvotes: 1

Related Questions