[Users] How to create legend panel using OpenLayers.Layer.MapServer layer...

Andreas Hocevar ahocevar at opengeo.org
Fri Jan 8 20:38:30 CET 2010


stela anders wrote:
> Thanks Andreas... ;)
> displayInLayerSwitcher did the trick !!!
> 
> I have some point layer with image symbol (.gif - 16x15) ... The legend 
> icon in that case stay ugly (only part of image appears)...

Not a GeoExt issue for sure. GeoExt just loads the image and displays it 
in its original extent and dimensions. But you could define a png24 
format in your mapfile, and configure your legendPanel with something like

defaults: {imageFormat: "image/png"}

> Any idea why that? Or maybe is a restriction?

Again, you might want to ask about GetLegendGraphic on the mapserver 
users list or look in the mapserver docs.

Regards,
Andreas.

> 
> Thanks so much! U r saving my week ;)
> 
> Stella
> 
> 2010/1/8 Andreas Hocevar <ahocevar at opengeo.org 
> <mailto:ahocevar at opengeo.org>>
> 
>     stela anders wrote:
> 
>         Hello Andreas...
> 
>         All sublayers is with status ON, they are draw on map, but in my
>         legend I got ONLY "Layer1" label printed...
>         My layers:
>                       OpenLayers.Layer.WMS("Layer1",
>                        mycgi, {
>                            map: mymapfile,
>                            layers: ['Sublayer11','Sublayer12',
>         'Sublayer13'],
>                            format: "image/png",
>                            transparent: "true"
>                        }, {
>                            isBaseLayer: true,                          
>                    visibility: true
>                        }),
> 
> 
>     The above should cause three GetFeatureInfo requests to be issued:
>     one for each of your sublayers. If you just see the label, then
>     MapServer does not send you an image on the GetFeatureInfo request.
>     Here is what you can try: enable the Net panel on firebug and look
>     at the GetFeatureInfo request that the browser issues. Copy them,
>     open them in a browser window/tab, and fix your mapfile until they
>     work (more help available in mapserver docs/lists).
> 
> 
>                       OpenLayers.Layer.WMS("Layer2",
>                        mycgi, {
>                            map: mymapfile,
>                            layers: ['Sublayer21','Sublayer22',
>         'Sublayer23'],
>                            format: "image/png",
>                            transparent: "true"
>                        }, {
>                            isBaseLayer: false,
>                            displayInLayerSwitcher: false,
>                            visibility: true
>                        }),
> 
> 
>     This won't display anything, because you have set
>     "displayInLayerSwitcher" to false.
> 
>         So, What is your suggestion in building a legend to Map with
>         GeoExt sublayers? I need all sublayers appears on my legend
>         (each one has different images...)
> 
> 
>     The LegendPanel does exactly that. It requests one image per
>     sublayer (now that you provided a code snippet and I finally know
>     what you meant by "sublayer"). My suggestion is: fix your mapfile so
>     Mapserver can answer GetFeatureInfo requests correctly.
> 
>     Regards,
>     Andreas.
> 
>     -- 
>     Andreas Hocevar
>     OpenGeo - http://opengeo.org/
>     Expert service straight from the developers.
> 
> 


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list