I want to change layers visibility while I zoom , here are my screenshots.
where is my error ?
geoserverlayersopenlayerszoom
I want to change layers visibility while I zoom , here are my screenshots.
where is my error ?
When setting up your labels, you'll need to define new label classes, then set up the labels appropriately for each class. Go to the layer properties, then click the Labels tab. Under Method, select this:
Then Add
a new class, specify the appropriate Scale Range
and Label Field
- then just rinse and repeat for as many scale-specific labels as you need.
This is saved in the MXD and not in your data source. I'm not sure if it will make the transition to ArcGIS Online, as I don't have much experience with that.
edit: @chris-w is correct in his comment and answer. If you want different labels to remain the same size as you zoom in and out, you will have to convert the label to annotation.
Because the only attribute in the selected data is count you can't make different colors with one SLD by using filter. I believe that the only alternative is then to have two basic styles which use different default styles. You can configure named styles on server side and select them with WMS url as &Sex=Male&styles=male
. Or you can add the whole SDL into GetMap request.
Here are two fast ugly examples which should work for you if you have local GeoServer running on localhost:8080 with topp:states demo layer installed. Green output:
http://localhost:8080/geoserver/wms?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&TILED=TRUE&TRANSPARENT=TRUE&WIDTH=256&HEIGHT=256&FORMAT=image/jpeg&LAYERS=topp:states&SRS=EPSG:4326&bbox=-79.828125,36.50857729743935,-73.125,42.032974332441405&SLD_BODY=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%3Csld%3AStyledLayerDescriptor%20xmlns%3Asld%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22%20xmlns%3Ajava%3D%22java%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20xmlns%3Awfs%3D%22http%3A%2F%2Fwww.opengis.net%2Fwfs%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3Axslutil%3D%22de.latlon.deejump.plugin.style.XSLUtility%22%20xmlns%3Adeegreewfs%3D%22http%3A%2F%2Fwww.deegree.org%2Fwfs%22%20xmlns%3Afo%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2FXSL%2FFormat%22%20xmlns%3Agml%3D%22http%3A%2F%2Fwww.opengis.net%2Fgml%22%20xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22%20xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%20http%3A%2F%2Fschemas.opengis.net%2Fsld%2F1.0.0%2FStyledLayerDescriptor.xsd%22%20version%3D%221.0.0%22%3E%0A%3Csld%3ANamedLayer%3E%0A%3Csld%3AName%3Etopp%3Astates%3C%2Fsld%3AName%3E%0A%3Csld%3AUserStyle%3E%0A%3Csld%3AName%3Estates%3C%2Fsld%3AName%3E%0A%3Csld%3ATitle%3Estates%3C%2Fsld%3ATitle%3E%0A%3Csld%3AIsDefault%3E1%3C%2Fsld%3AIsDefault%3E%0A%3Csld%3AFeatureTypeStyle%3E%0A%3Csld%3AName%3Estates%3C%2Fsld%3AName%3E%0A%3Csld%3ARule%3E%3Csld%3AName%3EbasicPolyStyle%3C%2Fsld%3AName%3E%0A%3Csld%3AMinScaleDenominator%3E0.0%3C%2Fsld%3AMinScaleDenominator%3E%0A%3Csld%3AMaxScaleDenominator%3E4.724409448771654E14%3C%2Fsld%3AMaxScaleDenominator%3E%0A%3Csld%3APolygonSymbolizer%3E%0A%3Csld%3AGeometry%3E%0A%3Cogc%3APropertyName%3Ethe_geom%3C%2Fogc%3APropertyName%3E%0A%3C%2Fsld%3AGeometry%3E%0A%3Csld%3AFill%3E%0A%3Csld%3ACssParameter%20name%3D%22fill%22%3E%2300b400%3C%2Fsld%3ACssParameter%3E%0A%3Csld%3ACssParameter%20name%3D%22fill-opacity%22%3E0.588%3C%2Fsld%3ACssParameter%3E%0A%3C%2Fsld%3AFill%3E%0A%3Csld%3AStroke%3E%0A%3Csld%3ACssParameter%20name%3D%22stroke%22%3E%23007d00%3C%2Fsld%3ACssParameter%3E%0A%3Csld%3ACssParameter%20name%3D%22stroke-opacity%22%3E0.588%3C%2Fsld%3ACssParameter%3E%0A%3Csld%3ACssParameter%20name%3D%22stroke-width%22%3E1%3C%2Fsld%3ACssParameter%3E%0A%3C%2Fsld%3AStroke%3E%3C%2Fsld%3APolygonSymbolizer%3E%3C%2Fsld%3ARule%3E%0A%3C%2Fsld%3AFeatureTypeStyle%3E%0A%3C%2Fsld%3AUserStyle%3E%0A%3C%2Fsld%3ANamedLayer%3E%0A%3C%2Fsld%3AStyledLayerDescriptor%3E
Pink output:
http://localhost:8080/geoserver/wms?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&TILED=TRUE&TRANSPARENT=TRUE&WIDTH=256&HEIGHT=256&FORMAT=image/jpeg&LAYERS=topp:states&SRS=EPSG:4326&bbox=-79.828125,36.50857729743935,-73.125,42.032974332441405&SLD_BODY=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%3Csld%3AStyledLayerDescriptor%20xmlns%3Asld%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22%20xmlns%3Ajava%3D%22java%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20xmlns%3Awfs%3D%22http%3A%2F%2Fwww.opengis.net%2Fwfs%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3Axslutil%3D%22de.latlon.deejump.plugin.style.XSLUtility%22%20xmlns%3Adeegreewfs%3D%22http%3A%2F%2Fwww.deegree.org%2Fwfs%22%20xmlns%3Afo%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2FXSL%2FFormat%22%20xmlns%3Agml%3D%22http%3A%2F%2Fwww.opengis.net%2Fgml%22%20xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22%20xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%20http%3A%2F%2Fschemas.opengis.net%2Fsld%2F1.0.0%2FStyledLayerDescriptor.xsd%22%20version%3D%221.0.0%22%3E%0A%3Csld%3ANamedLayer%3E%0A%3Csld%3AName%3Etopp%3Astates%3C%2Fsld%3AName%3E%0A%3Csld%3AUserStyle%3E%0A%3Csld%3AName%3Estates%3C%2Fsld%3AName%3E%0A%3Csld%3ATitle%3Estates%3C%2Fsld%3ATitle%3E%0A%3Csld%3AIsDefault%3E1%3C%2Fsld%3AIsDefault%3E%0A%3Csld%3AFeatureTypeStyle%3E%0A%3Csld%3AName%3Estates%3C%2Fsld%3AName%3E%0A%3Csld%3ARule%3E%3Csld%3AName%3EbasicPolyStyle%3C%2Fsld%3AName%3E%0A%3Csld%3AMinScaleDenominator%3E0.0%3C%2Fsld%3AMinScaleDenominator%3E%0A%3Csld%3AMaxScaleDenominator%3E4.724409448771654E14%3C%2Fsld%3AMaxScaleDenominator%3E%0A%3Csld%3APolygonSymbolizer%3E%0A%3Csld%3AGeometry%3E%0A%3Cogc%3APropertyName%3Ethe_geom%3C%2Fogc%3APropertyName%3E%0A%3C%2Fsld%3AGeometry%3E%0A%3Csld%3AFill%3E%0A%3Csld%3ACssParameter%20name%3D%22fill%22%3E%23FF0066%3C%2Fsld%3ACssParameter%3E%0A%3Csld%3ACssParameter%20name%3D%22fill-opacity%22%3E0.588%3C%2Fsld%3ACssParameter%3E%0A%3C%2Fsld%3AFill%3E%0A%3Csld%3AStroke%3E%0A%3Csld%3ACssParameter%20name%3D%22stroke%22%3E%23007d00%3C%2Fsld%3ACssParameter%3E%0A%3Csld%3ACssParameter%20name%3D%22stroke-opacity%22%3E0.588%3C%2Fsld%3ACssParameter%3E%0A%3Csld%3ACssParameter%20name%3D%22stroke-width%22%3E1%3C%2Fsld%3ACssParameter%3E%0A%3C%2Fsld%3AStroke%3E%3C%2Fsld%3APolygonSymbolizer%3E%3C%2Fsld%3ARule%3E%0A%3C%2Fsld%3AFeatureTypeStyle%3E%0A%3C%2Fsld%3AUserStyle%3E%0A%3C%2Fsld%3ANamedLayer%3E%0A%3C%2Fsld%3AStyledLayerDescriptor%3E
One of SLD files without URL-encoding - Yes, it is rather long and only one parameter is changing <sld:CssParameter name="fill">#00b400</sld:CssParameter>
<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns:sld="http://www.opengis.net/sld" xmlns:java="java" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xslutil="de.latlon.deejump.plugin.style.XSLUtility" xmlns:deegreewfs="http://www.deegree.org/wfs" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns="http://www.opengis.net/sld" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd" version="1.0.0">
<sld:NamedLayer>
<sld:Name>topp:states</sld:Name>
<sld:UserStyle>
<sld:Name>states</sld:Name>
<sld:Title>states</sld:Title>
<sld:IsDefault>1</sld:IsDefault>
<sld:FeatureTypeStyle>
<sld:Name>states</sld:Name>
<sld:Rule><sld:Name>basicPolyStyle</sld:Name>
<sld:MinScaleDenominator>0.0</sld:MinScaleDenominator>
<sld:MaxScaleDenominator>4.724409448771654E14</sld:MaxScaleDenominator>
<sld:PolygonSymbolizer>
<sld:Geometry>
<ogc:PropertyName>the_geom</ogc:PropertyName>
</sld:Geometry>
<sld:Fill>
<sld:CssParameter name="fill">#00b400</sld:CssParameter>
<sld:CssParameter name="fill-opacity">0.588</sld:CssParameter>
</sld:Fill>
<sld:Stroke>
<sld:CssParameter name="stroke">#007d00</sld:CssParameter>
<sld:CssParameter name="stroke-opacity">0.588</sld:CssParameter>
<sld:CssParameter name="stroke-width">1</sld:CssParameter>
</sld:Stroke></sld:PolygonSymbolizer></sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
</sld:NamedLayer>
</sld:StyledLayerDescriptor>
Best Answer
You appear to be trying to turn off/on Layer Visibility in GeoWebCache which is integrated with GeoWebServer. Geowebcache is used for caching tiles to improve speed, not controlling layer visibility
There are two ways to handle layer visibility
Style the Layer using SLD in GEoserver, using
<MinScaleDenominator></MinScaleDenominator>
and<MaxScaleDenominator></MaxScaleDenominator>
to control the display of featuresUse the OpenLayers setVisibility() function to turn he layers off.