CompositeSymbol with TextSymbol

4082
5
05-15-2015 02:48 AM
steelissteelis
New Contributor

Hi Everyone,

I have recently created a CompositeSymbol that consist of a PictureMarkerSymbol, TextSymbol and a SimpleMarkerSymbol.

After adding the CompositeSymbol into the GraphicLayer, I realize that the TextSymbol within the added GraphicSymbol have actually lost the Font information.

This is a portion of the code where the CompositeSymbol is created and the values tested:

Graphic graphic = CreateACompositeSymbol();

if (graphic != null) {

   int graphicUID = graphicslayer.addGraphic(graphic);

   Graphic graphicAdded = graphicslayer.getGraphic(graphicUID);

  Symbol symbol = graphicAdded.getSymbol();

   if(symbol instanceof CompositeSymbol){

  CompositeSymbol compositeSymbol = (CompositeSymbol) symbol;

  List<Symbol> listofSymbols = compositeSymbol.getSymbols();

   for(Symbol innerSymbol : listofSymbols){

   if(innerSymbol instanceof TextSymbol){

   float size = ((TextSymbol) innerSymbol).getSize();

  }

  }

  }

I think you can create your own composite symbol then just place a breakpoint at the last line to see the difference in the Font value for the TextSymbol in the graphic and graphicAdded object. The text value is the same and the color in the Attributes map is correct though.

Can anyone confirm if they have the same problem?

Thanks in advance for any help.

Tags (2)
0 Kudos
5 Replies
WillCrick
Occasional Contributor

Hi,

When you say the symbol has lost its "Font" information, are you referring to the value returned from the getSize() method? If so, are you saying that this property is coming back as a different value from the value you originally set on this symbol before you added it to the graphics layer?

Thanks

Will

steelissteelis
New Contributor

Hi Will and Everyone,

This is a sample value from debugging the TextSymbol. I have obttaiend the value from the List of Graphic in the MapView

Font [family=null, size=8.0, style=normal]

Note that the Size was 18 prior to adding. After adding into the list then immediately obtaining the object using the Graphic UID, the value is now 8.

I have verified the problem with my colleague who also encountered the same problem previously.

Thank you in advance for the help.

0 Kudos
XuemingWu
Esri Contributor

Hi Steelis,

When you create a TextSymbol, the font properties as well as other properties are respected by the API. The value of font size is lost only when you get the symbol from the graphic that you derive from GraphicsLayer.getGraphic(s) . It is a bug in our API.

Not sure what is your use case in the above code snippet. If you want to apply the same font properties to other TextSymbol, you can either retain a reference of the symbol or the graphic you create instead of using the ones that are derived from GraphicsLayer.getGraphic(s). If you want to change the font properties of a TextSymbol, create a new TextSymbol instead of changing the ones that are derived from GraphicsLayer.getGraphic(s).

thanks.

0 Kudos
steelissteelis
New Contributor

Hi Xueming,

Thank you for the answer.

Actually I'm just verifying that it is a bug in the ArcGIS Android API and hopefully let the Developers in Esri be aware of it. I have workarounds in my use case for now but I thought it will be better in the future for that to be fixed in future releases.

Best Regards,

Steelis

0 Kudos
XuemingWu
Esri Contributor

Hi Steelis,

Thank you for your update. An issue has been logged for this bug. It will be addressed in a future release.

thanks,

Xueming

0 Kudos