[mapserver-users] html legend not working

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Mon Aug 3 05:26:03 PDT 2015


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?

Mapfile:

MAP
    NAME 'XXX'
    UNITS meters
    EXTENT  728034.319166294 4193385.80350739 2183515.00526018 5960168.11180283 

    CONFIG 'MS_ERRORFILE' '/var/log/ms_error.log'
    DEBUG 1
    SIZE 800 600

    SYMBOLSET "/home/www/geomoose-2.8.0/maps/symbols/symbols-catasto.sym"
    FONTSET "/home/www/geomoose-2.8.0/maps/fonts/msfontset.txt"
    RESOLUTION 72

    PROJECTION
        #"init=epsg:32632"
        #"init=epsg:4326"
        "init=epsg:3857"
        #"init=epsg:900913"
    END

    OUTPUTFORMAT
      NAME "png"
      DRIVER AGG/PNG
      MIMETYPE "image/png"
      IMAGEMODE RGB
      EXTENSION "png"
      FORMATOPTION "GAMMA=0.75"
    END
    OUTPUTFORMAT
      NAME "gif"
      DRIVER GD/GIF
      MIMETYPE "image/gif"
      IMAGEMODE PC256
      EXTENSION "gif"
    END
    OUTPUTFORMAT
      NAME "png8"
      DRIVER AGG/PNG8
      MIMETYPE "image/png; mode=8bit"
      IMAGEMODE RGB
      EXTENSION "png"
      FORMATOPTION "QUANTIZE_FORCE=on"
      FORMATOPTION "QUANTIZE_COLORS=256"
      FORMATOPTION "GAMMA=0.75"
    END
    OUTPUTFORMAT
      NAME "jpeg"
      DRIVER AGG/JPEG
      MIMETYPE "image/jpeg"
      IMAGEMODE RGB
      EXTENSION "jpg"
      FORMATOPTION "GAMMA=0.75"
    END
    OUTPUTFORMAT
      NAME "svg"
      DRIVER CAIRO/SVG
      MIMETYPE "image/svg+xml"
      IMAGEMODE RGB
      EXTENSION "svg"
    END
    OUTPUTFORMAT
      NAME "pdf"
      DRIVER CAIRO/PDF
      MIMETYPE "application/x-pdf"
      IMAGEMODE RGB
      EXTENSION "pdf"
    END
    OUTPUTFORMAT
      NAME "GTiff"
      DRIVER GDAL/GTiff
      MIMETYPE "image/tiff"
      IMAGEMODE RGB
      EXTENSION "tif"
    END
    OUTPUTFORMAT
      NAME "kml"
      DRIVER KML
      MIMETYPE "application/vnd.google-earth.kml.xml"
      IMAGEMODE RGB
      EXTENSION "kml"
    END
    OUTPUTFORMAT
      NAME "kmz"
      DRIVER KMZ
      MIMETYPE "application/vnd.google-earth.kmz"
      IMAGEMODE RGB
      EXTENSION "kmz"
    END
    OUTPUTFORMAT
      NAME "cairopng"
      DRIVER CAIRO/PNG
      MIMETYPE "image/png"
      IMAGEMODE RGB
      EXTENSION "png"
    END

    WEB
        IMAGEPATH "/home/www/tmp/"
        IMAGEURL "/ms_tmp/"

        METADATA
            "wms_title"                 "CEN"
            "wms_onlineresource"        "http://localhost/cgi-bin/cen?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities"
            "wms_enable_request"        "*"
            "wms_srs"                   "EPSG:32632 EPSG:4326 EPSG:900913 EPSG:3857"
        END  # Metadata
    END  # Web

    LEGEND
      STATUS ON
      KEYSIZE 18 12
      # LABEL object
      LABEL
        TYPE BITMAP
        SIZE MEDIUM
        COLOR 0 0 89
      END
      TEMPLATE "legend.html"  ### HTML template file
    END

    INCLUDE 'sostegni_italia.map'
END


--
<My mama said to get things done
You'd better not mess with Major Tom>
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the MapServer-users mailing list