Q:

Place Marker on center of polyline

i am using Google's direction service alongside the Polyline class to draw lines along a road with custom colors. I want to be able to place a market on the center of a polyline. I have tried using the following code:
function Marker(start, end) {
    var midP = google.maps.geometry.spherical.interpolate(start, end, 0.5);
    // console.log(map);
    // console.log(midP);
    var options = {
        position: midP
    };
    marker = new google.maps.Marker(options);
    marker.setMap(map);
}

start and end are the start and end points of a given polyline.
However the marker doesn't fall on the polyline. It appears to untill you zoom in.
I would appreciate any help on how to get this right. Thanks

A:

I think what you're looking for is the midpoint of the polyline, i.e. the point at which you would have traveled have the distance following the route. Is that right?
Then I would use an algorithm like this one which finds the midpoint of a polyline. The code in that answer is written for a polyline "defined as a series of [x,y] points", but could easily be adapted to use a Maps API polyline.

