I'm using a GeometryEditor, and would like to add labels to the geometry which the user is creating, showing the lengths of the segments as they're working.
I'm doing this by looping over the segments of the GeometryEditor.Geometry and adding new Graphics (invisible except for the label) with a LabelDefinition to my own GraphicsOverlay on the map. The problem is, my labels are drawing underneath the geometry instead of on top.
I've set my Graphic.ZIndex to int.MaxValue hoping that would be high enough to cover the GeometryEngine graphics, but it didn't work. I can of course edit the geometry engine symbols to make the fill translucent, so then at least the labels are legible; but I would still rather have them on top.
Any suggestions on how I can get the labels on top?
Hi Felicity,
you are on the right lines with your workaround.
label_definition = LabelDefinition(label_expression, symbol);
label_definition.setDeconflictionStrategy(LabelDeconflictionStrategy.dynamic);
label_definition.setLabelOverlapStrategy(LabelOverlapStrategy.allow); // TODO decide and test your preference here
label_definition.setFeatureBoundaryOverlapStrategy(LabelOverlapStrategy.exclude);
label_definition.setFeatureInteriorOverlapStrategy(LabelOverlapStrategy.exclude);
graphicsOverlay.setLabelDefinitions({label_definition});
Hm, I see your strategy. The downside to this is that if we simply avoid overlapping the interior of the polygon, that filled-in area becomes wasted space while the labels are more crowded around the outside. Ideally I would actually be able to draw on top to make the best use of the space.
Another option would be to just make the whole GeometryEditor fill and outline transparent, and draw over it with my own graphics, in the same overlay as the labels... but I wonder if that's overkill, and the different selection graphics and feedback lines would make it more complicated than it's worth for a relatively small UI improvement.