How do i customize layer labels from a MapImageLayer? current layer code below
var resultsLabelLayer = new MapImageLayer({
url: url,
sublayers: [{
id: 1,
labelsVisible: true,
visible: true,
labelingInfo: [{
labelExpression: "[CONST]",
labelPlacement: "always-horizontal",
symbol: new TextSymbol({
color: [ 255,255,255,1 ],
font: {
size: 16,
weight: "bolder"
}
})
}]
}]
});
map.add(resultsLabelLayer);
Using this and adding the layer to the map yields no labels or the layer being drawn
Solved! Go to Solution.
And it still doesn't work?
Have you enabled the Supports Dynamic Layers for the map service?
Evon,
This sample shows some of the parameters that can be customized:
MapImageLayer - label sublayer features | ArcGIS API for JavaScript 4.2
That is exactly the document I was following, still to no success to display any labels. There may be more to this but I get no error in console.
Evon,
Strange it works fine for me.
I updated my question with the code I am using, I tried a hard refresh on the browser still no use. I do have a layer on my service that is not enabled however I am not sure if that is causing an issue. i disabled the other layers and only have visible set to the layer i want to label.
Hello Evon,
You snippet does not have the id property in it. All the sample snippet has the id value, which will provide the information on which sublayer, the changes needs to be applied to.
Have you tried adding the "id" property?
Warm Regards
thanks for your observation, I have left it out while testing something but I have added it in my code snippet above.
And it still doesn't work?
Have you enabled the Supports Dynamic Layers for the map service?
Is this mandatory in order to change the labels client side?
I think that MapImageLayer is using the functionality provided by Dynamic Layer of the Map Service. Because of which you are able to change the symbology, label and other details of a MapService. It is similar to LayerDrawingOptions in 3.x version. I couldn't find any documentation though. I checked the service used in the sample and they have the Dynamic Layer support enabled.
Its worth a try.