I have used below code for show dynamic layers which is working fine and now I have to display labels for that dynamic layers.
How to do that with below code?
var dataSource = new esri.layers.TableDataSource();
var layerSource = new esri.layers.LayerDataSource();
var dynamicLayerInfo = new esri.layers.DynamicLayerInfo();
var drawingOptions = new esri.layers.LayerDrawingOptions();
var layerinfoTemplate = new www.InfoTemplate();
var options = [];
dataSource.workspaceId = "..."
dataSource.dataSourceName = "..."; //shapefile name
layerSource.dataSource = dataSource;
dynamicLayerInfo.id = i;
dynamicLayerInfo.name = "...";
dynamicLayerInfo.source = layerSource;
dynamicLayerInfos.push(dynamicLayerInfo);
var labelClass = new w.LabelClass({
useCodedValues: false,
labelExpression: "Name: {CITY_NAME} Area: {CITY_AREA}",
labelPlacement: 'esriServerLinePlacementAboveAfter',
symbol: new w.TextSymbol({
color: new w.Color("#000000")
})
});
drawingOptions.renderer = new SimpleRenderer(new SimpleLineSymbol(new
SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 0]), 2));
drawingOptions.showLabels = true;
options[0] = drawingOptions;
EsriDynamicLayer.setDynamicLayerInfos(dynamicLayerInfos, true);
EsriDynamicLayer.setLayerDrawingOptions(options);
Hi,
please enable dynamic layers support on your service first.
Hope this helps,
Adam
Hi @nita14
the dynamic layer is already enabled and dyaminc layers are already visible in the map.
Now I want to show labels of the layers that are visible in map,
Can you help me on that
Did you assign labelClass to drawingOptions ?
https://developers.arcgis.com/javascript/3/jsapi/layerdrawingoptions-amd.html#labelinginfo
yes i have assign it like below
labelPlacement: 'esriServerLinePlacementAboveAfter',
is wrong. Check valid values first.
https://developers.arcgis.com/javascript/3/jsapi/labelclass-amd.html#labelplacement
Basically, leave only labelExpression and check it that works. Zoom in the map to check if labels are there.
Adam
Tried this but not showing labels
can you help me in this.. I am literally stuck in this.