[UMN_MAPSERVER-DEV] C# layerObj.draw && layerObj.drawLegend

Tamas Szekeres szekerest at GMAIL.COM
Mon Apr 23 05:25:27 EDT 2007


Currently there's no separate function for drawing a legend item for one
layer. However you can temporarily disable including the other layers by
setting their layerObj.status to MS_OFF or layerObj.type to
MS_LAYER_TYPE.MS_LAYER_QUERY.

Best regards,

Tamas



2007/4/23, Jean Michel PIERRET <jmp at geosys.com>:
>
>  Hi,
>
>
>
> 1)
>
>
>
> I guess you should either disable the labelcache for this layer (
> layerObj.labelcache = mapscript.MS_OFF ) or call layerObj.drawlabelcacheexplicitly right after drawing the shapes.
>
>
>
> It's ok for the label with (layerObj.labelcache = mapscript.MS_OFF),
> drawlabelcache does not exist on layerObj but on mapObj.
>
>
>
> lobj.labelcache = mapscript.MS_OFF;
>
> lobj.draw(_lobj.map, iobj);
>
> or
>
>             lobj.draw(_lobj.map, iobj);
>
>             lobj.map.drawlabelcache(iobj);
>
> 2)
>
> Here is a function extracted from my previous project for drawing the
> legend image, hopefully it applies to your intents fairly enough.
>
> private Image CreateLegendImage(layerObj layer, int classindex, int width,
> int height, int keysizex, int keysizey)
>         {
>             using (classObj def_class = new classObj(null)) // for drawing
> legend images
>             {
>                 using (imageObj image = def_class.createLegendIcon(map,
> layer, width, height))
>                 {
>                     classObj layerclass = layer.getClass(classindex);
>                     layerclass.drawLegendIcon(layer.map, layer, keysizex,
> keysizey, image,
>                         (width - keysizex) / 2, (height - keysizey) / 2);
>                     byte[] img = image.getBytes();
>                     using (MemoryStream ms = new MemoryStream(img))
>                     {
>                         return Image.FromStream(ms);
>                     }
>                 }
>             }
>         }
>
>  Your function work but for one class only and without label, I'm looking
> for a function which give me the same result of mapObj.drawLegend with
> only on layer activate.
>
> Thanks,
>
>
>
> Regards.
>
>
>
> *Jean-michel PIERRET <jmp at geosys.com> - Poste  376*
>
> *Tel : +33 (0)5 62 47 80 76*
> *Mail* : jmp at geosys.com
> *GEOSYS SA*
>
>
>
>
>
> -----Message d'origine-----
> *De :* UMN MapServer Developers List [mailto:MAPSERVER-DEV at LISTS.UMN.EDU]
> *De la part de* Tamas Szekeres
> *Envoyé :* vendredi 20 avril 2007 21:15
> *À :* MAPSERVER-DEV at LISTS.UMN.EDU
> *Objet :* Re: [UMN_MAPSERVER-DEV] C# layerObj.draw && layerObj.drawLegend
>
>
>
>
>
> 2007/4/20, Jean Michel PIERRET <jmp at geosys.com>:
>
> Hi,
>
>
>
> I'm using mapserver with c# bindings and i have two questions.
>
>
>
> 1)
>
>                         layerObj lobj = null;
>
>
>
> ...
>
>
>
>             imageObj iobj = null;
>
>
>
>             iobj = lobj.map.prepareImage();
>
>             lobj.draw(_lobj.map, iobj);
>
>
>
> In the drawn image, the labels don't appear, whereas with the method
> mapObj.draw they are there. It is normal ?.
>
>
> I guess you should either disable the labelcache for this layer (
> layerObj.labelcache = mapscript.MS_OFF ) or call layerObj.drawlabelcacheexplicitly right after drawing the shapes.
>
>
>
>
> 2)
>
>
>
> Exist there a method to draw legend for one layer only and not for all the
> map.
>
>
> Here is a function extracted from my previous project for drawing the
> legend image, hopefully it applies to your intents fairly enough.
>
> private Image CreateLegendImage(layerObj layer, int classindex, int width,
> int height, int keysizex, int keysizey)
>         {
>             using (classObj def_class = new classObj(null)) // for drawing
> legend images
>             {
>                 using (imageObj image = def_class.createLegendIcon(map,
> layer, width, height))
>                 {
>                     classObj layerclass = layer.getClass(classindex);
>                     layerclass.drawLegendIcon(layer.map, layer, keysizex,
> keysizey, image,
>                         (width - keysizex) / 2, (height - keysizey) / 2);
>                     byte[] img = image.getBytes();
>                     using (MemoryStream ms = new MemoryStream(img))
>                     {
>                         return Image.FromStream(ms);
>                     }
>                 }
>             }
>         }
>
>
>
> Best regards,
>
> Tamas
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20070423/be4142df/attachment.html


More information about the mapserver-dev mailing list