I created a hello world program to load a local kml file (borrowed from google's docs):
var ctaLayer = new google.maps.KmlLayer("http://localhost:8080/kml/cta.kml");
This does not work (nothing gets loaded).
However, when I change that line to:
var ctaLayer = new google.maps.KmlLayer("http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml");
it loads properly. Both kml files are identical. What do I need to do to get it to load when serving it myself? (I tried both absolute and relative paths, and I know the paths I am using are correct...)
Also I added the correct mime type to my appserver's config file:
<mime-mapping>
<extension>kml</extension>
<mime-type>application/vnd.google-earth.kml+xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>kmz</extension>
<mime-type>application/vnd.google-earth.kmz</mime-type>
</mime-mapping>
But it still doesn't load.
I found this in google's docs:
The Google Maps API supports the KML and GeoRSS data formats for displaying geographic information. These data formats are displayed on a map using a KmlLayer object, whose constructor takes the URL of a publicly accessible KML or GeoRSS file.
So I guess what I am trying to do is not possible without serving the kml from a publicly accessible url...unless someone can prove otherwise
The KML can't be accessed since it's on your local machine and google can't access that since it doesn't know how to get to localhost:8080