How can I add a Traffic Layer to a map?
How can I add a Traffic Layer to a Map?
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
How can I add a Traffic Layer to a Map?
Hello! You would need to check Google API docs https://developers.google.com/maps/do...
This is how far I have gone...
var map = Tiggzi('map');
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);
am I missing anything?
Sorry, I need more details. Do you have any specific problem?
sorry, I am getting the map.
This works fine in getting me the map and current location.
var map = Tiggzi('map');
map.options['address']='';
map.refresh();
after trying to understand the layers adding link from google api, in order to add the traffic layer I did this.
var map = Tiggzi('map');
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);
map.refresh();
With this change I lost current location and still not getting the traffic layer. I am wondering if my syntax is way off.
Instead of
codevar map = Tiggzi('map');
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);
map.refresh();/code
try this code:
codevar myLatLng = new google.maps.LatLng(34.04924594193164, -118.24104309082031);
var mapOptions = {
zoom: 13,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(Tiggzi("mapName").get(0), mapOptions);
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);/code
where mapName - GoogleMap component name
it didn't work, should i use a div, instead of the google map control?
Hello! You can use either map or Panel with div type. The problem is probably that code loads before map. You would need to track map loading and add the code after map load.
To use Panel with div type, but as you would need to delete map component, to get it working add in App settings - External resources next link
http://maps.google.com/maps/api/js?se...