CSGeoXML can load KML files locally as a single overlay

2008 November 4

If you have used GGeoXml or EGeoXml you know what it means to load a KML file to your google map. However, if you have tried to develop locally, or develop for a server behind a firewall, then you know the pain that comes with loading KML files locally.

EGeoXml does a splendid job of loading local KML files, but it loads each item as a single overlay. I wanted to be able to add and remove the overlays from the KML file as a single overlay.

So, I looked into what Mike Williams did with EGeoXml and added a little code to allow the class to add everything and remove everything at once.

You can get to our CSGeoXml Page by going through “Projects” at the top navigation, or by going to the CSGeoXml Page.

Sphere: Related Content

12 Comments leave one →
2008 December 23

i’ve got some questions:

-is the “csgeoxml” working with firefox on macosx or am i probably doing something wrong? (have a look at the website: http://homepage.mac.com/pman88/maps )

-how can i remove the layer again?
only: map.removeOverlay(csGeoXml); doesn’t work with me.

2009 January 5

I have looked at the script in FF on Mac OSX and it seems to be loading just fine.

What I would suggest is looking into your timing in your scripts. If the csGeoXml variable is not populated properly then the map cannot remove it.

Please get firebug and send me any JS errors that you are getting and I will do my best to work through the problem. The last thing I would suggest for you to send to me with the JS errors, would be your KML file so that I can test on my local machine.

2009 February 9

[...] The developers for CloudSync.com have been let loose to share ideas, scripts, and knowledge with the rest of the web devloper world.  They have so far discussed topics ranging from using mod_gzip, to dynamically creating custom markers for google maps, and even loading a local KML file as a single overlay on google maps. [...]

Pingback
2009 June 6
xriz UNITED KINGDOM Blackberry 8100 permalink

Hi, I’m not a developer. I hope it doesn’t interfere with d usage of d csgeoxml. Thanks I really need ds stuff

2009 December 1
Martin POLAND Windows Vista Opera 9.80 permalink

When I try to load local KML with Internet Explorer I received a “Permission Denied”.
This is my code:

var options = {noshadow: true};
var pippo = new CsGeoXml(‘csGeoXml’, map, ‘file:///c:/abc.kml’, options);
var handle = GEvent.addListener(pippo, ‘parsed’, function () {GEvent.removeListener(handle); map.addOverlay(pippo);});

Can you help me? Thanks

2009 December 1
Matt Marzin UNITED STATES Windows XP Google Chrome 3.0.195.33 permalink

I’m trying to use your example above to plot a kml and an error occurs on:

line 79: CsGeoXml.prototype = new GOverlay();

am i doing something wrong?

2009 December 2

I have not seen this error before. How does IE deliver this message to you? Is it a pop up or in he error console? Also, what version of IE are you using?

2009 December 2

What is the error?
What browser?
Do you have a link?

2009 December 2
Matt Marzin UNITED STATES Windows XP Google Chrome 3.0.195.33 permalink

Sorry, I should have included that before. I’ve been using Google chrome and Firefox with firebug. I believe it is trying to compile the csgeoxml.js file and it throws some sort of an error on that line(79). The console doesn’t say what the error is, it just points at the line.

I’m running a rails application running on localhost. My code is included below.
var options = {noshadow: true}; //many options available
var csGeoXml = new CsGeoXml(‘csGeoXml’, map, ‘http://localhost:3000/flights.kml’, options);
var handle = GEvent.addListener(csGeoXml, ‘parsed’, function () {
GEvent.removeListener(handle);
map.addOverlay(csGeoXml);
});

2009 December 2

Which version of the maps API are you using? It is possible that the newer versions of the API do not provide the GOverlay function.

2009 December 2
Martin ITALY Windows Vista Opera 9.80 permalink

When I use my code (see my first post) I see a new window with this data:

Line: 486
Char: 109
Error: Permission denied
Code: 0
URL: http://maps.gstatic.com/intl/it_ALL/mapfiles/184a/maps2.api/main.js

I use API v2 and IE7/8 (Windows XP/Vista) with the same error.

Besides I think I have found a bug on line 210 of CSGeoXML, I have replace this line “CsGeoXml.prototype.createPolygon = function() {” with this “CsGeoXml.prototype.createPolygon = function(data) {“.

Can you help me with my “Permission denied” error?

2009 December 2

The KML file should be local to the server you are running the code on, and should be a web-accessible path as well.

Leave A Comment

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS