4

I am using geoserver 2.5.5. I have to get the legends of each category from different link. Now geoserver gives whole legend as a PNG image format using this link http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=topp:states

enter image description here

I need to have a link which gives each category of legend as a separate image like I need only <2M category in one link like this

enter image description here

  • Why not just use the SCALE option to select the scale(s) you want? – BradHards Sep 7 '15 at 7:35
5

You can specify the optional RULE parameter in your request to specify the rule you want the legend for (see documentation)

You must have a Rule with a Name set, so if you modify the default population style:

 <Rule>
      <Name>top</Name>
      <Title>&gt; 4M</Title>

      <!-- like a linesymbolizer but with a fill too -->

You can make a request like:

http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=topp:states&RULE=top 
  • Yes, but I am not clear about how to use RULE parameter exactly. At least I need one sample link which include RULE parameter. – Vikneswaran S J Sep 7 '15 at 8:56
  • So this Rule should be wriiten inside the sld file for styling or where? and how you relate the rule top with > 4M in legend. – Vikneswaran S J Sep 7 '15 at 13:59
  • Each rule can have a name (see my SLD example) and you can refer to it by that name in the GetLegend Request – Ian Turton Sep 7 '15 at 14:02
  • Thank you for your help. can you please give me some link that has complete example of using rule. I am new to this and I can't understand it clearly. – Vikneswaran S J Sep 7 '15 at 14:41
  • Do you have some SLD? if so please paste it into the question – Ian Turton Sep 7 '15 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.