[mapserver-users] html legend not working

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Mon Aug 3 06:55:47 PDT 2015


Hi,


I am not sure if HTML legends really work with WMS. The demo site that is mentioned in the html legend manual page must support html legends.
http://demo.mapserver.org/cgi-bin/mapserv?map=%2Fosgeo%2Fmapserver%2Fitasca_legend%2Fmap%2Fitasca1.map&layers=all&zoomsize=2&zoomdir=1&map_size=600+400

However, I could not find any way for reading the html legend through WMS. Format image/png does work for me
http://demo.mapserver.org/cgi-bin/mapserv?map=%2Fosgeo%2Fmapserver%2Fitasca_legend%2Fmap%2Fitasca1.map&service=wms&version=1.1.1&request=getlegendgraphic&layer=ctyrdln3&format=image/png

The site is advertising these formats for GetLegendGraphic, notice that html does not appear on the list even the service itself does support html legends if  they are read with native Mapserver methods:

<GetLegendGraphic>
      <Format>image/gif</Format>
      <Format>image/png</Format>
      <Format>image/png; mode=24bit</Format>
      <Format>image/jpeg</Format>
      <Format>image/vnd.wap.wbmp</Format>

I also tested the effect of adding this WEB object metadata item into some of our Mapserver 7.0 RC1 services:
"wms_getlegendgraphic_formatlist" "text/html"

This change does not have any effect on the advertised GetLegendGraphic formats of our server. They are always

<Format>image/png</Format>
<Format>image/jpeg</Format>
<Format>image/gif</Format>
<Format>image/png; mode=8bit</Format>

However, if I use "wms_getlegendgraphic_formatlist" "image/jpeg" then I can't read the legend as image/png even it does still show in GetCapabilities. So this setting works with the image formats as described in the documentation but there is a bug because the setting does not reflect to GetCapabilities.

When it comes to top posting, I always top post but I also try to include some useful information into my mails for compensating the irritation. And I know that bottom posting is irritating at least as many people as top posting. I apologize also that my mail program does poor job with quoting previous mails. 

Regards,

-Jukka Rahkonen-

Raffaele Morelli wrote:


On 03/08/15 at 12:26pm, Rahkonen Jukka (MML) wrote:
> Hi,
> 
> By a quick look at http://mapserver.org/ogc/wms_server.html you should probably add text/html as a GetLegendGraphic format:
> wms_getlegendgraphic_formatlist
> 
>     Description: (Optional) A comma-separated list of valid formats for a WMS GetLegendGraphic request.
> 
> and then use &format=text/html in your request. However, I have not tried that myself but this is just my best guess.
> 
> -Jukka Rahkonen-
> 
> Raffaele Morelli wrote:
> 
> > Short story: I can't get html legend to work...
> 
> > legend.html file is in the same directory of the mapfile, as you can see the LABEL block is a verbatim copy from Mapserver documentation.
> 
> > The INCLUDE layer is a point layer with CLASS correctly defined.
> 
> > This my request to test
> http://localhost/cgi-bin/mapserv?MAP=/home/www/geomoose-2.8.0/maps/cen_default//cen_default.map&FORMAT=image/png&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&_OLSALT=0.9622128666378558&SRS=EPSG:3857&SCALE=6933486.650500195&WIDTH=250&STYLE=&LAYER=sostegni
> 
> The legend is returned a png file, just like TEMPLATE statement wasn't taken into account.
> 
> 
> Any hint?
> 

Added, but it doesn't work.
I got this error:

msWMSGetLegendGraphic(): Image handling error. Unsupported output format (text/html).



PS please do not top post


-- 
<My mama said to get things done
You'd better not mess with Major Tom>



More information about the MapServer-users mailing list