ArcGIS API for JavaScript: StreamLayer: Labels

3468
2
10-13-2014 11:02 PM
TodStevens
New Contributor II

Has anyone been able to turn on labels for streamlayers in ArcGIS API for JavaScript?

 

The samples do not show any labels (dots with labels are not very useful), but the API has the ability to via SetLabelingInfo.

 

I used the streamlayer sandbox to test this (full sample attached)

 

var labelClass = new LabelClass({

  labelExpression: '[BusNo]',

  labelPlacement: 'always-horizontal'

});

 

  labelClass.symbol = new TextSymbol({

    font: new Font("12", Font.STYLE_NORMAL, Font.VARIANT_NORMAL, Font.WEIGHT_BOLD, "Helvetica"),

    color: new Color("#666633")

                         });

 

            layer.setLabelingInfo([labelClass]);

            layer.setShowLabels(true);

            layer.setRenderer( renderer );

 

Regards

Tod

Tags (1)
0 Kudos
2 Replies
TodStevens
New Contributor II

I still can not use the labelinfo mechanism in the streamlayer to add labels.

I was able to add a client-side label layer and add labels when not using a basemap. I had to use an added featurelayer as the base map (I do not know why that affected labelling)

The additional problem with client side labelling with a label layer is that labels hang around after the renderer of the stream adds a new point.

   var temporalRenderer = new TemporalRenderer(null , latestObsRenderer, null, null);

I make the obsRenderer=null so I only see the latest observations from the stream. The label for the older observation remains around for a while (a refresh/redraw issue)

0 Kudos
TodStevens
New Contributor II

I have had some success with labels. API 3.11 has a problem with placing point labels (only places them with the above-right default). I can see the problem in labellayer.js

I cannot see how to set label priorities?

0 Kudos