Last active
August 3, 2023 07:42
-
-
Save RalucaNicola/e1b45c108140898cc3b6d4535236cde9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to get layer id: | |
view.map.layers.forEach(l => console.log(l.id, l.title)) | |
// replace the id below with the one you want to modify: | |
const layer = view.map.findLayerById("189b5aed56b-layer-75"); | |
// clone renderer, modify it and set it back on the layer: | |
let renderer = layer.renderer.clone(); | |
renderer.uniqueValueInfos.forEach(info=>{ | |
const symLayer = info.symbol.symbolLayers.getItemAt(0) | |
if (symLayer.size > 0) { | |
symLayer.anchor = "bottom" | |
info.symbol.callout = { | |
type: "line", | |
size: 3, | |
color: "#219E5A", | |
border: { | |
color: [0, 0, 0, 0] | |
} | |
}; | |
info.symbol.verticalOffset = { | |
screenLength: 30, | |
maxWorldLength: 5000, | |
minWorldLength: 0 | |
} | |
} | |
} | |
) | |
layer.renderer = renderer; | |
// set labeling info and enable labels on the layer: | |
layer.labelingInfo = [{ | |
symbol: { | |
type: "label-3d", | |
symbolLayers: [{ | |
type: "text", | |
material: { | |
color: [255, 255, 255] | |
}, | |
background: { | |
color: "#219E5A" | |
}, | |
font: { | |
size: 10, | |
} | |
}] | |
}, | |
labelExpressionInfo: { | |
expression: "Replace($feature.Name, '*', TextFormatting.NewLine)" | |
}, | |
where: "Category = 'Label'" | |
}] | |
layer.labelsVisible = true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment