Search code examples
labellayerarcgis-js-api

ESRI Js API 4.15 : FeatureLayer labels are not visible on all features


I'm trying to show labels on a point FeatureLayer, the label is not visible for just one Feature, But it become visible when the map change scale, is there any explanation?

Here is my code:

 "renderer": {
                    "type": "class-breaks",
                    "field": "nums",
                    "classBreakInfos": [
                        {
                            "minValue": 0,
                            "maxValue": 9,
                            "label": " < 10",
                            "symbol": {
                                "type": "picture-marker",
                                "url": "./assets/picto/nums/vert.png",
                                "width": 30,
                                "height": 50
                            }
                        },
                        {
                            "minValue": 10,
                            "maxValue": 19,
                            "label": " 10 à 19",
                            "symbol": {
                                "type": "picture-marker",
                                "url": "./assets/picto/nums/orange.png",
                                "width": 30,
                                "height": 50
                            }
                        },
                        {
                            "minValue": 20,
                            "maxValue": 1000000,
                            "label": " > 19",
                            "symbol": {
                                "type": "picture-marker",
                                "url": "./assets/picto/nums/rouge.png",
                                "width": 30,
                                "height": 50
                            }
                        }
                    ]
                },
"labelingInfo": [
                    {
                        "labelExpressionInfo": {
                            "expression": "$feature.nums"
                        },
                        "labelPlacement": "center-center",
                        "symbol": {
                            "type": "text",
                            "color": "black",
                            "haloColor": "white",
                            "xoffset": -2,
                            "yoffset": 13,
                            "font": {
                                "size": 7,
                                "family": "sans-serif",
                                "weight": "bolder"
                            }
                        }
                    }
                ]

I joined a picture of the FeatureLayer labels problem:

FeatureLayer labels


Solution

  • Base on you definition, you are using the default deconflict strategy ("static"). Sometimes when overlaps occurs the overlapped label is not showed. Depends on the situation this strategy make sense or not.

    You could try "none" option, to turn off deconfliction and you should not have that issue. It seems it might be what you are looking for.

    labelClass.deconflictionStrategy = "none";
    

    ArcGIS JS API - LabelClass deconflictionStrategy