[mapguide-users] Legend icons hardcoded to 16x16 pixels?

Hans Milling hm at geograf.dk
Tue Nov 29 05:45:41 EST 2011


Is it on purpose that Legend items are hardcoded to 16x16 pixels in the
Maestro API?
When using dashed lines on the map, the legend image is too small to tell
the difference between different dashed or dotted lines:
http://osgeo-org.1803224.n2.nabble.com/file/n7042355/legendimage.png
legendimage.png 

The source looks like this:

        public override System.Drawing.Image GetLegendImage(double scale,
string layerdefinition, int themeIndex, int type)
        {
            MgMappingService ms =
this.Connection.CreateService(MgServiceType.MappingService) as
MgMappingService;
            MgResourceIdentifier ldef = new
MgResourceIdentifier(layerdefinition);

            var bmp = new
System.Drawing.Bitmap(Utility.MgStreamToNetStream(ms,
ms.GetType().GetMethod("GenerateLegendImage"), new object[] { ldef, scale,
16, 16, "PNG", type, themeIndex }));
            LogMethodCall("MgMappingService::GetLegendImage", true,
scale.ToString(), layerdefinition, themeIndex.ToString(), type.ToString());
            return bmp;
        }

I suggest making an overloaded method that accepts a width and height
attribute to be able to customize the size of the icons:

        // If called without the width/height, the method generates the
original 16x16 icons
        public override System.Drawing.Image GetLegendImage(double scale,
string layerdefinition, int themeIndex, int type)
        {
            return GetLegendImage(scale, layerdefinition, themeIndex, type,
16, 16);
        }

        public override System.Drawing.Image GetLegendImage(double scale,
string layerdefinition, int themeIndex, int type, int width, int height)
        {
            MgMappingService ms =
this.Connection.CreateService(MgServiceType.MappingService) as
MgMappingService;
            MgResourceIdentifier ldef = new
MgResourceIdentifier(layerdefinition);

            var bmp = new
System.Drawing.Bitmap(Utility.MgStreamToNetStream(ms,
ms.GetType().GetMethod("GenerateLegendImage"), new object[] { ldef, scale,
width, height, "PNG", type, themeIndex }));
            LogMethodCall("MgMappingService::GetLegendImage", true,
scale.ToString(), layerdefinition, themeIndex.ToString(), type.ToString());
            return bmp;
        }

Best regards Hans Milling...

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Legend-icons-hardcoded-to-16x16-pixels-tp7042355p7042355.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list