Support » Plugin: Flexible Map » Dynamically generated KML

  • Resolved ei3hmb


    Hi there,

    I wrote a short php script to generate kml data dynamically from MySQL.
    There is no problem to display map with markers, but what I can see on the map is not what I have generated form my php script. It looks like google maps caches data loaded from the very first kml output.

    The code is:
    [flexiblemap src="" width="720" height="600"]

    How to force google maps to display kml generated in real time, not form cache?


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


    G’day J,

    This one’s in the FAQ:

    Why won’t my KML map update when I edit the KML file?

    Google Maps API caches the KML file, so it often won’t get your new changes. To force a change, append a URL query parameter with a number (known as a cache buster) and increment the number each time you change the KML file. A nice simple and commonly used parameter name is v (for version), like this:

    So, add a query parameter to the source URL. I suggest using the output of the time() function, which will change every second. If you aren’t generating the shortcode dynamically, then you can use a filter hook to change the KML src:

    add_filter('flexmap_shortcode_attrs', 'my_dynamic_kml');
    function my_dynamic_kml($attrs) {
        // src attribute is specified and is a PHP file?
        if (isset($attrs['src']) && strpos($attrs['src'], '.php') !== false) {
            // append a cache buster
            $attrs['src'] = add_query_arg(array('v' => time()), $attrs['src']);
        return $attrs;



    OK, it works now().

    Many thanks,


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamically generated KML’ is closed to new replies.