[OpenLayers-Users] Problems displaying kmz file in OpenLayers

Christopher Schmidt crschmidt at metacarta.com
Mon Mar 30 14:51:28 EDT 2009


On Mon, Mar 30, 2009 at 04:47:42PM +0200, Asle Benoni wrote:
> Thanks. I still get in FireBug:
> 
> OpenLayers.Protocol.WFS is not a constructor
> init()openlayers3.html (line 83)
> onload(load )7tnQksP2...GPg%3D%3D (line 2)
> featureNS: "kulturminner_ns", })

Protocol.WFS is new in trunk, and not included in OpenLayers 2.7. 

> 
> In the demo page og GeoServer I see the layer as
> "*kulturminner_ns:gravminne<http://naturkart.no:8080/geoserver/wms?bbox=582633.35,6523100.745,673298.65,6636394.255&styles=&Format=application/openlayers&request=GetMap&version=1.1.1&layers=kulturminner_ns:gravminne&width=490&height=550&srs=EPSG:32632>
> "* so am I writing this correctly?
> 
>        map.addLayer(new OpenLayers.Layer.Vector("Gravminne", {
>             strategies: [new OpenLayers.Strategy.BBOX()],
>             projection: new OpenLayers.Projection("EPSG:4326"),
>             protocol: new OpenLayers.Protocol.WFS({
>             srsName: "EPSG:4326",
>             url: "http://naturkart.no:8080/geoserver/wfs&request=getmap",
>             featureType: "gravminne",
>             featureNS: "kulturminner_ns",   })
>                    }
>                ));
> 
> 
> 2009/3/29 Ingo Weinzierl <ingo.weinzierl at intevation.de>
> 
> > Hello Asle,
> >
> > I don't know if this could solve your problem, but I am using a vector
> > layer as well.
> > Defining the WFS protocol looks a bit different from yours:
> >
> >     wfs = new OpenLayers.Layer.Vector(
> >         "Name of the Layer",
> >         {
> >             strategies: [new OpenLayers.Strategy.BBOX()],
> >             projection: new OpenLayers.Projection("EPSG:4326"),
> >             protocol: new OpenLayers.Protocol.WFS({
> >                 srsName: "EPSG:4326",
> >                 url: "http://localhost:8080/geoserver/wfs",
> >                 featureType: "rohre_graben_damm",
> >                 featureNS: "http://www.openplans.org/topp",
> >             })
> >         }
> >     );
> >
> > I hope this can help you.
> >
> > Regards,
> > Ingo
> >
> > Am 29.03.2009 um 03:28 schrieb Asle Benoni:
> >
> > I changed the URL but still get this response:
> >
> > *OpenLayers.Protocol.WFS is not a constructor
> > *
> >  map.addLayer(new OpenLayers.Layer.Vector("Gravminne", {
> >    strategies: [new OpenLayers.Strategy.BBOX()],
> >    protocol: new OpenLayers.Protocol.WFS({
> >        url: "http://naturkart.no:8080/geoserver/wfs&request=getmap",
> >        typeName: "gravminne",
> >        featurePrefix: "kulturminner_ns"
> >    })
> >    }));
> >
> > /asle
> >
> > 2009/3/28 Andreas Hocevar <ahocevar at opengeo.org>
> >
> >> add &request=getmap to your url.
> >>
> >> Regards,
> >> andreas.
> >>
> >> On 3/28/09, Asle Benoni <asle.benoni at gmail.com> wrote:
> >> > 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.
> >> >>
> >> >
> >>
> >> --
> >> Sent from my mobile device
> >>
> >> Andreas Hocevar
> >> OpenGeo - http://opengeo.org/
> >> Expert service straight from the developers.
> >>
> >
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
> >
> >

> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list