Announcements

ArcGIS API for JavaScript 3.19 released

The ArcGIS API for JavaScript 3.19 is now available, allowing you to write Arcade expressions for custom visualizations and labels, and to consume vector tiles in any supported ArcGIS spatial reference.

Arcade integration for visualization and labeling

Arcade is a lightweight expression language designed for creating custom content, visualizations, and labels across the ArcGIS platform. In the 3.19 release of the API, Arcade may be used for creating custom data-driven visualizations and labeling. Field values are treated as global variables in Arcade expressions and may be accessed using the following syntax: $feature.FIELD_NAME. Arcade comes equipped with its own library of functions that allow users to do simple math calculations and text formatting.

Visualization

Rather than drive visualizations based on the value of a layer’s field, users now can pass an expression to renderers and visual variables. The expression will execute for each feature, generating a symbol based on the returned value. This is convenient when a service doesn’t have the exact values you need. To leverage Arcade in renderers, you must pass it as a string to the valueExpression property of the renderer or visual variable.

image

The following snippet demonstrates how you can write an Arcade expression showing the share of the vote earned in an election by the winner for each geography in the layer.

 // CANDIDATE1 and CANDIDATE2 are field values
 var arcade = "var votes = [$feature.CANDIDATE1, $feature.CANDIDATE2];"
   // Sum() and Max() are built-in Arcade functions
   + "return ( Max(votes) / Sum(votes) ) * 100;";
 renderer.setVisualVariables([{
   type: "colorInfo",
   valueExpression: arcade,  // valueExpression points to the Arcade expression
   valueExpressionTitle: "Share of winner's votes",
   stops: [ ... ]
 }]);

Labeling

Arcade may also be used to label features in a FeatureLayer. This is handled in the expression property of the labelExpressionInfo object of the LabelClass.

image

The snippet below demonstrates how to label features with only the value of a field in the layer. Remember to use the expression property of the labelExpressionInfo object; the value property will not understand the Arcade expression.

// returns the value of a field in the layer
// the value of this field will be the label for each feature
var arcade = "$feature.STATION_NAME"
// set the arcade expression to the `expression` property of labelExpressionInfo
var labelClass = new LabelClass({
  labelExpressionInfo: {
    expression: arcade
  },
  labelPlacement: "below-right",
  minScale: 2500000
});
nameClass.symbol = new TextSymbol()
// set the label class to the feature layer
featureLayer.setLabelingInfo([ labelClass ]);

Take a look at the Label features using Arcade expressions sample to see examples of various Arcade expressions used in the labeling context.

Arcade is convenient for a number of reasons, including providing the ability to save expressions to layer items and web maps in ArcGIS Online or Portal for ArcGIS. That means expressions can be authored in apps and persisted in webmaps throughout the ArcGIS platform.

Be sure to read the full Arcade documentation for details about its syntax and the Arcade guide page for more examples of its usage within the API.

VectorTileLayer enhancements

This release of the JavaScript API includes support for vector tiles in any ArcGIS-supported spatial reference. You can publish vector tile layers by building packages that can then be published to Portal for ArcGIS or ArcGIS Online. Users then can bring these layers into their web apps.

image

North Korea Missile Azimuthal Equidistant
image

North Korea Missile Web Mercator
image

Check out the 3.19 what’s new for additional information about upgrades to other resources and a more detailed listing of API enhancements. For an overview on what was released with 4.2, check out this blog announcement.

About the authors

20+ years of experience with web mapping. Currently lead project engineer for the ArcGIS API for JavaScript development team at Esri. トレイルランニングをするのが好きです。

Connect:

Kristian is a Product Engineer for the ArcGIS API for JavaScript, focusing on mapping and visualization.

Connect:

Next Article

Make This Dymaxion Globe Ornament Please

Read this article