Leaflet.js: Wms Layer Styles
Solution 1:
I must say I'm a bit confused. WMS is a service to get raster images from the server. You don't get geometries or attributes from WMS.
Since WMS gives raster images, you can't style it with Javascript. So you can't just set weight, fill color, etc. from the Javascript, since the data has already been rendered on the server when the Javascript sees it.
However, you can set the styles
parameter in the WMS request, which instructs the WMS server (GeoServer in your case) to apply a certain style to the returned images; see the GetMap reference: http://docs.geoserver.org/stable/en/user/services/wms/reference.html#getmap.
If you really want to control styling on the client, you should probably use WFS instead, which will give you the geometries in vector format, and the attributes. GeoServer can return them in GeoJSON format, which makes it easy to work with them in Leaflet. There's at least one plugin you could use for this: https://github.com/azgs/azgs-leaflet (I have not used it myself).
Post a Comment for "Leaflet.js: Wms Layer Styles"