This sample shows how to add a VectorTileLayer from a JSON style object by setting the layer's style property. Esri's mid-century vector tile style is simplified and the VectorTileLayer is added from the modified JSON object. Esri also offers a set of vector basemaps with different styles.
It also demonstrates how to change the layout and paint properties for specified style-layers in the VectorTileLayer's currentStyleInfo.style in 2D MapView at runtime without having to reload the entire VectorTileLayer. This can be done by using the setStyleLayer() and setPaintProperties() methods.
The ArcGIS Vector Tile Style Editor is used to design custom vector basemaps and it takes advantage of the methods mentioned above.
// change the font case for the countries(Admin0 point/large) labels layer
document.getElementById("layoutButton").addEventListener("click", () => {
// get the layout properties for the Admin0 point/large layer
const styleLayer = vtLayer.getStyleLayer("Admin0 point/large");
// change the text-transform layout property
styleLayer.layout["text-transform"] = styleLayer.layout["text-transform"] == "uppercase" ? "none" : "uppercase";
vtLayer.setStyleLayer(styleLayer);
});
// change the fill-color for the water(Marine area/1) layer
document.getElementById("paintButton").addEventListener("click", () => {
// get the paint properties for the marine area/1 layer
const paintProperties = vtLayer.getPaintProperties("Marine area/1");
// change the fill-color paint property for the layer.
paintProperties["fill-color"] = paintProperties["fill-color"] == "#93CFC7" ? "#0759C1" : "#93CFC7";
vtLayer.setPaintProperties("Marine area/1", paintProperties);
});