KML Rendering Issue

59 views
Skip to first unread message

gmap_wonderer

unread,
Jan 20, 2012, 5:17:37 PM1/20/12
to google-map...@googlegroups.com
I'm using a KMLLayer to load a KML file, which contains 955 placemarks.  Most of the time, it works perfectly fine, but once in a while, one of tiles of KML layer is disappeared. A entire square block was not drawn.  See attached picture and notice that a square in the south west area were not drawn.  Originally I used one KML file (2MB) when I found the issue.  Then, I divided it into five different files, but the problem persists.

I'm wondering whether there is something I can do to avoid or this is a known issue. 

Thanks!


Joseph Elfelt

unread,
Jan 21, 2012, 5:15:36 PM1/21/12
to Google Maps JavaScript API v3
Help us help you.
Please post a link to your map (per the forum rules) instead of a png.

gmap_wonderer

unread,
Jan 23, 2012, 12:32:56 PM1/23/12
to google-map...@googlegroups.com
Here it is: http://sonicop.dyndns.org/kml/prototype.html

Please understand the problem is intermittent. I googled more and found the following issue
http://code.google.com/p/kml-samples/issues/detail?id=413 very similar to what I got, but there was no reply.

Thanks!

Joseph Elfelt

unread,
Jan 23, 2012, 3:44:57 PM1/23/12
to Google Maps JavaScript API v3
I just tried your map and it worked fine.
But as you point out, the problem is intermittent

Thanks for the posting a link to that issue.
I added my star since I work a lot with KML files.

I see that you are displaying 5 KML fils that are hosted at sonicop.
Maybe the problem is related to the speed/load of the sonicop server.

One way to test that would be to upload copies of the files to Google
Sites (fast servers, lots of bandwidth). Also make a second version
of your program to display those duplicate files. Then when you have
a problem displaying the files from sonicop you could right away try
to display them from Google Sites.

Rossko

unread,
Jan 23, 2012, 3:50:40 PM1/23/12
to Google Maps JavaScript API v3
> I'm using a KMLLayer to load a KML file, which contains 955 placemarks.

It's getting a bit close to the maximum features limit
http://code.google.com/apis/kml/documentation/mapsSupport.html

There have been a few threads kicking around which suggest that
Google's KML parser will abort renderings of large, complex or slow-to-
serve files due to a timeout. There's no clear indication that is the
root issue, but the result seems to be apparently 'random' failures.
Some people have had success by minimizing the delays under their
control, e.g. removing redirections, serving flat files instead of
building dynamically, finding fast hosting.

It would be nice if some failure type indication were available, this
is all guesswork.

gmap_wonderer

unread,
Jan 23, 2012, 7:47:34 PM1/23/12
to google-map...@googlegroups.com
Thanks, Joseph. I actually tried your idea and put my files over there at Google Sites.  But, the problem persists.  To reproduce the problem, I would keep hitting refresh button my page and I would see the problem at least 1 out of 10 refreshing.

gmap_wonderer

unread,
Jan 24, 2012, 1:56:32 PM1/24/12
to google-map...@googlegroups.com
Hi Joseph,
I ran across one of your post somewhere else, and as a workaround one of your suggestion was to use a timer.  Would you mind sharing or elaborate a little more on how you have come about it?  If such timer waits and retries, it would work in my case as well.
Thanks!

Joseph Elfelt

unread,
Jan 24, 2012, 3:59:50 PM1/24/12
to Google Maps JavaScript API v3
Here's the timer I'm using. Note that I am listening for when the KML
tiles start to load. It sounds like you want to tweak the listeners
to try and trap the case of when the KML tiles start to load but do
not finish loading. You could then display an appropriate error
message and/or delete the KML layer and try to reload it a second
time.

masu.timer_kml_load = setTimeout("display_timeout_message()",
10000);
masu.kml_layer.setMap(masu.map);
// Listen for when the visible tiles of the kml map are
ready to start loading
// This requires two nested listeners. The first tiles the
user sees will be for the KML map
google.maps.event.addListenerOnce(masu.kml_layer,
"defaultviewport_changed", function() {
google.maps.event.addListenerOnce(masu.map,
"bounds_changed", function() {
clearTimeout(masu.timer_kml_load);
// do some more stuff...
});
});

gmap_wonderer

unread,
Jan 24, 2012, 6:09:15 PM1/24/12
to google-map...@googlegroups.com
Very clever idea, Joseph. I bet you had only one KmlLayer and it doesn't preserve the viewPort. Mine has multiple layers and their preserveViewport is set to true.  So, the second listener for 'bounds_changed' 's never been caught.  I searched and tried other events (such as idle and tilesloaded), but they didn't get caught when each layer is complete.  I wish KmlLayer had it another own event when the loading is complete.

Joseph Elfelt

unread,
Jan 24, 2012, 6:36:56 PM1/24/12
to Google Maps JavaScript API v3
Yes and no.

I only have 1 KML layer.

I'm using:
masu.kml_layer.set('preserveViewport', true);
Reply all
Reply to author
Forward
0 new messages