1

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
        }
    }]);
});
Gabriel Mesquita
  • 2,271
  • 1
  • 20
  • 30
Touqeer
  • 583
  • 1
  • 4
  • 19

2 Answers2

1

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").
Gabriel Mesquita
  • 2,271
  • 1
  • 20
  • 30
  • 1
    Thanks for the reply. I followed the link and set `icon: "/assets/car.png" ` and applied rotation using `rotation: 45` but it's not rotating. When I set the `icon: google.maps.SymbolPath.FORWARD_CLOSED_ARROW`, it rotates perfectly. And I didn't get the `transform` part. – Touqeer Aug 03 '17 at 04:36
1

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.

Touqeer
  • 583
  • 1
  • 4
  • 19