TransWikia.com

How to show labels for dynamicLayerInfo in ArcGISDynamicMapServiceLayer

Geographic Information Systems Asked by Shilpakar Amar on April 26, 2021

Does anyone know how to show labels for dynamic layers

I have used below code for show dynamic layers which is working fine and now I have to display labels for that dynamic layers.

    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);

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP