Kml overlay on java api. New points not plotted?

96 views
Skip to first unread message

az

unread,
Jul 7, 2011, 10:30:39 AM7/7/11
to google-map...@googlegroups.com
Hi 
I have a kml file that I plot to the map using 
var ctaLayer = new google.maps.KmlLayer('http://myserver/cta.kml');
ctaLayer.setMap(map);
Initially there were only 2 points in the kml file and they plotted OK first tile only.
Afterwards if I add new points to the kml they are not plotted at all. Is I change the name of the kml to something new, only then are the new points plotted.
Is there some kind of cache somewhere and how I can make the changes to kml file visible, i.e. newly added points plotted?
Thnaks


Chris Broadfoot

unread,
Jul 8, 2011, 1:59:19 AM7/8/11
to google-map...@googlegroups.com
Yes, there's a cache. I suggest appending a time-dependent dummy parameter to the URL:

var cacheBust = parseInt(new Date() / (1000 * 60 * 60), 10);
new google.maps.KmlLayer('http://myserver/cta.kml?' + cacheBust);

This will update the KML file every hour (1000*60*60 = one hour in milliseconds)

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/jNrV2YwC29YJ.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

az

unread,
Jul 11, 2011, 6:19:05 AM7/11/11
to google-map...@googlegroups.com
Thanks a lot. Will give it a try.
What is the minimum ammount of time that the cache might be updated.
Could it be every 10 minutes?

Rossko

unread,
Jul 11, 2011, 10:33:45 AM7/11/11
to Google Maps JavaScript API v3
> What is the minimum ammount of time that the cache might be updated.
> Could it be every 10 minutes?

KmlLayer cache expiry is under Google's control, you can't influence
it. It seems to be at least several hours.

The method Chris suggested circumvents the cache altogether, so you
needn't worry about cache expiry at all.

az

unread,
Jul 12, 2011, 5:35:17 AM7/12/11
to google-map...@googlegroups.com
Thanks,
Is circumverting the cache one of the means to overlay/show data added in real time?
In that note what is the best method for this?
The idea is that users will add x/y coordinate and these need to be plotted on the map. 

az

unread,
Jul 12, 2011, 5:38:25 PM7/12/11
to google-map...@googlegroups.com
Hi
thanks for that, but when I apply the cachebust, nothing happens - the map canvas is just a grey area.

Rossko

unread,
Jul 12, 2011, 6:31:46 PM7/12/11
to Google Maps JavaScript API v3
> thanks for that, but when I apply the cachebust, nothing happens - the map
> canvas is just a grey area.

Something is wrong. We can't see what.
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/2b3f101fd509919e

az

unread,
Jul 13, 2011, 6:20:22 AM7/13/11
to google-map...@googlegroups.com
I got it :)
Here it is:
Help appreciated.

az

unread,
Jul 14, 2011, 10:18:02 AM7/14/11
to google-map...@googlegroups.com
Hi
Could you please check my code. There is a problem with the cache dummy. 
Webaddress vbove.
Thanks

Rossko

unread,
Jul 14, 2011, 5:21:06 PM7/14/11
to Google Maps JavaScript API v3
You are not defining any centre for the map when you initialize it

az

unread,
Jul 15, 2011, 8:39:19 AM7/15/11
to google-map...@googlegroups.com
This is sorted now, but now the kml isnt plotted at all.
Reply all
Reply to author
Forward
0 new messages