MapImageLayer - label sublayer features
This sample demonstrates how to label features in MapImageLayer sublayers. Labels are applied when the labelsVisible property is set to true
and the labelingInfo property contains at least one LabelClass, which defines the label expression, its placement, and symbol properties.
var layer = new MapImageLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
sublayers: [{
id: 2,
labelsVisible: true,
labelingInfo: [{
labelExpression: "[state_abbr]",
labelPlacement: "always-horizontal",
symbol: new TextSymbol({
color: [ 255,255,255,0.85 ],
font: {
size: 16,
weight: "bolder"
}
}),
minScale: 18500000,
maxScale: 9250000
}, {
labelExpression: "[state_name]",
labelPlacement: "always-horizontal",
symbol: new TextSymbol({
color: [ 255,255,255,0.85 ],
haloColor: "gray",
haloSize: 1,
font: {
size: 14,
weight: "bold"
}
}),
minScale: 9250000,
maxScale: 2400000
}]
}]
});