[mapguide-users] Regarding - Set Feature Label at Run Time

ravinder.singh at BIRLASOFT.COM ravinder.singh at BIRLASOFT.COM
Sat Mar 7 04:24:30 EST 2009


Hi,

 

I have set the properties you told me to set. But its not working.
Infact I have set all the properties of label style as in following
code.Tried in many other ways around also, but not getting success.

 

Its giving the following error

 

"The remote server returned an error: (559) MgDbXmlException.: 

An exception occurred in DB XML component.

Error: XML Indexer:  Parse error in document at line, 43, char 19.
Parser message: Element 'Text' is not valid for content model:
'((Unit,SizeContext,SizeX,SizeY,Rotation,MaintainAspect,InsertionPointX)
,InsertionPointY,(Text,FontName,ForegroundColor,BackgroundColor,Backgrou
ndStyle,HorizontalAlignment,VerticalAlignment,Bold,Italic,Underlined,Adv
ancedPlacement),ExtendedData1)'

Exception occurred in method MgResourceDefinitionManager.UpdateDocument
at line 601 in file
d:\buildforgeprojects\mapguide_open_source_v2.0\build_27.16\mgdev\server
\src\services\resource\ResourceDefinitionManager.cpp"  when reaching at
conn.SaveResource(objVectorLayerDefinitionType) position.

I remove the line ar.Label.Text = "MY_PROPERTY_NAME ";

Then its gives the same error for FontName, same way gives for SizeX and
SizeY.

 

Here is the code

 

ar.Label = new TextSymbolType();

//TextSymbolType txtsymb = new TextSymbolType();

//txtsymb.Text = "MY_PROPERTY_NAME ";

//ar.Label = txtsymb;

ar.Label.Bold = "false";

ar.Label.FontName = "Arial";

ar.Label.HorizontalAlignment = "Center";

ar.Label.Italic = "false";

ar.Label.BackgroundColor = System.Drawing.Color.FromArgb(0,
System.Drawing.Color.White); //transparent

ar.Label.ForegroundColor = System.Drawing.Color.Black;

ar.Label.Unit = LengthUnitType.Points;

ar.Label.Underlined = "false";

ar.Label.VerticalAlignment = "Baseline";

//ar.Label.SizeX = "12";

//ar.Label.SizeY = "12";                                    

//ar.Label.Text = "MY_PROPERTY_NAME ";

ar.Label.Text = "MY_PROPERTY_NAME ";

 

 

Thanks & Regards,

Ravinder

________________________________

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Kenneth
Skovhede, GEOGRAF A/S
Sent: Thursday, March 05, 2009 7:07 PM
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] Regarding - Set Feature Label at Run Time

 

Yes, that is how it's supposed to be.
If you want to assign the label style, you must set many of the required
properties for a
label style object:

ar.Label = new TextSymbolType();
ar.Label.BackgroundColor = System.Drawing.Color.FromArgb(0,
System.Drawing.Color.White); //Transparent
ar.Label.ForegroundColor = System.Drawing.Color.Black;
ar.Label.Unit = LengthUnitType.Points;
ar.Label.SizeX = "12";
ar.Label.SizeY = "12";
ar.Label.FontName = "Arial";

I think those are the required ones, but I have not tested it.




Regards, Kenneth Skovhede, GEOGRAF A/S



ravinder.singh at BIRLASOFT.COM skrev: 

Hi,

 

I have tried it and written the following code. It works if I
check(select) the Display feature Labels in Label Style Dialog Box(in
maestro) and even don't set any property, but It does not work if I
don't check the Display feature Labels. 

 

Means if there is text "None"  set in Label Style  in Area Style then it
does not work , otherwise it works by simply checking the Display
feature Labels in Label Style Dialog Box.

 

That's why in your example code, this code "if (ar.Label != null)" is
written.

 

But my problem is that I do have Only Area style defined in maestro ,
but I have not defined any property as feature label. So I don't want to
check the  Display feature Labels checkbox, To Generate the dynamic
label I tried to write my commented line of code (c#), but does not
work.

 

Please If can be done ?

 

  foreach (VectorScaleRangeType vsr in
vectorLayerDefinition1.VectorScaleRange)

            {

                foreach (object o in vsr.Items)

                {

                    if (o is AreaTypeStyleType)

                    {

                        AreaTypeStyleType ast = o as AreaTypeStyleType;

                        if (ast.AreaRule != null)

                        {

                            foreach (AreaRuleType ar in ast.AreaRule)

                            {

                                      //Code to Create the label at run
time

   //====================================

                                //TextSymbolType txtSymb = new
TextSymbolType();

                                //txtSymb.Text = "MY_PROPERTY_NAME";

                                //ar.Label = txtSymb;        

  //====================================                       

                                if (ar.Label != null)

                                {

                                    ar.Label.Text = "MY_PROPERTY_NAME ";

                                }

                            }

                        }

                    }

                }

            }                        

 

Thanks & Regards,

Ravinder

________________________________

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Kenneth
Skovhede, GEOGRAF A/S
Sent: Thursday, March 05, 2009 1:12 PM
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] Regarding - Set Feature Label at Run Time

 

That is a bit difficult for two reasons.
1) The MapGuide style model is fairly large, so there are many subitems
to examine
2) The styles for Point, Line and Area don't share the same properties,
so they must be handled individually.

I have put up an example on how to do this here:
http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/IterateLa
yerRules





Regards, Kenneth Skovhede, GEOGRAF A/S



ravinder.singh at BIRLASOFT.COM skrev: 

Hi All,

 

I have to set a property as Feature Label for a layer at run time. I got
some hints and tried with VectorLayerDefinitionType and
TextSymbolType.But not able to do so as I don't know the exact
procedure.

 

I am using maestro api for creating run time map.

 

Please assist...

 

I am using c#, asp.net.

 

 

Thanks & Regards,

Ravinder

 

************************************************************************
************************************************************************
*********************%CRLF%"This message and any attachments are solely
for the intended recipient and may contain Birlasoft confidential or
privileged information. If you are not the intended recipient,any
disclosure,copying, use, or distribution of the information included in
this message and any attachments is %CRLF%prohibited. If you have
received this communication in error, please notify us by reply e-mail
at (administrator at birlasoft.com) and permanently delete this message and
any attachments. Thank
you."%CRLF%*************************************************************
************************************************************************
********************************%CRLF%
 
 
 



________________________________



 
 
 
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
  
************************************************************************
************************************************************************
*********************%CRLF%"This message and any attachments are solely
for the intended recipient and may contain Birlasoft confidential or
privileged information. If you are not the intended recipient,any
disclosure,copying, use, or distribution of the information included in
this message and any attachments is %CRLF%prohibited. If you have
received this communication in error, please notify us by reply e-mail
at (administrator at birlasoft.com) and permanently delete this message and
any attachments. Thank
you."%CRLF%*************************************************************
************************************************************************
********************************%CRLF%
 



________________________________



 
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
  

*********************************************************************************************************************************************************************%CRLF%"This message and any attachments are solely for the intended recipient and may contain Birlasoft confidential or privileged information. If you are not the intended recipient,any disclosure,copying, use, or distribution of the information included in this message and any attachments is %CRLF%prohibited. If you have received this communication in error, please notify us by reply e-mail at (administrator at birlasoft.com) and permanently delete this message and any attachments. Thank you."%CRLF%*********************************************************************************************************************************************************************%CRLF%
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090307/f7890359/attachment.html


More information about the mapguide-users mailing list