How to add KML layer to the Web

1489
3
08-29-2013 04:46 AM
thanhnguyen6
New Contributor
Hi All:

I have a Python Toolbox that generate a KML (filename.kmz) and store it in the webserver directory.
I can access the file from Google Earth.  However, when I use this example (https://developers.arcgis.com/en/javascript/jssamples/layers_kml.html) from JavaScript resources I changed 

this line --> //var kmlUrl = "http://dl.dropbox.com/u/2654618/kml/Wyoming.kml";

to this --> var kmlUrl = "http://machine.test.com/filename.kml";

or

to this --> var kmlUrl = "http://machine.test.com/filename.kmz";

and got this error:

dojo.io.script error
Error: File not found. Wrong url or out of memory.

Note:  In Google Earth I can display the two files above.
What I am doing wrong?

Thanks,
Thanh
0 Kudos
3 Replies
ZachLiu1
Occasional Contributor II
It gave me the same error when I tried in on my server. At the beginning I thought it was a MIME type issue, but it didn't look so after I added them.

Here is a post with similar issue, but I didn't find any clue at the end.

http://forums.arcgis.com/threads/84091-Error-loading-KML-just-started-yesterday.
0 Kudos
thanhnguyen6
New Contributor
Hi ZachLiu

At beginning I cannot access the file from Google Earth either so I add MIME type:
Extension: .kml
MIME type: application/vnd.google-earth.kml+xml

Extension: .kmz
MIME type: application/vnd.google-earth.kmz

Then Google Earth see it.

But I still got the error from the Java Script above.

Thanks,
Thanh
0 Kudos
thanhnguyen6
New Contributor
Hi Zachlui:

I think I understand the problem.  The following statement is from here (https://developers.arcgis.com/en/javascript/jsapi/kmllayer.html)

To add a KML file(.kml or .kmz) to a map, the KML must be available via a publicly accessible URL. Locally hosted or KML files inside a firewall are not supported.

thanks,
Thanh
0 Kudos