Select to view content in your preferred language

Drawing labels on top of GeometryEditor graphics

311
2
4 weeks ago
FelicityRhone
Regular Contributor

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?

FelicityRhone_0-1777932224636.png

 

0 Kudos
2 Replies
gyoung
by
New Contributor

Hi Felicity,

you are on the right lines with your workaround. 

Use a Graphic for the polygon geometry and a Graphic for each of the vertices and mid-vertices, all Graphics should be in the same GraphicsOverlay. The Graphics can have a symbology as with the VertexTool they are always hidden by the GeometryEditor's graphics and default Style ( GeometryEditorStyle.midVertexSymbol etc). In-fact, to get label deconfliction working as we want it seems the Graphics must have symbols. Ideally, the symbols would be a similar size to the MidVertexSymbol, VertexSymbol and FillSymbol.
Then you can set:
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});

Note: LabelDeconflictionStrategy.dynamic is used since dynamicNeverRemove seems to mean that the boundary and interior instructions could be ignored.
LabelDeconflictionStrategy.dynamic means there is a chance some labels could be removed in order to avoid the polygon interior/boundary, in practice I've not seen them being removed.
 
Note also: this suggestion means there is still a chance the label could be a little obscured by the GeometryEditorStyle.selected* symbols. This could be alleviated by some transparency in GeoView.selectionProperties.
 
Note also: this suggestion is only suitable for the VertexTool and not Reticle tools as your symbology would not be hidden by GeometryEditor's graphics during vertex and geometry moves.
 
 

 

 

0 Kudos
FelicityRhone
Regular Contributor

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.

0 Kudos