[OpenLayers-Users] KML doesn't display from Http response

fdesbois fdesbois at codelutin.com
Wed Jul 7 10:48:10 EDT 2010


Hi,

I've got a problem when loading a KML file. If I use an existing file
in my webapp, the layer appears correctly, but if I use a Servlet
returning a Kml as response, it doesn't work.

Here is the KML initialization where title and url are parameters of
initialize method put onLoad of the page : 

var kml = new OpenLayers.Layer.GML(title, url, {
            format: OpenLayers.Format.KML,
            formatOptions: {
                extractStyles: true,
                extractAttributes: true
            }
    });

In firebug, there is those results. The both contents are the same KML
file. The KML is valid and generated using JavaApiForKml [1]


KML file ------------------------------------------------

url = "temp.kml"

Response

Server		Apache-Coyote/1.1
Accept-Ranges	bytes
Etag		W/"46676-1278501078000"
Last-Modified	Wed, 07 Jul 2010 11:11:18 GMT
Content-Length	46676
Date		Wed, 07 Jul 2010 13:13:09 GMT

Request

Host		localhost:8080
User-Agent	Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.2.6)
		Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6 
Accept		text/html,
		application/xhtml+xml,
		application/xml ;q=0.9,*/*;q=0.8 
Accept-Language fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding	gzip,deflate 
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7

KML stream -------------------------------------------------

url = "servletName"

Response

Server			Apache-Coyote/1.1
Content-Type		application/vnd.google-earth.kml+xml
Transfer-Encoding	chunked
Date			Wed, 07 Jul 2010 13:20:45 GMT

The request is the same

I have the same result with content-type = application/xml

-------------------------------------------------------------

I use OpenLayers with Apache Tapestry [2] Java Framework. I have a
simple page that returns a StreamResponse with content-type as
specified above.

If it's not possible, do you have any tips to display the KML without
creating explicitely the file on server or how to create it easily
directly in webapp and remove the file in javascript ?

Thanks for your help

[1] http://code.google.com/p/javaapiforkml/
[2] http://tapestry.apache.org/tapestry5.1/

-- 
Florian Desbois <fdesbois at codelutin.com>
SSLL Code Lutin
http://www.codelutin.com
tel : 02 40 50 29 28
Réseau Libre-Entreprise 



More information about the Users mailing list