LabelPoints returns the correct points, but then the text's top-left (or bottom-left) corner is placed at that point. I want to center the text. Not sure how to offset it, since the text can change. Any ideas?
<esri:TextSymbol FontSize="14" OffsetX="50" OffsetY="7" Text="{Binding Attributes[myAttribute]}"> <esri:TextSymbol.ControlTemplate> <ControlTemplate> <TextBlock Width="100" FontFamily="{Binding Symbol.FontFamily}" FontSize="{Binding Symbol.FontSize}" Foreground="{Binding Symbol.Foreground}" Text="{Binding Symbol.Text}" TextAlignment="Center" /> </ControlTemplate> </esri:TextSymbol.ControlTemplate> </esri:TextSymbol>
Yeah I tried that but then there are different-sized features that should have their labels visible at different resolutions. Any idea about that?
I guess, you'd rather to get a labelling engine at client side working label by label but unfortunately, that doesn't exist yet.
Exactly. Mike mentioned that there were talks about adding advanced labeling in next versions of the Runtime. Is there an estimated time frame for that by any chance?
geometryTask.LabelPointsCompleted += delegate(object snd, GraphicsEventArgs le) { graphicsLayer.Graphics.Clear(); for (int i = 0; i < le.Results.Count; ++i) { var graphic = le.Results; var feature = features; if (feature.Geometry != null && feature.Attributes["PROP_ID"] != null && Convert.ToInt32(feature.Attributes["PROP_ID"]) > 0) { var extent = feature.Geometry.Extent; var point1 = MyMap.MapToScreen(new MapPoint(extent.XMin, extent.YMin, extent.ZMin, extent.MMin, extent.SpatialReference)); var point2 = MyMap.MapToScreen(new MapPoint(extent.XMax, extent.YMax, extent.ZMax, extent.MMax, extent.SpatialReference)); if (Point.Subtract(point1, point2).Length > 110) { var symbol = new TextSymbol() { Text = feature.Attributes["PROP_ID"].ToString(), ControlTemplate = LayoutRoot.Resources["LabelTemplate"] as ControlTemplate, FontSize = 12, OffsetX = 50, OffsetY = 6 }; graphic.Symbol = symbol; var mapPoint = graphic.Geometry as MapPoint; graphic.Attributes.Add("X", mapPoint.X); graphic.Attributes.Add("Y", mapPoint.Y); graphicsLayer.Graphics.Add(graphic); } } } };
if ((point2.X - point1.X) > 110)
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.