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.
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.
The steps required for showing the cycling paths and routes are presented as follows:
Change the two lines containing
TransitLayer
, supplanting theBicyclingLayer
object instead of theTransitLayer
object:var bicyclingLayer = new google.maps.BicyclingLayer (); bicyclingLayer.setMap(map);
You can observe the cycling paths and routes on top of the Google Maps base maps as shown in the following screenshot: