I have a requirement to create an application which would show public transport routes between a source and a destination which i acheived it successfully. But i found that the transit routes does not seem to work for most of the cities. It works for only a few places. For Eg: I selected source Mumbai and destination as Bangalore. I get the result as zero results found but in fact there are trains and buses between the routes. Is there any other alternate API that i can use? Any solution that can tackle this issue..Thanks in advance. Please find the below code i have used.

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
body {
  font-size: 0.8em;

#map-container, #side-container, #side-container li {
  float: left;

#map-container {
  width: 500px;
  height: 600px;

#side-container {
  border: 1px solid #bbb;
  margin-right: 5px;
  padding: 2px 4px;
  text-align: right;
  width: 260px;
#side-container ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
#side-container li input {
  font-size: 0.85em;
  width: 210px;
#side-container .dir-label {
  font-weight: bold;
  padding-right: 3px;
  text-align: right;
  width: 40px;

#dir-container {
  height: 525px;
  overflow: auto;
  padding: 2px 4px 2px 0;
#dir-container table {
  font-size: 1em;
  width: 100%;

<div id="side-container">
    <li class="dir-label">From:</li>
    <li><input id="from-input" type=text value="panvel"/></li>
    <br clear="both"/>
    <li class="dir-label">To:</li>
    <li><input id="to-input" type=text value="thane"/></li>
    <select onchange="Demo.getDirections();" id="travel-mode-input">
      <option value="Train" selected="selected">By train</option>
      <option value="walking">Walking</option>
    <select onchange="Demo.getDirections();" id="unit-input">
      <option value="imperial">Imperial</option>
      <option value="metric" selected="selected">Metric</option>
    <input onclick="Demo.getDirections();" type=button value="Go!"/>
  <div id="dir-container"></div>
<div id="map-container"></div>

<script type="text/javascript">
var Demo = {
  // HTML Nodes
  mapContainer: document.getElementById('map-container'),
  dirContainer: document.getElementById('dir-container'),
  fromInput: document.getElementById('from-input'),
  toInput: document.getElementById('to-input'),
  travelModeInput: document.getElementById('travel-mode-input'),
  unitInput: document.getElementById('unit-input'),

  // API Objects
  dirService: new google.maps.DirectionsService(),
  dirRenderer: new google.maps.DirectionsRenderer(),
  map: null,

  showDirections: function(dirResult, dirStatus) {
    if (dirStatus != google.maps.DirectionsStatus.OK) 
      alert('Directions failed: ' + dirStatus);
    // Show directions

  getSelectedTravelMode: function() 
    var value =
    if (value == 'Train') {
      value = google.maps.DirectionsTravelMode.TRANSIT;
    } else if (value == 'bicycling') {
      value = google.maps.DirectionsTravelMode.BICYCLING;
    } else if (value == 'walking') {
      value = google.maps.DirectionsTravelMode.WALKING;
    } else {
      alert('Unsupported travel mode.');
    return value;

  getSelectedUnitSystem: function() {
    return Demo.unitInput.options[Demo.unitInput.selectedIndex].value == 'metric' ?
        google.maps.DirectionsUnitSystem.METRIC :

  getDirections: function() {
    var fromStr = Demo.fromInput.value;
    var toStr = Demo.toInput.value;
    var dirRequest = 
      origin: fromStr,
      destination: toStr,
      travelMode: Demo.getSelectedTravelMode(),
      unitSystem: Demo.getSelectedUnitSystem(),
      provideRouteAlternatives: true

    Demo.dirService.route(dirRequest, Demo.showDirections);

  init: function() {
    var latLng = new google.maps.LatLng(28.6168, 77.2434);
    Demo.map = new google.maps.Map(Demo.mapContainer, {
      zoom: 13,
      center: latLng,
      mapTypeId: google.maps.MapTypeId.ROADMAP

    // Show directions onload

// Onload handler to fire off the app.
google.maps.event.addDomListener(window, 'load', Demo.init);
  • Example code please (jsfiddle is good for debugging)
    – Mapperz
    Oct 30, 2013 at 13:53
  • @ Mapperz : I have edited my question and added the code which i have used for reference.
    – sTg
    Oct 30, 2013 at 13:58
  • @Mapperz - Do i misunderstand something? I think this about data availability, not a coding/API issue. (If you agree, maybe a rollback to the codeless question...?
    – Martin F
    Mar 29, 2014 at 1:58

1 Answer 1


Are you sure it is an API issue? I think it is a database/system coverage issue.

According to news.yahoo.com/google-maps-adds-live-transit-data-selected-cities (2011-06-09)

Google plans to expand its live transit coverage into other metropolitan areas worldwide.

(emphasis mine). There are several cities covered by Google Transit, but i suspect it's going to take even the mighty Google a few more years to conquer the whole world.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.