From: Christopher N. <cna...@gm...> - 2010-02-12 15:20:20
|
Thanks for your quick reply Edwin. I successfully set the proxy host using the JSNI code you provided and loaded my WFS layer. I will look at what is in trunk because I would prefer to use the WFS protocol. I don't see any of the OpenLayers Strategies such as Cluster, BBOX, etc, is support planned in the near term for these options? I didn't see it among the tickets in Trac. Regards, Chris On Thu, Feb 11, 2010 at 4:36 PM, Edwin Commandeur < com...@gm...> wrote: > Hi Christopher, > > Without a proxy it is not possible for OpenLayers to do WFS requests, > because of cross-domain restrictions on Javascript. > > Before going into ProxyHost: The recommended way to create a WFS layer > is via WFSProtocol. We are intending to remove the WFS layer > alltogether, as it appears to be the legacy way to talk to a WFS. You > can look at the latest OpenLayers examples > (http://openlayers.org/dev/examples/). For instance: > > http://openlayers.org/dev/examples/wfs-states.js > > For this you need the code that it is in trunk (but see also below about > proxy). > > The easiest way to set the proxyHost is to create a setter for it in JSNI > code: > > public static native void setProxyHost(String host)/*-{ > > $wnd.OpenLayers.ProxyHost = host; > > }-*/; > > and then > > setProxyHost("myhost/here"); > > However, the proxyHost should point at a proxy that is running on the > same domain as the javascript. There is a python proxy included with > the OpenLayers examples. You can try to get that running at the some > domain as the app you are working on. > > Currently, the GWT-OL lacks a java proxy servlet, but that should be > added to trunk soon. I can send you a copy of the new build when that > hits trunk. > > Greetings, > Edwin > > On 11 February 2010 17:55, Christopher Navarro <cna...@gm...> > wrote: > > Hi, > > > > I'm trying to read WFS features from a geoserver using gwt-openlayers and > I > > can't seem to figure out where I am going wrong. > > > > Using straight OpenLayers/Javascript/HTML I have the following, which > works: > > > > // Proxy setup to fix XMLHttpRequest domain matching > > OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url="; > > > > // parameters for getting the WFS layer > > var params = { typename: "marketmaker:business_cu" }; > > var options = {}; > > > > // WFS Layer creation > > var layer = new OpenLayers.Layer.WFS( "WFS", > > "http://mmweb.ncsa.uiuc.edu:8080/geoserver/wfs", > > params, options ); > > > > // add the layer > > map.addLayer( layer ); > > > > My GWT-OpenLayers equivalent is: > > > > // parameters for wfs layer > > WFSParams wfsParams = new WFSParams(); > > wfsParams.getJSObject().setProperty( "typename", > "marketmaker:business_cu" > > ); > > > > // no additional options > > WFSOptions wfsOptions = new WFSOptions(); > > > > // WFS layer creation > > WFS wfsLayer = new WFS( "wfs", WFS_URL, wfsParams, wfsOptions ); > > > > // add the layer > > map.addLayer( wfsLayer ); > > > > Is there some way to inject the value of OpenLayers.ProxyHost using > > GWT-OpenLayers? I'm not sure if that is the issue. I am new to > javascript > > and perhaps this is wrong, but I tried writing the value of > > OpenLayers.ProxyHost directly into the compiled javascript file that GWT > > creates. Any help is appreciated. > > > > Regards, > > Chris > > > > > ------------------------------------------------------------------------------ > > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > > http://p.sf.net/sfu/solaris-dev2dev > > _______________________________________________ > > Gwt-openlayers-users mailing list > > Gwt...@li... > > https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users > > > > > |