[Geoserver-users] dynamic SLD with openlayers

Hi,

i would like to change dynamically the style of a layer with the command :

--
var tiled = new OpenLayers.Layer.WMS
("state","http://localhost:8080/geoserver/wms",\{\.\.\.\.\.\.\}\)
tiled.mergeNewParams({SLD :'http://localhost/mapping/styleSLD.xml’});
--

but it doesn' work, the layer still display with the SLD i fixed in
geoserver/entity configuration..
Does the geoserver SLD interfer and take priority to the one i put in my
openlayers ?
how can i use the command uppon to change the SLD in my webapp ?

thks for all

Flo
--
View this message in context: http://www.nabble.com/dynamic-SLD-with-openlayers-tp21367731p21367731.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

floflo schrieb:

Hi,

i would like to change dynamically the style of a layer with the command :

--
var tiled = new OpenLayers.Layer.WMS
("state","http://localhost:8080/geoserver/wms",\{\.\.\.\.\.\.\}\)
tiled.mergeNewParams({SLD :'http://localhost/mapping/styleSLD.xml’});
--

but it doesn' work, the layer still display with the SLD i fixed in
geoserver/entity configuration..
Does the geoserver SLD interfer and take priority to the one i put in my
openlayers ?
how can i use the command uppon to change the SLD in my webapp ?

thks for all

Flo
  

Flo,
are you sure, OL changed the getMap request? If so, you probably have caching and/or map refreshing problems.

Regards, Till

--
----------------------------------------------------------
terrestris GmbH & Co. KG
Irmintrudisstrasse 17
53111 Bonn
Germany

Till Adams
Geschäftsführung

Tel: +49 (0)228 / 962 899-52
Fax: +49 (0)228 / 962 899-57
adams@anonymised.com http://www.terrestris.de
Amtsgericht Bonn, HRA 6835
---------------------------------------------------------

Komplementärin:

terrestris Verwaltungs GmbH

vertreten durch:
Hinrich Paulsen, Till Adams

Hi,

you could try tiled.redraw(true) after merge.

- mika -

floflo kirjoitti:

Hi,

i would like to change dynamically the style of a layer with the command :

--
var tiled = new OpenLayers.Layer.WMS
("state","http://localhost:8080/geoserver/wms",\{\.\.\.\.\.\.\}\)
tiled.mergeNewParams({SLD :'http://localhost/mapping/styleSLD.xml’});
--

but it doesn' work, the layer still display with the SLD i fixed in
geoserver/entity configuration..
Does the geoserver SLD interfer and take priority to the one i put in my
openlayers ?
how can i use the command uppon to change the SLD in my webapp ?

thks for all

Flo
  

Lehtonen, Mika wrote:

you could try tiled.redraw(true) after merge.
  
No, mergeNewParams() will redraw the layer properly.

floflo kirjoitti:
  

Hi,

i would like to change dynamically the style of a layer with the command :

--
var tiled = new OpenLayers.Layer.WMS
("state","http://localhost:8080/geoserver/wms",\{\.\.\.\.\.\.\}\)
tiled.mergeNewParams({SLD :'http://localhost/mapping/styleSLD.xml’});
--

but it doesn' work, the layer still display with the SLD i fixed in
geoserver/entity configuration..
Does the geoserver SLD interfer and take priority to the one i put in my
openlayers ?
how can i use the command uppon to change the SLD in my webapp ?
    
Make sure that you don't have a STYLES param in your WMS request. So in
your above snippet, in the {......} part, there should not be a STYLES
key in it. If it is, you have to say

mergeNewParams({SLD: "your_sld_uri", STYLES: null).

Regards,
Andreas.

ok thks but it keeps not working on my server...

it works on my local machine with geoserver 1.7.0 (windows) but not on my
server with 1.7.1 on linux..

from my windows local machine, i call this a page which load :
- wms from localhost (geoserver 1.7.0)
- SLD from remote server
it works (SLD process works on my windows machine, even with remote SLD)
it loads the map with the new SLD

tiled = new OpenLayers.Layer.WMS(
                    "communes", "http://localhost:8080/geoserver/wms",
                    {
                        layers: 'bl:communes',
                        syle:'',
      SLD: 'http://172.31.172.244/myStyle.xml
or SLD: 'http://localhost/myStyle.xml
       },
                   {buffer: 0}

but if i load
- wms from remote server
- SLD from remote server
it doesn't work..
it loads the map with the SLD put in geoserver and noway to change it

tiled = new OpenLayers.Layer.WMS(
                    "communes", "http://172.31.172.244:8080/geoserver/wms",
                    {
                        layers: 'bl:communes',
                        syle:'',
      SLD: 'http://172.31.172.244/myStyle.xml
       },
                   {buffer: 0}

if i call the same page from the server machine, replacing 172.31.172.244 by
localhost, it keeps not working...
any one have an idea ?
seems that my version of geoserver on my remote server (1.7.1) doesn't work
fine or maybe i have to change a parameter in the config ?

ty

Make sure that you don't have a STYLES param in your WMS request. So in
your above snippet, in the {......} part, there should not be a STYLES
key in it. If it is, you have to say

mergeNewParams({SLD: "your_sld_uri", STYLES: null).

--
View this message in context: http://www.nabble.com/dynamic-SLD-with-openlayers-tp21367731p21427113.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

floflo ha scritto:

ok thks but it keeps not working on my server...

it works on my local machine with geoserver 1.7.0 (windows) but not on my
server with 1.7.1 on linux..

from my windows local machine, i call this a page which load :
- wms from localhost (geoserver 1.7.0)
- SLD from remote server
it works (SLD process works on my windows machine, even with remote SLD)
it loads the map with the new SLD

tiled = new OpenLayers.Layer.WMS(
                    "communes", "http://localhost:8080/geoserver/wms",
                    {
                        layers: 'bl:communes',
                        syle:'',
      SLD: 'http://172.31.172.244/myStyle.xml
or SLD: 'http://localhost/myStyle.xml
       },
                   {buffer: 0}

but if i load
- wms from remote server
- SLD from remote server
it doesn't work..
it loads the map with the SLD put in geoserver and noway to change it

tiled = new OpenLayers.Layer.WMS(
                    "communes", "http://172.31.172.244:8080/geoserver/wms",
                    {
                        layers: 'bl:communes',
                        syle:'',
      SLD: 'http://172.31.172.244/myStyle.xml
       },
                   {buffer: 0}

if i call the same page from the server machine, replacing 172.31.172.244 by
localhost, it keeps not working...
any one have an idea ? seems that my version of geoserver on my remote server (1.7.1) doesn't work
fine or maybe i have to change a parameter in the config ?

If it works on yours but not on the server, it may be a case of
the server not being able to reach its own public IP?

It happens for example with my home connection, other people can
reach me thru my public IP, but I cannot connect to it from
within my local network (the ISP is blocking such access).

If that's the case, have you tried changing the SLD param
on your server to
SLD: 'http://localhost/myStyle.xml
or
SLD: 'http://127.0.0.1/myStyle.xml

and oh, this seems to assume you have Apache running as well
(no 8080 port on the sld address).

I've also tried have one of our servers on Linux render
topp:states with a style coming from a remote server
(style attached) and it worked fine. The request looked
like:

http://sigma.openplans.org:8080/geoserver/wms?WIDTH=800&SRS=EPSG%3A4326&LAYERS=topp%3Astates&HEIGHT=400&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=-137.18031789177215,17.31338778227679,-55.742520075472584,58.03228669042659&SLD=http://host:port/path/to/polygonstates.sld

(just fix the location of the sld, the rest is pointing
to a real 1.7.1 instance).

I'm also wondering what kind of &sld behaviour you are
looking for. There are three:
- you specify the sld, and not specify either layer nor
   styles. In this case the sld is assumed to contain
   a full definition of layers and styles, each NamedLayer
   is processed in order, the name of the layer is the
   name of one featureType/coverage in GeoServer, the
   UserStyle its style
- you specify the sld and the layer names. This is
   library mode, the sld must contain a UserLayer whose
   name matches the specified layer, its style will
   be used (and so on for each layer you specified
- you specify the sld, layers and styles. In this
   case it works as above, but once it located the
   NamedLayer corresponding to the current layer, it
   chooses the UserStyle whose name matches the
   style specified in &styles (as you can have many
   of them inside each NamedLayer)

This should not really affect your case thought, the
above behaviour has been around for a full year already
(so 1.7.0 should behave the same way).

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

polygonstates.sld (1.09 KB)

Is it possible to plug GeoServer with another map server ? For example, instead of overlaying two WMS with openLayers, could I not just connect GeoServer to the google map server or to another GeoServer WMS ?

Thanks and best regards,
GT

TASSE Gilles ha scritto:

Is it possible to plug GeoServer with another map server ? For
example, instead of overlaying two WMS with openLayers, could I not
just connect GeoServer to the google map server or to another
GeoServer WMS ?

Connecting GeoServer to Google servers is a direct violation
of their license. Only javascript code running inside a browser
can connect to their server and get tiles out of it.

As for the second, that is called WMS cascading, and we do not support
it because we basically don't have a way to represent, in our
configuration, a layer that is not a vector data source, nor
a georeferenced coverage. Some configuration changes are needed.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.