[mapserver-users] Creating legend

Subha Ramakrishnan subha at gslab.com
Wed Oct 8 02:38:57 EDT 2008


Fawcett, David wrote:
> Or, just a straight mode=legend request to the CGI if you are using 
> MapServer.  You can pass in your extent, that will manage the 
> scale-dependent layers.
>
Will the map file remain the same for this? I did try using mode=legend 
in my request and added that to a separate DIV.But the request doesn't 
seem to be generating any image.
This is how my map file looks. I've not pasted the entire contents as 
its too big.

 legend
    status on
    imagecolor 255 0 0
    position ul
  end
  layer
    CONNECTIONTYPE postgis
    name india_states
    CONNECTION "user=postgres dbname=ibp host=localhost"
    group world
    type polygon
    dump true
    METADATA
       "wfs_title" "Factbook Metadata"
       "gml_include_items" "all"
       "wms_feature_info_mime_type" "text/html"
    END
    template "template.html"
    projection
      "init=epsg:4326"
    end
    transparency alpha
    status on
    data "topology from india_states using unique id using SRID = -1"
        CLASSITEM "state"
        CLASS
                NAME "JAMMU & KASHMIR"
                EXPRESSION "JAMMU & KASHMIR"
                STYLE
                        COLOR 191 191 155
                        OUTLINECOLOR 000 000 000
                        #antialias true
                end
        end
      CLASS
                NAME "HIMACHAL"
                EXPRESSION "HIMACHAL"
                STYLE
                        COLOR 245 226 188
                        OUTLINECOLOR 000 000 000
                        #antialias true
                end
        end                                   

And this request is like this as per the example i found here 
:http://openlayers.org/pipermail/users/2008-September/007495.html
var legenddiv = document.createElement('div');
legenddiv.setAttribute('id','legend');
legenddiv.innerHTML = '<img src = 
"http://localhost/cgi-bin/mapserv?mode=legend&map='+mapfile+'"</img>';
document.getElementById('map').appendChild(legenddiv);

Thanks & regards,
Subha
         
> David.
>
>     -----Original Message-----
>     *From:* mapserver-users-bounces at lists.osgeo.org
>     [mailto:mapserver-users-bounces at lists.osgeo.org] *On Behalf Of
>     *Roger André
>     *Sent:* Tuesday, October 07, 2008 12:06 PM
>     *To:* Steve Lime
>     *Cc:* mapserver-users at lists.osgeo.org
>     *Subject:* Re: [mapserver-users] Creating legend
>
>     Also, you might want to consider making a separate
>     GetLegendGraphic WMS request and putting the legend in a separate
>     DIV element in your web page. 
>
>     Just an idea.
>     --
>
>     On Tue, Oct 7, 2008 at 8:22 AM, Steve Lime
>     <Steve.Lime at dnr.state.mn.us <mailto:Steve.Lime at dnr.state.mn.us>>
>     wrote:
>
>         Visit:
>
>          http://www.openlayers.org/dev/examples/example-list.html
>
>         and search for untiled. There's a "WMS Untiled" example you
>         can view the source of. The singleTile option goes in the
>         "options" object as opposed the "params" object. Params get
>         passed to the WMS service, options are handled by OL.
>
>         Steve
>
>         >>> Subha Ramakrishnan <subha at gslab.com
>         <mailto:subha at gslab.com>> 10/07/08 9:58 AM >>>
>         Hi Steve,
>         It would be great if you can give me an example or tell me
>         where it is
>         usually set in OL.
>         Thanks for your help.
>
>         Subha
>
>         Steve Lime wrote:
>         > There's nothing you have to do on the MapServer side. Looks
>         like your OL config is wrong
>         > though. I think 'singleTile' is set in the wrong
>         configuration object, perhaps others are in
>         > the wrong place too.
>         >
>         > Steve
>         >
>         >
>         >>>> Subha Ramakrishnan <subha at gslab.com
>         <mailto:subha at gslab.com>> 10/07/08 1:30 AM >>>
>         >>>>
>         > Hi,
>         >
>         > I am using mapserver 5.0.2 with openlayers.
>         > I've a problem while creating a legend for a map from
>         mapserver.When i
>         > try to overlay the image from the mapserver on openlayers'
>         base map, the
>         > images are rendered in tiles, and every tile has a legend
>         and is limited
>         > by the size of the tile. So, i see lots of legends on the
>         map and only
>         > half of them are visible as it is restricted by the tile size.
>         >
>         > This is my request to mapserver from openlayers
>         >
>         > var mapfile = layer_tablename+'.map';
>         > twms1 = new OpenLayers.Layer.WMS(
>         > layer_tablename,"http://localhost/cgi-bin/mapserv?",
>         > { map: mapfile,
>         >    transparent: 'true', layers:layer_tablename,
>         >    format: 'image/png',
>         >    projection:"EPSG:4326",reproject:false,
>         >    units: "m",
>         >    singleTile: true
>         > },{numZoomLevels : MaxZoomLevel});
>         > map.addLayer(twms1);
>         >
>         > I am using the option of singleTile. Is there any setting to
>         be done in
>         > the map file or mapserver for it render a single tile/single
>         legend per
>         > image?
>         >
>         > Thank you.
>         >
>         > Regards,
>         > Subha
>         >
>         > _______________________________________________
>         > mapserver-users mailing list
>         > mapserver-users at lists.osgeo.org
>         <mailto:mapserver-users at lists.osgeo.org>
>         > http://lists.osgeo.org/mailman/listinfo/mapserver-users
>         >
>         >
>         >
>
>
>         _______________________________________________
>         mapserver-users mailing list
>         mapserver-users at lists.osgeo.org
>         <mailto:mapserver-users at lists.osgeo.org>
>         http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
>
> -- 
> This message has been scanned for viruses and
> dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is
> believed to be clean.
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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