1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
5 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
6 <title>Google Maps JavaScript API Example: Traffic Overlays</title>
7 <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAEVw7F2FrOuAa5Y0vvjDw-hS4Kh9Yhf3T4FdRv0A-Zia9EqEJDhTpraMfVaMs-QO-RzRPqUC6tPLIqA"
8 type="text/javascript"></script>
9 <script type="text/javascript">
15 function initialize() {
16 if (GBrowserIsCompatible()) {
17 map = new GMap2(document.getElementById("map_canvas"));
18 map.setCenter(new GLatLng(39.966596,-75.123825), 9);
20 var trafficOptions = {incidents:true};
21 trafficInfo = new GTrafficOverlay(trafficOptions);
22 map.addOverlay(trafficInfo);
26 function toggleTraffic() {
27 if (toggleState == 1) {
28 map.removeOverlay(trafficInfo);
31 map.addOverlay(trafficInfo);
38 <body onload="initialize()">
39 <div id="map_canvas" style="width: 640px; height: 480px; float:left; border: 1px solid black;"></div>
42 <input type="button" value="Toggle Traffic" onClick="toggleTraffic();"/>