Select to view content in your preferred language

text on sketch or graphics layer

3731
7
Jump to solution
10-31-2012 01:55 PM
HamzaHaroon
Regular Contributor
Is it possible to put word text on a sketch or graphics layer? Or would i have to take the text and make some sort of custom graphic out of it and then place that on the graphics layer?
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
Here is sample code, how to create a composite symbol with text/fill symbols and create a graphic with it.

AGSTextSymbol *textSymbol = [[AGSTextSymbol alloc]init]; textSymbol.textTemplate = @"Text Symbol"; textSymbol.color = [UIColor orangeColor];   AGSSimpleFillSymbol *simpleFillSymbol = [AGSSimpleFillSymbol simpleFillSymbol]; simpleFillSymbol.outline.color = [UIColor greenColor]; simpleFillSymbol.style = AGSSimpleFillSymbolStyleSolid;   //create a composite symbol AGSCompositeSymbol *compositeSymbol = [AGSCompositeSymbol compositeSymbol]; [compositeSymbol.symbols addObject:simpleFillSymbol]; [compositeSymbol.symbols addObject:textSymbol];  AGSGraphic *graphic = [AGSGraphic graphicWithGeometry:<your polygon geometry> symbol:compositeSymbol attributes:nil infoTemplateDelegate:nil];


Hope this helps!

Regards,
Nimesh

View solution in original post

0 Kudos
7 Replies
NimeshJarecha
Esri Regular Contributor
You should use AGSCompositeSymbol for the graphic which will have AGSTextSymbol with Marker/Line/Fill symbol.

Regards,
Nimesh
0 Kudos
HamzaHaroon
Regular Contributor
can you provide an example of how AGSTextSymbol can be used? I tried searching online, but couldn't find any.
0 Kudos
NimeshJarecha
Esri Regular Contributor
Here is sample code, how to create a composite symbol with text/fill symbols and create a graphic with it.

AGSTextSymbol *textSymbol = [[AGSTextSymbol alloc]init]; textSymbol.textTemplate = @"Text Symbol"; textSymbol.color = [UIColor orangeColor];   AGSSimpleFillSymbol *simpleFillSymbol = [AGSSimpleFillSymbol simpleFillSymbol]; simpleFillSymbol.outline.color = [UIColor greenColor]; simpleFillSymbol.style = AGSSimpleFillSymbolStyleSolid;   //create a composite symbol AGSCompositeSymbol *compositeSymbol = [AGSCompositeSymbol compositeSymbol]; [compositeSymbol.symbols addObject:simpleFillSymbol]; [compositeSymbol.symbols addObject:textSymbol];  AGSGraphic *graphic = [AGSGraphic graphicWithGeometry:<your polygon geometry> symbol:compositeSymbol attributes:nil infoTemplateDelegate:nil];


Hope this helps!

Regards,
Nimesh
0 Kudos
HamzaHaroon
Regular Contributor
thanks alot. this definitely seems like what i need. One thing i cant figure out is if I can make the text wrap around underneath if its too long.
0 Kudos
NimeshJarecha
Esri Regular Contributor
No, unfortunately, you can't wrap around text.

Regards,
Nimesh
0 Kudos
HamzaHaroon
Regular Contributor
oh ok. your code sample works great.

just some minor fixes to it:

textSymbol.text should be textSymbol.textTemplate

and [compositeSymbol.symbols addObject...]
0 Kudos
NimeshJarecha
Esri Regular Contributor
Thanks for pointing that out. I fixed it in my post.

Regards,
Nimesh
0 Kudos