All,
Has anyone successfully created a balloon callout on graphics layer by codes ? I asked this question before with previous version of arcgis Pro. I was under the impression with version 2.8 I should be able to do it but no luck so far. Below is my codes. I got all other properties correct but NO callout arrow. Thanks in advance for your help.
_subjectTextSymbol = await CreateBalloonCalloutAsync(ColorFactory.Instance.RedRGB);
.
.
.
subjectLabelGraphic.Text = "Subject";
subjectLabelGraphic.Symbol = _subjectTextSymbol.MakeSymbolReference();
//Add the graphic label
graphicsLayer.AddElement(subjectLabelGraphic);
.
.
.
private static Task<CIMTextSymbol> CreateBalloonCalloutAsync(CIMColor textColor)
{
return QueuedTask.Run<CIMTextSymbol>(() =>
{
//create a text symbol
var textSymbol = SymbolFactory.Instance.ConstructTextSymbol(textColor, 11, "Corbel", "Regular");
//A balloon callout
var balloonCallout = new CIMBalloonCallout();
//set the callout's style
balloonCallout.BalloonStyle = BalloonCalloutStyle.RoundedRectangle;
//Create a solid fill polygon symbol for the callout.
var polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreyRGB, SimpleFillStyle.Solid);
//Set the callout's background to be the black polygon symbol
balloonCallout.BackgroundSymbol = polySymbol;
//margin inside the callout to place the text
balloonCallout.Margin = new CIMTextMargin
{
Left = 5,
Right = 5,
Bottom = 5,
Top = 5
};
//assign the callout to the text symbol's callout property
textSymbol.Callout = balloonCallout;
return textSymbol;
});
}
Solved! Go to Solution.
Thanks for the reply @LeLuong. That is very interesting that it is possible through the SDK but on the UI. Also that it allows that in the first place.
I can only hope that these types of features that are not available in the UI will be available in the SDK in the future.
Yayyyy! I got it. Thank yo very much @CharlesMacleod .
to coin a phrase: just do it. this is possible through the api and, apparently, not the ui.
var textGraphic = new CIMTextGraphic() {
Text = "Callout Text",
Placement = Anchor.CenterPoint,
Symbol = textSymbol.MakeSymbolReference(),
Shape = MapView.Active.Extent.Center,
//Leaders is an array of CIMLeader - add a Leader point to show
//the leader, remove Leaders to hide the leader.
Leaders = new CIMLeader[] {
new CIMLeaderPoint(){
Point = MapPointBuilderEx.CreateMapPoint(
MapView.Active.Extent.Center.X - 5000,
MapView.Active.Extent.Center.Y - 1500)
},
new CIMLeaderPoint(){
Point = MapPointBuilderEx.CreateMapPoint(
MapView.Active.Extent.Center.X - 3500,
MapView.Active.Extent.Center.Y - 2500)
},
new CIMLeaderPoint(){
Point = MapPointBuilderEx.CreateMapPoint(
MapView.Active.Extent.Center.X - 500,
MapView.Active.Extent.Center.Y - 5000)
}
}
};