Maps API v3 Marker icon to point to another marker

http://stackoverflow.com/questions/25303797

by upsidown

HTML

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;libraries=places,geometry"></script>
<div id="map-canvas"></div>

CSS

html, body, #map-canvas {
    height: 100%;
    margin: 0;
    padding: 0
}

JavaScript

function initialize() {
    var direction = new google.maps.LatLng(52.376423, 4.887234);
    var station = new google.maps.LatLng(52.375401, 5.218824);
    
    var mapProperties = {
        center: direction,
        zoom: 10
    };
    
    var map = new google.maps.Map(document.getElementById("map-canvas"), mapProperties);
    
    var directionMarker = new google.maps.Marker({
        position: direction,
        map: map,
        draggable: false,
        title: "test"
    });
    
    var heading = google.maps.geometry.spherical.computeHeading(direction,station);
    
    directionMarker.setIcon({
        path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
        scale: 6,
        rotation: heading
    });
    
    var stationMarker = new google.maps.Marker({
        position: station,
        map: map,
    });
}

initialize();