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 traffic layer

In today's world, the condition of traffic is very important information in cities. If there is an accident on the way or a recent construction that blocks an important street, it affects your whole day. How useful would it be to have real-time traffic information directly on your maps?

The Google Maps JavaScript API has a very handy aspect that lets you have traffic information fed on a real-time basis on top of your base maps.

In this recipe, we will cover how to display traffic information on your Google Maps.

Getting ready

We can use the first recipe of Chapter 1, Google Maps JavaScript API Basics, as a base for the basic map display. After copying the code of the original recipe, you can proceed forward.

How to do it… ...

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