AnsweredAssumed Answered

Label Placement & Halo of featureLayer issues

Question asked by atomaly on Jun 23, 2015
Latest reply on Jul 29, 2015 by atomaly

Hi All,

 

I've got a problem when I'm trying to create labels using Label Layer for a featureLayer i create on the fly (using a JSON FeatureCollectionObject)

 

Label Placement of DynamicLayers seems like it is so much better.....but I have a requirement to generate the layer on the fly..

Symbology is fine, that seems to be working no worries.

 

I'm using the standard way of defining the TextSymbol Object as according to the API Documentation, and it states you can use halo, but it seems to ignore it, even though when i look at the object in the code, it has correctly parsed it.

 

I also tried including the 'LabelingInfo' in the LayerDefinition JSON, and set showLabels: true when i create the Map and it seems to ignore that also. (which states in the API Documentation that it will work for featureLayers)

 

var symbol = new esri.symbol.TextSymbol({
                "type": "esriTS",
                "color": [
                 52,
                 52,
                 52,
                 255
                ],
                "backgroundColor": null,
                "borderLineColor": null,
                "borderLineSize": null,
                "verticalAlignment": "bottom",
                "horizontalAlignment": "left",
                "rightToLeft": false,
                "angle": 0,
                "xoffset": 0,
                "yoffset": 0,
                "kerning": true,
                "haloColor": [
                 255,
                 255,
                 255,
                 255
                ],
                "haloSize": 1,
                "font": {
                    "family": "Arial",
                    "size": 8,
                    "style": "normal",
                    "weight": "bold",
                    "decoration": "none"
                }
        });

var renderer = new esri.renderer.SimpleRenderer(symbol);
var labelLayer = new esri.layers.LabelLayer("label1", { mode: "dynamic" });
labelLayer.addFeatureLayer(featureLayer, renderer, "{ObjectName}");
mapObj.addLayer(labelLayer);

 

 

"labelingInfo": [
        {
    "labelPlacement": "esriServerPointLabelPlacementAboveRight",
        "where": null,
        "labelExpression": "[ObjectName]",
        "useCodedValues": true,

 

 

not using dynamic layer...as you can see i'm getting no halo.. and placement is always top right regardless.

its barely even usable in its current state in my opinion. i know there is probably a 'css' workaround for the halo.. but i'd prefer a nicer solution

 

using Dynamic service layer (static testing).. labels seem fine.

another quirk is you notice the roughness of the symbol when using Dynamic Service Layer...,

compared to the manual specification of the symbol in the featureLayer.. odd..

Outcomes