function initialize() { var map = new google.maps.Map(document.getElementById("map_canvas"), { zoom: 4, center: new google.maps.LatLng(20.632784,78.969727), mapTypeId: google.maps.MapTypeId.ROADMAP }); var route = [ new google.maps.LatLng(22.568049,88.322868), //Kolkata new google.maps.LatLng(28.639979,77.233887), //New Delhi new google.maps.LatLng(12.98181,77.578239), //Bengaluru new google.maps.LatLng(18.958246,73.053589) //Mumbai ]; var path = new google.maps.Polyline( { path: route, strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2 }); path.setMap(map); }
<html> <head> <title>Google Maps API v3 : Hardcoded Polyline</title> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> </script> </head> <body onload="initialize()"> <div id="map_canvas" style="width:530px; height:230px"> </div> </body> </html>