Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 887 Bytes

File metadata and controls

36 lines (29 loc) · 887 Bytes

⚠️ This document is aim for older versions (from 2.3.0 to 2.5.3). Document for new version is https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.6.0/README.md

map.setTrafficEnabled()

Set true if you want to show the traffic layer.

<div class="map" id="map_canvas">
    <span class="smallPanel"><button>current: map.trafficLayer = false</button></span>
</div>
var div = document.getElementById("map_canvas");
var map = plugin.google.maps.Map.getMap(div, {
  camera: {
    target: {
      lat: 37.422858,
      lng: -122.085065
    },
    zoom: 10
  }
});

var isEnabled = false;
var button = div.getElementsByTagName('button')[0];
button.addEventListener('click', function() {
  isEnabled = !isEnabled;
  map.setTrafficEnabled(isEnabled);
  button.innerHTML = "current: map.trafficLayer = " + isEnabled;
});