Google API Javascript Web API 

GoogleMaps API to Draw a line From A to B Direction

To make Google maps API to Draw a line From One Place to Another Direction.

Step1: Add the below Google maps API link to your page

<script type="text/javascript" src=""></script>


Step 2: Add the below HTML Div to body

 <div style="width: 600px;">
         <div id="map" style="width: 800px; height: 600px; float: left;"></div> 

Step 3: Then you have to configure Javascript code based on your Requirement.

 var directionsService = new google.maps.DirectionsService();
         var directionsDisplay = new google.maps.DirectionsRenderer();
         var map = new google.maps.Map(document.getElementById('map'), {
           mapTypeId: google.maps.MapTypeId.ROADMAP
         var request = {
           origin: '13.315616, 75.774851', 
           destination: '12.971606, 77.592682',
           travelMode: google.maps.DirectionsTravelMode.DRIVING
         directionsService.route(request, function(response, status) {
           if (status == google.maps.DirectionsStatus.OK) {


Arjun is is a web developer/designer, who is fond of the web. He lives in Manipal, Karnataka, India.

Also Read:  How to create server side session using javascript

Related posts