Hi
I'm trying to have an element placed at the bottom left corner of the selected feature but can't figure out how to do it. I can place it at the center of the polygon fine but not at any other positions. Your help is much appreciated.
while (foundCursor.MoveNext())
{
using (var row = foundCursor.Current)
{
var shape = row as Feature;
var poly = shape.GetShape() as Polygon;
myLabelGraphic.Shape = poly.Extent;
myLabelGraphic.Placement = Anchor.BottomLeftCorner;
}
Solved! Go to Solution.
Hi Helen,
You have almost all the logic in
Once you get the polygon of your feature, you need to get its lower left corner coordinates. Use that for the graphic's shape property. So like this:
var poly = currentRow.GetShape() as Polygon;
var lowerLeftX = poly.Extent.XMin;
var lowerLeftY = poly.Extent.YMin;
myLabelGraphic.Shape = //Create MapPoint using these coordinates.
Thanks
Uma
Hi Helen,
You have almost all the logic in
Once you get the polygon of your feature, you need to get its lower left corner coordinates. Use that for the graphic's shape property. So like this:
var poly = currentRow.GetShape() as Polygon;
var lowerLeftX = poly.Extent.XMin;
var lowerLeftY = poly.Extent.YMin;
myLabelGraphic.Shape = //Create MapPoint using these coordinates.
Thanks
Uma
Hi Uma Harano,
Line 12 returns an error : graphic shape property can not be null or empty. What did I do wrong? maxPoint is not null.
Thank you!
var poly = shape.GetShape() as Polygon;
var maxX= poly.Extent.MMax;
var maxY= poly.Extent.YMax;
MapPoint maxPoint = MapPointBuilder.CreateMapPoint(maxX, maxY);
if (maxPoint != null)
{
myLabelGraphic.Shape = maxPoint;
myLabelGraphic.Placement = Anchor.CenterPoint;
myLabelGraphic.Text = myText;
myLabelGraphic.Symbol = myTextSymbol.MakeSymbolReference();
graphicsLayer.AddElement(myLabelGraphic);
}
Hi,
On line 2, use XMax instead. That should fix the issue.
Thanks
Uma
Hi Uma,
Silly me. I was so certain I had XMax there. Thank you very much!