How to put a infowindow on polyline in Google Maps v3?

Bader picture Bader · Nov 23, 2011 · Viewed 13.4k times · Source

I want to know how to show infowindow on polyline in using Google Maps Api V3? and to appear in the middle of the polyline ?!

Answer

Shane Best picture Shane Best · Feb 2, 2012

Firstly you will need to calculate the middle/center of the polyline. This has been discussed and answered here; https://stackoverflow.com/a/9090409/787921

Then you will have to open the infowindow;

var infowindow = new google.maps.InfoWindow({
             content: "infowindow text content"});
infowindow.setPosition(midLatLng);
infowindow.open(map);