<div dir="ltr">Hi Subha,<br><br>I think for the "mode=legend" to work, you need to change the LAYER status to DEFAULT. 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>&service=wms<br>&version=%221.1.1%22<br>&request=GetLegendGraphic<br>
&layer=countries<br>&styles=<br>&width=60<br>&height=40<br>&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"><<a href="mailto:subha@gslab.com">subha@gslab.com</a>></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. 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't seem to be generating any image.<br>
This is how my map file looks. I've not pasted the entire contents as its too big.<br>
<br>
legend<br>
status on<br>
imagecolor 255 0 0<br>
position ul<br>
end<br>
layer<br>
CONNECTIONTYPE postgis<br>
name india_states<br>
CONNECTION "user=postgres dbname=ibp host=localhost"<br>
group world<br>
type polygon<br>
dump true<br>
METADATA<br>
"wfs_title" "Factbook Metadata"<br>
"gml_include_items" "all"<br>
"wms_feature_info_mime_type" "text/html"<br>
END<br>
template "template.html"<br>
projection<br>
"init=epsg:4326"<br>
end<br>
transparency alpha<br>
status on<br>
data "topology from india_states using unique id using SRID = -1"<br>
CLASSITEM "state"<br>
CLASS<br>
NAME "JAMMU & KASHMIR"<br>
EXPRESSION "JAMMU & KASHMIR"<br>
STYLE<br>
COLOR 191 191 155<br>
OUTLINECOLOR 000 000 000<br>
#antialias true<br>
end<br>
end<br>
CLASS<br>
NAME "HIMACHAL"<br>
EXPRESSION "HIMACHAL"<br>
STYLE<br>
COLOR 245 226 188<br>
OUTLINECOLOR 000 000 000<br>
#antialias true<br>
end<br>
end <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('div');<br>
legenddiv.setAttribute('id','legend');<br>
legenddiv.innerHTML = '<img src = "<a href="http://localhost/cgi-bin/mapserv?mode=legend&map=%27+mapfile+" target="_blank">http://localhost/cgi-bin/mapserv?mode=legend&map='+mapfile+</a>'"</img>';<br>
document.getElementById('map').appendChild(legenddiv);<br>
<br>
Thanks & regards,<br>
Subha<br>
<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>
-----Original Message-----<br>
*From:* <a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank">mapserver-users-bounces@lists.osgeo.org</a><br>
[mailto:<a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank">mapserver-users-bounces@lists.osgeo.org</a>] *On Behalf Of<br>
*Roger André<br>
*Sent:* Tuesday, October 07, 2008 12:06 PM<br>
*To:* Steve Lime<br>
*Cc:* <a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.org</a><br>
*Subject:* Re: [mapserver-users] Creating legend<br>
<br>
Also, you might want to consider making a separate<br>
GetLegendGraphic WMS request and putting the legend in a separate<br>
DIV element in your web page. <br>
Just an idea.<br>
--<br>
<br>
On Tue, Oct 7, 2008 at 8:22 AM, Steve Lime<br>
<<a href="mailto:Steve.Lime@dnr.state.mn.us" target="_blank">Steve.Lime@dnr.state.mn.us</a> <mailto:<a href="mailto:Steve.Lime@dnr.state.mn.us" target="_blank">Steve.Lime@dnr.state.mn.us</a>>><br>
wrote:<br>
<br>
Visit:<br>
<br>
<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>
and search for untiled. There's a "WMS Untiled" example you<br>
can view the source of. The singleTile option goes in the<br>
"options" object as opposed the "params" object. Params get<br>
passed to the WMS service, options are handled by OL.<br>
<br>
Steve<br>
<br>
>>> Subha Ramakrishnan <<a href="mailto:subha@gslab.com" target="_blank">subha@gslab.com</a><br>
<mailto:<a href="mailto:subha@gslab.com" target="_blank">subha@gslab.com</a>>> 10/07/08 9:58 AM >>><br>
Hi Steve,<br>
It would be great if you can give me an example or tell me<br>
where it is<br>
usually set in OL.<br>
Thanks for your help.<br>
<br>
Subha<br>
<br>
Steve Lime wrote:<br>
> There's nothing you have to do on the MapServer side. Looks<br>
like your OL config is wrong<br>
> though. I think 'singleTile' is set in the wrong<br>
configuration object, perhaps others are in<br>
> the wrong place too.<br>
><br>
> Steve<br>
><br>
><br>
>>>> Subha Ramakrishnan <<a href="mailto:subha@gslab.com" target="_blank">subha@gslab.com</a><br>
<mailto:<a href="mailto:subha@gslab.com" target="_blank">subha@gslab.com</a>>> 10/07/08 1:30 AM >>><br>
>>>><br>
> Hi,<br>
><br>
> I am using mapserver 5.0.2 with openlayers.<br>
> I've a problem while creating a legend for a map from<br>
mapserver.When i<br>
> try to overlay the image from the mapserver on openlayers'<br>
base map, the<br>
> images are rendered in tiles, and every tile has a legend<br>
and is limited<br>
> by the size of the tile. So, i see lots of legends on the<br>
map and only<br>
> half of them are visible as it is restricted by the tile size.<br>
><br>
> This is my request to mapserver from openlayers<br>
><br>
> var mapfile = layer_tablename+'.map';<br>
> twms1 = new OpenLayers.Layer.WMS(<br>
> layer_tablename,"<a href="http://localhost/cgi-bin/mapserv" target="_blank">http://localhost/cgi-bin/mapserv</a>?",<br>
> { map: mapfile,<br>
> transparent: 'true', layers:layer_tablename,<br>
> format: 'image/png',<br>
> projection:"EPSG:4326",reproject:false,<br>
> units: "m",<br>
> singleTile: true<br>
> },{numZoomLevels : MaxZoomLevel});<br>
> map.addLayer(twms1);<br>
><br>
> I am using the option of singleTile. Is there any setting to<br>
be done in<br>
> the map file or mapserver for it render a single tile/single<br>
legend per<br>
> image?<br>
><br>
> Thank you.<br>
><br>
> Regards,<br>
> Subha<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>
<mailto:<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>
><br>
><br>
><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>
<mailto:<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>
<br>
<br>
<br>
-- <br>
This message has been scanned for viruses and<br>
dangerous content by *MailScanner* <<a href="http://www.mailscanner.info/" target="_blank">http://www.mailscanner.info/</a>>, 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>
<br>
</blockquote>
<br>
</blockquote></div><br></div>