• Resolved danadanadana

    (@danadanadana)


    Hi,

    I was wondering if it’s possible to add a traffic layer to a kml map with your plugin.

    I’m working on a project where I need to have two maps on a page zoomed into a specific point. The maps have to be kml because they need a path drawn on them and one map has to have a traffic layer and the other doesn’t.

    I was able to accomplish the traffic layer with a kml file using the comprehensive google maps plugin but that doesn’t allow zooming in to a specific point on the map so it’s really not ideal and I would prefer to use your plugin. And anyway I can’t use both plugins on the same page because the map api is being called twice and I haven’t been able to sort that out yet.

    So sorry for the long explanation — basically I’m just hoping there’s a way to add a traffic layer on a kml map using your plugin.

    Thanks for all your hard work!

    http://ww.wp.xz.cn/plugins/wp-flexible-map/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author webaware

    (@webaware)

    G’day danadanadana,

    The plugin itself doesn’t do that, but it’s very easy to add a traffic layer if you can add some JavaScript to your page. Here’s an example, using a map with an ID “with_traffic”:

    [flexiblemap src="http://snippets.webaware.com.au/maps/example-toronto.kml" width="100%" height="400" id="with_traffic"]

    Add this script to your page or post, e.g. in the footer:

    <script>
    jQuery(window).load(function($) {
        if ("flxmap_with_traffic" in window) {
            var map = flxmap_with_traffic.getMap();
            var trafficLayer = new google.maps.TrafficLayer();
            trafficLayer.setMap(map);
        }
    });
    </script>

    NB: assumes you have jQuery loaded; if not, please enqueue it in your plugin or theme.

    cheers,
    Ross

    Thread Starter danadanadana

    (@danadanadana)

    That was so easy!!

    Thank you!!!!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Add Traffic Layer’ is closed to new replies.