This project is read-only.

How to add an ILabel to a FeatureLayer.Labels

Feb 3, 2011 at 4:05 AM

We have information such as 

  <Label X="4159844.26886126" Y="4492910.81089377" Rotation="0" Name="FULTON" />

And want to add a corresponding label to the FeatureLayer (without any reference to a map control).

How is this done? It seems no class implements the ILabel interface so we cannot

new LabelLayer().Labels.Add(new Label(...))
Feb 3, 2011 at 4:19 PM

I honestly can't remember if you can add a label layer directly to the map without tying it to a feature layer.  I usually advise people to create a point feature layer that represents the X, Y coordinates and then set up the label layer on that feature layer.  You can then mess with the dynamic visibility or other symbol techniques in order to hide the actual feature symbols themselves.  Since a LabelLayer is just another layer, there is a possibility that you could tweak it by adding a new constructor that doesn't require a feature set.  I suppose it could even use the same "offset" values in order to describe the X and Y coordinates for each label, where 0,0 is effectively the "point location" for all the labels.  It was not designed to be used that way and it might not work, but I believe it implements IMapLayer, so the rendering would likely be evoked correctly if you did add such a layer directly to the map.  If you really want stand alone label layers (like ESRI annotation) another question to consider is whether the scaling on the labels continues to work the same as it does for labels on a feature, or if it becomes like ESRI annotation, which essentially has a fixed size relative to the geography.

Anyway, I'm not sure that answers your question, but hopefully it helps a little.



Feb 5, 2011 at 3:36 AM

I gave up trying to add labels to the LabelLayer (due to a few quirks) and ended up adding them to the map control.