Provide better Label support of Feature Layers in ArcGIS Server JavaScript API

572
2
09-03-2014 07:35 AM
Status: Open
KarenRobine
Occasional Contributor II

In the JavaScript API, there's FeatureLayer and LabelLayer classes. However, the LabelLayer class does not currently deal with conflict resolution of the labels. The labels need to be better associated with the graphics of the FeatureLayer, and supported by the same "conflict resolution" issues that face those graphics (ie., overlapping graphics). We ran into this when attempting to handle overlapping SimpleMarkerSymbols with labels. You could not tell which marker symbol the label was associated with. And in cases where part of the simple marker symbol was showing up, the label should have also shown up.  Your samples lead us to handling this with icon marker symbols, but we're dealing with thousands of these with unique label values so the icon marker symbols won't cut it.
 

We also researched using SVG graphics to solve this problem but since we can only use a path element, we had no way to associate a marker and a text together. So  possibly providing more capabilities with SVG graphics could help solve this problem.

2 Comments
by Anonymous User
I agree - options like 'never remove' so that features don't lose labels, as well as the ability to 'stack' labels to make them fit would make such a difference. This is along the lines of what is available in the Maplex label engine in ArcMap.
GodfreyYeung1

"The labels need to be better associated with the graphics of the FeatureLayer" Agreed.

I was trying to modify labels of FeatureLayer polygons so that they would not be one long horizontal string.

However, currently there seems to be no way of accessing and modifying those labels after setting them as properties during construction of FeatureLayer classes.

I thought about iterating through the FeatureLayerView's graphics, but there's no way of accessing labels through graphics or symbols. 

Another great solution would be to allow the LabelClass's labelExpressionInfo property to accept a function as an argument, and have feature attributes available within that function. 

The only current solution seems to be to create an independent set of Text graphics, and set their positions to correspond with respective features in the FeatureLayer. This seems messy. 

A similar story goes for popups. 

I'm using 4.0 right now.