function drawMarkersMap(canvasID, imageURL, shadow, dataToPlot, dataToZoom, markerLink, setCenter, setZoom) {
    var explicit = false;
    if (setCenter != null && setZoom != null) {
        // explicit center and zoom
        explicit = true;
    }
    if (!explicit) var bounds = new google.maps.LatLngBounds();
    var map = new google.maps.Map(document.getElementById(canvasID), {scrollwheel:false, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, streetViewControl: false});

    if (explicit) {
        map.setCenter(new google.maps.LatLng(setCenter.lat, setCenter.lng));
        map.setZoom(setZoom);
    }
    
    var icon = {};
    icon.icon = imageURL;
    if (shadow) {
        icon.shadow = shadow;
    }
    
    var markerPoint;
    var marker;

    if ( dataToPlot.length == 0 && !explicit && dataToZoom.length > 0 ) {
        var centerPoint = new google.maps.LatLng(dataToZoom[0].lat, dataToZoom[0].lng);
        map.setCenter( centerPoint );
        map.setZoom(4);
        return;
    }
    
    if (dataToPlot) {
        for ( i = 0; i < dataToPlot.length; i++) {
            markerPoint = new google.maps.LatLng(dataToPlot[i].lat, dataToPlot[i].lng);
            icon.position = markerPoint;
            if (dataToPlot[i].icon) icon.icon = dataToPlot[i].icon;
            marker = new google.maps.Marker(icon);
            marker.setMap(map);
            
            if (markerLink) {
                addMarkerListener(marker, markerLink + dataToPlot[i].ride_key);
            }
        }
    }
    
    if (dataToZoom && !explicit) {
        for ( i = 0; i < dataToZoom.length; i++ ) {
            markerPoint = new google.maps.LatLng(dataToZoom[i].lat, dataToZoom[i].lng);
            bounds.extend(markerPoint);
        }
    }
        
    if (!explicit) map.fitBounds(bounds);
}

function addMarkerListener(marker, link) {
    google.maps.event.addListener(marker, "click", function() {
            location.href = link;
    });
}

