Does the Google Map Plugin cache the KML layer being added to a map?

You are here : Home / Does the Google Map Plugin cache the KML layer being added to a map?

resolved
Public
Good or Bad - Rate our Support

I am running a frontend map with a KML file that is contantly being updated throughout the day. unfortunately, the KML file is being updated, but the map is showing the first version of the KML file.

is there a cache system that might be causing this? or is there something you can do to help me?

you can see the map here: http://www.keyscience.org/cs-lab/map/

thanks for any support and for a great plugin!

Public
Hello,
Yeah this is absolutely possible your facing cache issue. I am getting this map right now. Is it right or getting wrong kml.

Thanks

#1
Public
Thanks for the quick response!

no, that is not the correct map. there should be a red dot in the water to the left of the island.

can you help me deactivate any caching with the KML layers? or maybe set the cache to dump every 1 or 2 hours?

thanks for any advice or help you can give me!

nate.
#2
Public
Hello,
I checked your website source and found you are also using custom kml codes in your site. I think thats why you are facing this issue. Whenever you want to change kml layer you need to change it on kml layers located under layer settings.

Thanks
#3
Public
thanks for looking into it!

the concept of this section of the website is that users can upload photos on the "Record" page, after which we create a new KML file (maps.kml) with their upload and resave it (maps.kml). then, your plugin renders the KML file (maps.kml) on the "Map" page.

our problem is that after a user uploads, we must change the filenames (maps-1.kml) to get the map to render properly.

can you explain what you mean by "custom kml codes"? is it an issue with the KML file?

thanks!!!

nate.
#4
Public
No, i mean i found some codes related to kml in your view source.

Thanks
#5
Public
oh! yes, i forgot to remove the old Google Earth code. it is removed now.

unfortunately it is still showing the wrong version of the KML file. is there something in the plugin causing the cache? and can it be turned off?

thanks!
#6
Public
Hi,
I have been working on this same issue for months, and yes google caches kml files. I think for very long periods of time. I have just found what may be a work around, as I also use in the map a link that has the same file name and the underlying data changes daily.
So the workaround I found was to use network link option.
I created a kml file like this



Storm Events

http://www.spc.noaa.gov/climo/reports/yesterday.kmz -> this is the original layer link
onInterval -> this is the refresh type
300 -> this is interval in seconds minimum is 300 (google)




Name this kml what you like and put it in the map manager klm link mine is like http://mydomain/wp-content/uploads/mynetworklink.kmz

Will see how it goes over the next couple of days to see if my site matches the noa site data.

John
#7
Public
Ok, I do not know how to answer in the text
So this link is to the page that started me on the answer

https://groups.google.com/forum/#!topic/kml-support-getting-started/c4PLRQe1Adw
#8
Public
One more try........ for my kml file

[code language="xml"]
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<NetworkLink>
<name>Storm Events</name>
<Url>
<href>http://www.spc.noaa.gov/climo/reports/yesterday.kmz</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>300</refreshInterval>
</Url>
</NetworkLink>
</kml>
[/code]
#9
Public
Hello johnpittman,

Thank you very much for your valuable suggestions, we also tested this issue with both kml/kml at our end and found ,we need to change every time file name then output is change otherwise previous output is displayed everytime.

Thanks

#10
Public
Yes, I have found that this is unreliable also......
A way to over come is like you say and change the name each time the page is refreshed or on an interval, as some may need frequent or as I do once a day. Maybe you could add code to do this. Some thing like

[code]var URL = filename+"?dummy="+(new Date()).getTime();[/code]

just a thought
#11
Public
thanks for the suggestions john! did your method work for you?

divyang, thanks for testing it out. do you have any suggestions for a workaround?

thank you!
#12
Public
Nathnmoyer,
No, it is not reliable with the use of network refresh. Only changing the name seems to work each time. But that is not practical, editing a map in admin mode every day or whatever period you need updates. Short of spending time to figure out a patch for the code, no. My source for kml file always uses the same name with data changed.


Divyang,
The programers are going to need a method so that any time the page is refreshed or an interval has pasted (short), they takes the kml filename from the settings and add a timestamp to the name before sending the request to google maps for update.
example orginal link read data from somesite . com / my.kml to temp file then change it to my20:21:43.kml and request from google with new temp file
John


#13
Public
Hello Nathnmoyer,
I have discussed with our developer team and they are saying we can solve it. Please provide us your wp login details at support@flippercode.com

Thanks
#14
Public
I figured out a way to get google to allow the kml to update, at least it is wotking the last day
At the end of the kml link add ?date();
So
[code] http://someplace.com/this.kml?date(); [/code]

give it a whirl.

john
#15
Public
Hello,
Yeah, that's how we implemented it right now. Please check it and let me know if any issue.
Thanks
#16
Public
By doing this in manage maps, it worked a couple of times and then it stopped working. I need to change it again in the manage maps.
It needs to go in the actual php code that is calling google. I'm not sure where that is, it looks like maps.js layer_options.
So do you have a modified version of the plugin to try?

Thanks
John
#17
Public
Hello,
Previous we were adding version number in maps.js. Now we have added this in php file put-wpgmp.php. Please let me know if any issue. If any issue, please arrange FTP also so it's safe to do changes.

Thanks
#18
Public
Divyang,
Thanks for the location in the code that needs attention, samed some time to hunt it down :)
I went ahead and renamed the file to a bakup and modified the code to add a time to the end, as that will be different every second.
It seems to be working Ok, at least right away. I will see over the next few days if it works or there is a bug in what I did. I'm not a php programer and have done coding in my past, mostly object oriented pascal like Delphi.
So what I added was
--- added this to get around google overlat caching (JGP 3/26/2017 ---
[code]
foreach ($kml_layers_links as $thislink => &$item) {
$kml_layers_links[$thislink] = $item ."?" .date("h:i:s");
}
[/code]
at about line 215

Let me know if there is a problem with coding it this way.

Thanks!!
John Pittman

[/code]
at about line 215

Let me know if there is a problem with coding it this way.

Thanks!!
John Pittman
#19
Public
thanks to both of you! it seems to be working well for me!

if something comes up, i will pop back in here to discuss. but as it stands, i think this fixed my issue.

thanks!

nate.
#20
Public
Hello,
Your most welcome :)

Thanks
#21
Public
john,

i think this is the relevant code from put-wpgmp.php. it is line 208-219 i think

// KML Layer.
if ( ! empty( $map->map_layer_setting['choose_layer']['kml_layer'] ) && $map->map_layer_setting['choose_layer']['kml_layer'] == 'KmlLayer' ) {
if ( strpos( $map->map_layer_setting['map_links'], ',' ) !== false ) {
$kml_layers_links = explode( ',', $map->map_layer_setting['map_links'] );
} else {
$kml_layers_links = array( $map->map_layer_setting['map_links'].'?v='.time() );
}

$map_data['kml_layer'] = array(
'kml_layers_links' => $kml_layers_links,
);
}
#22
Public
nathan,
i used the foreach loop to modify the array , because in the manage map settings there can be multiple links defined seperated by a comma. so this method works to change all links in the array and not just one.
so Iadded my 2 linnes just after the array after i was cast to an array of string.
this way there can be mutiple kml links in the settigs and all are converted to link?hh:mm:ss
i added at line ~219
John
so far it has worked for 2 updates of the kml link i use from spc,noaa,gov for storm events
#23
Public
awesome! glad to hear!

i am not sourcing anything as large as NOAA, and my updates seem to be running smoothly. i think i have had about 15 submissions (updates) since the edit, and they have all been presented on the page properly.

thanks for your involvement and good luck with your project! it sounds like we are slightly dabbling in the same content areas.

thanks,

nate.
#24

Please login or Register to Submit Answer

Customize Product according to your requirements?

We will be glad to discuss any of your needs related to our wordpress plugins . if any of functionality you'd like to see in products, you can reach us by via email hello@flippercode.com.