You are using a browser that is no longer supported. Please use the latest version of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. For more information please see the System Requirements.

Unsupported browser

You are using a browser that is not supported. JavaScript API works on the latest versions of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. Use one of these browsers and provide your feedback through GeoNet, the Esri Community.

  • {i18n.unsupportedBrowser.chrome}
  • Firefox
  • Safari
  • undefined
Loading...

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

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 tiles style is simplified and the VectorTileLayer is added from the modified JSON object. In addition to the above-mentioned, Esri offers a set of vector basemaps with different styles.

It also demonstrates how to change 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 setLayoutProperties() and setPaintProperties() methods that are new at version 4.10.

The ArcGIS Vector Tile Style Editor is used to design custom vector basemaps and it takes advantage of methods mentioned above.

// change the font case for the countries(Admin0 point/large) labels layer
document.getElementById("layoutButton").addEventListener("click", function(){
  // get the layout properties for the Admin0 point/large layer
  const layoutProperties = vtLayer.getLayoutProperties("Admin0 point/large");
  // change the text-transform layout property
  layoutProperties["text-transform"] = layoutProperties["text-transform"] == "uppercase" ? "none" : "uppercase";
  vtLayer.setLayoutProperties("Admin0 point/large", layoutProperties);

// change the fill-color for the water(Marine area/1) layer
document.getElementById("paintButton").addEventListener("click", function(){
  // 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);
});

Sample search results

TitleSample
Loading...