Google Maps bases its traffic views and faster-route recommendations on two different kinds of information: historical data about the average time it takes to travel a particular section of road at specific times on specific days and real-time data sent by sensors and smartphones that report how fast cars are moving right then.
Early versions of Google Maps relied only on data from traffic sensors, most of which were installed by government transportation agencies or private companies that specialize in compiling traffic data. Using radar, active infrared or laser radar technology, the sensors are able to detect the size and speed of passing vehicles and then wirelessly transmit that information to a server.
Data from these sensors can be used to provide real-time traffic updates, and, once collected, the information becomes part of the pool of historical data used to predict traffic volume on future dates. However, sensor data was largely limited to highways and primary roads because the sensors were typically installed only on the most heavily traveled or traffic-prone routes.
Beginning in 2009, Google turned to crowdsourcing to improve the accuracy of its traffic predictions. When Android phone users turn on their Google Maps app with GPS location enabled, the phone sends back bits of data, anonymously, to Google that let the company know how fast their cars are moving. Google Maps continuously combines the data coming in from all the cars on the road and sends it back by way of those colored lines on the traffic layers.
As more and more drivers use the app, the traffic predictions become more reliable because Google Maps can look at the average speed of cars traveling along the same route without misinterpreting someone's morning coffee stop as a traffic jam. If Google Maps doesn't have enough data to estimate the traffic flow for a particular section of road, that section will appear in gray on the traffic layer.