0

Im having some problem rotating my marker at google maps api. Im currently doing:

<script>
function initialize() {
    var mapProp = {
        center: new google.maps.LatLng(51.508742, -0.120850),
        zoom: 4,
        minZoom: 2,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map"), mapProp);
    var myLatlng = new google.maps.LatLng(-51.508742, -0.120850);

    var image = 'http://wcdn1.dataknet.com/static/resources/icons/set73/f3eef3d2.png';
    var marker = new google.maps.Marker({
        position: myLatlng,
        icon: {
            path: google.maps.SymbolPath.BACKWARD_OPEN_ARROW,
            scale: 10
        },
        rotation: 50,
        map: map
    });
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>

But this dosn't work sadly, I know the heading and that is 50 degrees as you can see in the "rotate". How can I do this?

Suchit kumar
  • 11,809
  • 3
  • 22
  • 44

1 Answers1

1

You need to change Marker structure a bit for rotation:

        function initialize() {
             var mapProp = {
                 center: new google.maps.LatLng(51.508742, -0.120850),
                 zoom: 4,
                 minZoom: 2,
                 mapTypeId: google.maps.MapTypeId.ROADMAP
             };
             var map = new google.maps.Map(document.getElementById("map"), mapProp);
             var myLatlng = new google.maps.LatLng(-51.508742, -0.120850);

             var image = 'http://wcdn1.dataknet.com/static/resources/icons/set73/f3eef3d2.png';
             var marker = new google.maps.Marker({
                 position: myLatlng,
                 icon: {
                     path: google.maps.SymbolPath.BACKWARD_OPEN_ARROW,
                     scale: 10,
                     rotation: 50
                 },
                 
                 map: map
             });
         }
         google.maps.event.addDomListener(window, 'load', initialize);
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>

<div id="map" style="width:500px;height:500px;"></div>;
Suchit kumar
  • 11,809
  • 3
  • 22
  • 44
  • for more info visit this thread:http://stackoverflow.com/questions/6800613/rotating-image-marker-image-on-google-map-v3 – Suchit kumar May 08 '15 at 07:00