<div dir="ltr">Hi Subha,<br><br>I think for the &quot;mode=legend&quot; to work, you need to change the LAYER status to DEFAULT.&nbsp; However, you can test the legend function via WMS request without changing the status by using a request similar to this: (linebreaks added for clarity)<br>
<br><a href="http://localhost/cgi-bin/mapserv?map=/var/www/mapfiles/states/states.map">http://localhost/cgi-bin/mapserv?map=/var/www/mapfiles/states/states.map</a><br>&amp;service=wms<br>&amp;version=%221.1.1%22<br>&amp;request=GetLegendGraphic<br>
&amp;layer=countries<br>&amp;styles=<br>&amp;width=60<br>&amp;height=40<br>&amp;format=png<br><br>Roger<br>--<br><br><div class="gmail_quote">On Tue, Oct 7, 2008 at 11:38 PM, Subha Ramakrishnan <span dir="ltr">&lt;<a href="mailto:subha@gslab.com">subha@gslab.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Fawcett, David wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Or, just a straight mode=legend request to the CGI if you are using MapServer. &nbsp;You can pass in your extent, that will manage the scale-dependent layers.<br>
<br>
</blockquote>
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&#39;t seem to be generating any image.<br>
This is how my map file looks. I&#39;ve not pasted the entire contents as its too big.<br>
<br>
legend<br>
 &nbsp; status on<br>
 &nbsp; imagecolor 255 0 0<br>
 &nbsp; position ul<br>
&nbsp;end<br>
&nbsp;layer<br>
 &nbsp; CONNECTIONTYPE postgis<br>
 &nbsp; name india_states<br>
 &nbsp; CONNECTION &quot;user=postgres dbname=ibp host=localhost&quot;<br>
 &nbsp; group world<br>
 &nbsp; type polygon<br>
 &nbsp; dump true<br>
 &nbsp; METADATA<br>
 &nbsp; &nbsp; &nbsp;&quot;wfs_title&quot; &quot;Factbook Metadata&quot;<br>
 &nbsp; &nbsp; &nbsp;&quot;gml_include_items&quot; &quot;all&quot;<br>
 &nbsp; &nbsp; &nbsp;&quot;wms_feature_info_mime_type&quot; &quot;text/html&quot;<br>
 &nbsp; END<br>
 &nbsp; template &quot;template.html&quot;<br>
 &nbsp; projection<br>
 &nbsp; &nbsp; &quot;init=epsg:4326&quot;<br>
 &nbsp; end<br>
 &nbsp; transparency alpha<br>
 &nbsp; status on<br>
 &nbsp; data &quot;topology from india_states using unique id using SRID = -1&quot;<br>
 &nbsp; &nbsp; &nbsp; CLASSITEM &quot;state&quot;<br>
 &nbsp; &nbsp; &nbsp; CLASS<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NAME &quot;JAMMU &amp; KASHMIR&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EXPRESSION &quot;JAMMU &amp; KASHMIR&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; STYLE<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; COLOR 191 191 155<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OUTLINECOLOR 000 000 000<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #antialias true<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>
 &nbsp; &nbsp; &nbsp; end<br>
 &nbsp; &nbsp; CLASS<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NAME &quot;HIMACHAL&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EXPRESSION &quot;HIMACHAL&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; STYLE<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; COLOR 245 226 188<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OUTLINECOLOR 000 000 000<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #antialias true<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>
 &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>
And this request is like this as per the example i found here :<a href="http://openlayers.org/pipermail/users/2008-September/007495.html" target="_blank">http://openlayers.org/pipermail/users/2008-September/007495.html</a><br>

var legenddiv = document.createElement(&#39;div&#39;);<br>
legenddiv.setAttribute(&#39;id&#39;,&#39;legend&#39;);<br>
legenddiv.innerHTML = &#39;&lt;img src = &quot;<a href="http://localhost/cgi-bin/mapserv?mode=legend&amp;map=%27+mapfile+" target="_blank">http://localhost/cgi-bin/mapserv?mode=legend&amp;map=&#39;+mapfile+</a>&#39;&quot;&lt;/img&gt;&#39;;<br>

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