Hi ,
We are develope tools using text annotation in 2.1 new sdk. We have a symbol showing the width of the drawn vehicle rout ,how can we create this symbol with text annotation in the format shown below (picture) ? Ican create only 12 with text annotation but I can not create the others.
Thanks
Best Regards
Hello, If I'm understanding correctly all you need to get the text you want within your circular point symbol callout is tags. The text string would be `12<SUP> <UND>00</UND></SUP>`. I hope that answers your question.
Ciara
Taner,
2.1 was the first release of annotation and we are working on enhancing the API for 2.2, 2.3, etc.
Currently, to make a annotation symbol similar to the above requires:
The CIM is where it can get tricky - especially for a complex symbol as you have above. This is a complete example that will change whichever annotation feature you have selected to be a circle with the text "12 00"
internal class ChangeSymbol : Button
{
protected async override void OnClick()
{
var annoLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<AnnotationLayer>().FirstOrDefault();
if (annoLayer == null)
return;
await QueuedTask.Run(() => {
var select = annoLayer.GetSelection();
if (select.GetObjectIDs().Count() > 0)
{
var oid = select.GetObjectIDs().First();
QueryFilter qf = new QueryFilter()
{
WhereClause = $"OBJECTID = {oid}"
};
var rowCursor = annoLayer.GetTable().Search(qf, false);
rowCursor.MoveNext();
var annoFeature = rowCursor.Current as ArcGIS.Core.Data.Mapping.AnnotationFeature;
var graphic = annoFeature.GetGraphic();
var textGraphic = graphic as CIMTextGraphic;
var op = new EditOperation();
op.Name = "Change Anno";
op.Callback((context) => {
//make the callout for the circle
var callOut = new CIMPointSymbolCallout();
callOut.PointSymbol = new CIMPointSymbol();
//Circle outline
var circle_outline = SymbolFactory.Instance.ConstructMarker(40, "ESRI Default Marker") as CIMCharacterMarker;
circle_outline.Size = 30;
//eliminate the outline
foreach (var layer in circle_outline.Symbol.SymbolLayers)
{
if (layer is CIMSolidStroke) {
((CIMSolidStroke) layer).Width = 0;
}
}
//Circle fill
var circle_fill = SymbolFactory.Instance.ConstructMarker(172, "ESRI Default Marker") as CIMCharacterMarker;
circle_fill.Size = 30;
//eliminate the outline, make sure the fill is white
foreach (var layer in circle_fill.Symbol.SymbolLayers) {
if (layer is CIMSolidFill) {
((CIMSolidFill)layer).Color = ColorFactory.Instance.WhiteRGB;
}
else if (layer is CIMSolidStroke)
{
((CIMSolidStroke)layer).Width = 0;
}
}
var calloutLayers = new List<CIMSymbolLayer>();
calloutLayers.Add(circle_outline);
calloutLayers.Add(circle_fill);
//set the layers on the callout
callOut.PointSymbol.SymbolLayers = calloutLayers.ToArray();
//set the callout on the text symbol
var textSym = textGraphic.Symbol.Symbol as CIMTextSymbol;
textSym.Callout = callOut;
textSym.Height = 8;//adjust as needed
//now set the text
textGraphic.Text = "12 <SUP><UND>00</UND></SUP>";
annoFeature.SetGraphic(textGraphic);
annoFeature.Store();
context.Invalidate(annoFeature);
}, annoLayer.GetTable());
op.Execute();
}
});
}
}