O'Reilly logo

Google Maps JavaScript API Cookbook by Balkan Uraz, Alper Dincer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding the transit layer

Public transit lines have immense importance in cities, especially for tourists and foreigners in the city. Mapping these transit lines (bus, underground, and so on) onto the base maps of several cities is a tedious task, and this is what the Google Maps JavaScript API offers through its special objects.

In this recipe, we will add transit layers to the Google Maps map interface.

Getting ready

Continuing from the previous recipe, Adding the traffic layer, will simplify our work, as we will only replace the TrafficLayer object with TransitLayer classes. Remember to copy the code of the original recipe.

How to do it…

Here are the steps to show public transit lines as an overlay:

  1. Delete TrafficLayer related lines (the last two ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required