Adding the bicycling layer

It is good to have the information about the cycling paths and common routes on top of base maps; Google Maps offers this as an overlay layer.

In this recipe, we will introduce the bicycling layer and its usage as an overlay in the Google Maps JavaScript API.

Getting ready

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

How to do it…

The steps required for showing the cycling paths and routes are presented as follows:

  1. Change the two lines containing TransitLayer, supplanting the BicyclingLayer object instead of the TransitLayer object:
     var bicyclingLayer = ...

Get Google Maps JavaScript API Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.