[OpenLayers-Users] Problems displaying kmz file in OpenLayers

Asle Benoni asle.benoni at gmail.com
Sat Mar 28 06:12:10 EDT 2009


Hello,
I tried the new WFS code but I still get this response:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE
ServiceExceptionReport SYSTEM "http:
//schemas.opengis.net/wms/1.1.1/WMS_exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1" >
  <ServiceException code="MissingParameterValue" locator="request">
      Could not determine geoserver request from http request
org.apache.catalina.connector.RequestFacade
@10f829
</ServiceException></ServiceExceptionReport>


I wonder if this WFS call can give me what I want with a KML response. I
want to be able to click on the location and a popup with a style for the
popup, show a picture, a link etc. fetched from the PostgreSQL table.

/asle

2009/3/27 Andreas Hocevar <ahocevar at opengeo.org>

> Hi,
>
> On Thu, Mar 26, 2009 at 5:08 PM, Asle Benoni <asle.benoni at gmail.com>
> wrote:
> > 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
> >                 }
> >                }));
>
> The geoserver url you are using here will always return KMZ, which
> OpenLayers cannot parse. Instead, you should use the following to
> create your layer:
>
> map.addLayer(new OpenLayers.Layer.WFS("Gravminne",
> "
> http://naturkart.no:8080/geoserver/wms?service=WMS&request=GetMap&layers=kulturminner_ns:gravminne&format=kml&srs=EPSG:4326
> ",
>                 {
>                 format: OpenLayers.Format.KML,
>                 formatOptions: {
>                   extractStyles: true,
>                   extractAttributes: true
>                 }
>                 }));
>
> Is there a specific reason why you  want to use KML? WFS would give
> you the same result, you would only have to use a style map for your
> symbology in addition. This is how to add the layer using the new WFS
> protocol:
>
> map.addLayer(new OpenLayers.Layer.Vector("Gravminne", {
>    strategies: [new OpenLayers.Strategy.BBOX()],
>    protocol: new OpenLayers.Protocol.WFS({
>        url: "http://naturkart.no:8080/geoserver/wfs",
>        typeName: "gravminne",
>        featurePrefix: "kulturminner_ns"
>    })
> ));
>
> For the symbology, you can use OpenLayers.Format.SLD to use a sld file
> that you already have on your server. Look at examples/SLD.html to see
> how to configure this.
>
> And you need OpenLayers.ProxyHost configured with a working proxy url.
>
> If a map image rendered on the server would also do, you could just
> use a WMS layer, and don't even need a ProxyHost:
>
> map.addLayer(new OpenLayers.Layer.WMS("Gravminne";
> "http://naturkart.no:8080/geoserver/wms?", {
>    transparent: true,
>    layers: "kulturminner_ns:gravminne"
> }));
> }
>
> > 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.
>
> With the WFS setup above (first of my code snippets), the data should
> be automatically reprojected to the SRS of your map.
>
> > 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.
>
> As already said, OpenLayers can not parse KMZ, only KML. To make
> GeoServer output KML, your request would have to be a WMS request and
> look like this:
>
>
> http://naturkart.no:8080/geoserver/wms/?service=wms&request=GetMap&layers=kulturminner_ns:gravminne&format=application/vnd.google-earth.kml+XML&format=kml&bbox=0,0,180,90&width=500&height=250&srs=EPSG:4326
>
> This is what will get generated with the second of my code snippets above.
>
> Regards,
> Andreas.
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090328/8a6833c6/attachment.html


More information about the Users mailing list