Flexible Map
[resolved] Dynamically generated KML (3 posts)

  1. ei3hmb
    Posted 3 years ago #

    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="http://EI3HMB.e-donegal.eu/map.php" width="720" height="600"]

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



  2. webaware
    Plugin Author

    Posted 3 years ago #

    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: http://example.com/my-map.kml?v=2

    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;


  3. ei3hmb
    Posted 3 years ago #


    OK, it works now().

    Many thanks,


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Flexible Map
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic