Posted by hankliu on May 20, 2010 at 10:06am
4 followers
Jump to:
| Project: | GMap Module |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hi, how can I add traffic overlay to map? I installed the GMAP Addon module but could not figure out how to add traffic overlay. Thanks in advance for any suggestion.
Comments
#1
Hi Hankliu
Im not getting much help about overlay issues. hmm. Cannot understand how to use the add on modules that cleary have the overlay functionality.
#2
Hi OpenSourcer, same here. Has anybody successfully added traffic to map?
#3
Hi
You can add overlay to the map by adding 'overlay' sections into your macro in 'Build a GMap macro'. You can use kml files like this which using Google Earth. Instruction is in: modules\gmap_addons\gmap_overlays\README.txt
I builded macro with line 'overlay=kml:http://mapgadgets.googlepages.com/cta.kml ' for tests:
[gmap overlay=kml:http://mapgadgets.googlepages.com/cta.kml |markers=small red::41.840408844786396,-87.71209716796875 |zoom=9 |center=41.887965758804484,-87.81646728515625 |width=700px |height=500px |control=Small |type=Physical]
but something is wrong because I get warning and overlay don't display:
warning: Invalid argument supplied for foreach() in C:\...\drupal-6.16\modules\gmap_addons\gmap_overlays\gmap_overlays.module on line 46.
I tried to open 'http://mapgadgets.googlepages.com/cta.kml' file in Google Earth and it work, so I think something is bad with 'gmap_overlays' module.
I'm using:
PHP 5.3.1
Drupal 6.16
gmap-6.x-1.1-rc1 with some patches for PHP 5.3.1
Sorry for my English.
#4
I've added traffic to the map. I know this thread is a bit old but it might save someone time in the future:
In a javascript file (traffic-overlay.js):
(function($) {
// just to make sure everything is loaded properly
if(($('#map_id')) && (Drupal.gmap)) {
Drupal.gmap.addHandler('gmap', function (elem) {
var obj = this;
obj.bind('init', function () {
var trafficOptions = {incidents:true};
trafficInfo = new GTrafficOverlay(trafficOptions);
obj.map.addOverlay(trafficInfo);
});
});
}
})(jQuery);
Then:
<?php// scope ensures that the gmap object is properly loaded before this code gets called
drupal_add_js('/path/to/js/traffic-overlay.js',array('scope'=>'footer'));
?>