[OpenLayers-Users] Problems displaying kmz file in OpenLayers

Christopher Schmidt crschmidt at metacarta.com
Thu Mar 26 12:50:14 EDT 2009


On Thu, Mar 26, 2009 at 05:08:23PM +0100, Asle Benoni wrote:
> Hi,
> I am really frustrated about not beeing able to display a kmz layer in  
> OpenLayers.
> Here is the code:
> 
>                  map.addLayer(new OpenLayers.Layer.GML("Gravminne", "http://naturkart.no:8080/geoserver/wms/kml?layers=kulturminner_ns:gravminne&format=application/vnd.google-earth.kml+XML&transparent=true&srs=EPSG:4326&transparent=true& 
> ",
>                 {
>                  format: OpenLayers.Format.KML,
>                  formatOptions: {
>                    extractStyles: true,
>                    extractAttributes: true,
>                    transparent:true
>                  }
>                 }));
> 
> I can see the http request from the proxy so it is fetching correct  
> data (I think) but I cannot see any on the map!
> The request looks like this (FireBug). I am not sure if the EPSG is  
> correct. I also tried "EPSG:32632" which I set for the map.
> 
> http://naturkart.no:8080/geoserver/wms/kml?layers=kulturminner_ns:gravminne&format=application/vnd.google-earth
> .kml+XML&transparent=true&srs=EPSG:4326&
> 
> But in the response I see
> <href><![CDATA[http://naturkart.no:8080/geoserver/wms?format_options=KMPLACEMARK%3Afalse
> %3BKMATTR%3Atrue%3BKMSCORE%3A50%3BSUPEROVERLAY%3Afalse 
> %3B&service=wms&srs=EPSG%3A4326&width=1024&styles
> = 
> point 
> &height=1024&transparent=false&request=GetMap&layers=kulturminner_ns 
> %3Agravminne&format=application
> %2Fvnd.google-earth.kmz%2Bxml&version=1.1.1]]></href>
> 
> 
> Can anyone point to how to show a KMZ file from GeoServer as I need  
> the options for that layer format. I checked the docs but did not get  
> wiser.

KMZ files can not be loaded by OpenLayers. They are zipped (compressed)
and we can not unzip content in Javascript. You should be able to load a
KML file, which is what it appears you are actualy trying to do.

This KML file includes a networkLink, which is not parsed unless:

 1. You are using trunk (not 2.7)
 2. You have set maxDepth to some number greater than 1.

Finally, it appears that the GeoServer KML service requires a BBOX with
the query, but OpenLayers does not add a BBOX To networklinks the way
that GOogle Earth does.

And even when I add the BBOX manually, I s till get an error, so in
 that case I don't know what the problem with this is, but I do know
 that it is unlikely you will be able to get what you want from
 OpenLayers, without digging into the code and probably consulting with
 the geoServer team.

Best Regards, 
Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list