Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26647

How to improve KML performance

Hi I'm having some issues with KML performance. At some times the KML markers only appear after a reload which may have to do with google caching the results. I think a better solution is needed perhaps something like displaying a total of markers for an area on a larger zoom level and then more detailed for levels that have more zoom. Is such a solution feasible and if so, how? Can you think of other ways how I can improve performance of my KML map? The links are http://www.koolbusiness.com and the KML file is http://www.koolbusiness.com/list.kml

I can load the KML file into maps.google.com with no problem however when trying to display it on my custom map the display sometimes won't load. Thanks in advance for any suggestions.

UPDATE: I've updated to using a KMZ file with zip compression. The file is available via http://www.koolbusiness.com/list.kmz and the source and more info is available at http://montao.googlecode.com

Upvotes: 1

Views: 2644

Answers (2)

Tony
Tony

Reputation: 933

I'm not sure if you've changed the KML yet to conform to some of the previous suggestions but...

  • The KML File seems to be pretty minimal which is good. I was going to suggest truncating the decimal points on the lat/lng.
  • You can compress like KML file to KMZ like the previous poster has mentioned. More information can be found here: http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server You'll need to set up the KMZ MIME type on your server too.
  • You can reduce the amount of white space in your KML file. It seems to have additional spaces when not required...
  • You can configure your web server to send cached versions of the KML file... I'm not sure what kind of back end you're running though so I can't really give pointers. This might be a reason why the markers don't show. Google's server will time out your request if it takes too long.

As for your question about a solution to displaying total markers in an area for a zoom: I was thinking you could for each zoom level, check the boundary of the map and then only display markers that have coordinates in that boundary. You'd probably have to write some kind of function that checks if it's in the boundary. I don't know of any way to retrieve the markers from the KML file as objects unless you manually parse the KML yourself using a client side parser.

To help determine why your markers don't load, try using FireBug to determine the requests to Google's servers. And see what kind of response is returning which might lead to more answers to your problem. I believe the one you should look for is KmlOverlayService.

Hope that helps.

Upvotes: 1

Björn
Björn

Reputation: 1601

don't know if it affects performance but it seems like you need to configure the mime types for kml files. http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server

Have you tried to compress the kml files as kmz files? You can do this with a zip program and just call the file kmz.

You repeat the style element in the placemarks but you can also create them under the doucment element and then just reference them with an id. http://code.google.com/apis/kml/documentation/kmlreference.html#style

Upvotes: 2

Related Questions