CSGeoXML

This is a JavaScript class based on Mike Williams‘ EGeoXml which is in turn based on the functionality available with Google’s GGeoXML.

The reason I rewrote Mike’s code was that it would add each individual item from the KML file as it parsed, but we needed to be able to add the entire KML file as a single overlay.  The GGeoXML function from Google Maps does this, but it’s shortcoming is that you have to load the KML file from a “publicly accessible server”.  In practice, this works for 90% of the world, unless you are developing on a local machine or have a server behind a firewall.

CSGeoXML solves both the problems mentioned above.  It will load local KML files using most of the code from Mike Williams’ EGeoXML, and it loads the entire KML file as a single overlay that can be added or removed as a whole.

To Download the file click one of the links below:

Download CSGeoXML.js 1.0

Download CSGeoXML 1.0 zipped

Example Code For adding a CsGeoXml Overlay:

  1.  var options = {noshadow: true}; //many options available
  2.  var csGeoXml = new CsGeoXml('csGeoXml', map, url, options);
  3.  var handle = GEvent.addListener(csGeoXml, 'parsed', function () {
  4.    GEvent.removeListener(handle);
  5.    map.addOverlay(csGeoXml);
  6.   });

Example Code for removing a CsGeoXml Overlay:

  1.  map.removeOverlay(csGeoXml);

If you have any problems with this code, or you need to see a specific feature, please leave a comment here. I will do my best to support the code through this page, and make updates as they come in. Also, as this is code we use I will be updating it from time to time. I will keep a list of versions in the download section of this page.