View
32
Download
0
Category
Preview:
Citation preview
Kristian Ekenes & MohanRaj Balumuri
ArcGIS API for JavaScript: Using Arcade with your Apps
Session Goals
Overview of Arcade
Using Arcade in the ArcGIS JS API
Take your apps to the next level
What is Arcade?
• An expression language primarily designed for ArcGIS web maps and web scenes• ArcGIS Pro• Runtime SDKs• JavaScript API• Web apps
• Used to provide extra bit of logic to make a map more dynamic
Arcade Purpose
Arcade is NOT intended to be a Full Programming / Scripting Language• Goal : Lightweight and Simple• Equivalent to a Spreadsheet Cell Calculation
Not a replacement for Python for geoprocessing and Automation
Input ValuesArcade
ExpressionResult Value
Unit Conversion
Why another language?
ArcGIS: Make, Share, Anywhere
ArcGIS: Make, Share, Anywhere - Challenges
Mobile and Native Apps
Browser based Apps
• Size of Executable• Security
• Native Access
• Page Size• Security
• XSS• No Binaries
Traditional Development / Scripting Languages
Arcade Goals
Portable• Write an Expression in Pro, have it run in a Browser, or on a Device
Secure• Ensure that Expressions or Scripting do not compromise Security
Lightweight• Most requirements for Scripts and Expressions are Lightweight. The
language should be small, and fast
Geospatial• Scripts should treat Geospatial as First Class Members
Language Overview
Arcade : Language FeaturesDesigned for Simple Expressions
• Single Line - Implicit Returns • Case Insensitive Language• Dictionary Syntax for Field Access
Has Language Features to Support more Complex Scripts• Type System• Implicit and Explicit Type Casting• Flow Control Statements: IF, FOR• Variable Declaration and Assignments• User Defined Functions
Arcade Scripts run and return a value. They are self contained and cannot alter their environment.
Profiles
Global Variables and Profiles
Popup
LabelingFeature Z
Visualization
Attribute RuleConstrain
Attribute RuleValidation
Attribute RuleCalculation
Field Calculate*
Not implemented in the JS API*Not publicly documented
Exploring Profiles and Functions in the Playground
Arcade and the ArcGIS JS API
ESRI JS APIVersion 3.27
ESRI JS APIVersion 4.10
ESRI JS API : Arcade Expressions
Expression Properties are set as Literal Strings
Arcade Interpreter will Execute valueExpression for every Feature
var renderer = {type: “class-breaks”,valueExpression: "( $feature.TOT_VOTES / $feature.REG_VOTERS ) * 100",valueExpressionTitle: "Voter turnout"classBreakInfos: [ ... ],
};
var labelClass = new LabelClass({labelExpressionInfo: {
expression: "$feature.STATION_NAME"},labelPlacement: "below-right",minScale: 2500000
});nameClass.symbol = new TextSymbol();// set the label class to the feature layerfeatureLayer.labelingInfo = [ labelClass ];
Arcade Expressions can be used For Labeling
Practicalities: Scripts in Script
Scripts within Scripts• Lots of String Escaping.• Embed Script in HTML using MIME type text/plain
<script type="text/plain" id="myScript">Proper($feature.CityName)
</script>...var arcadescript = document.getElementById(“myScript").text;
New FeaturesSince last Dev Summit
FeatureSet Functions
Represents a connection to a set of Features in memory or in a serverLazy, iterable, and chainable
var publicLandFeatures = FeatureSetByName($map, "public lands", ["class"], true); var sensitiveAreas = Filter(publicLandFeatures, "class = 'sensitive'"); Count( Intersects( sensitiveAreas, $feature ) );
Demos
Generate Arcade for your usersTake your apps to the next level
Demos
Generate Arcade for your users
Generate Arcade for your users
Expression sharing
Future
Adding Functions & Profiles
Identifying common operations and use cases
• Let us know what you need!
Finding Arcade Resources
ResourcesFor Arcade Documentation https://developers.arcgis.com/arcade
Playgroundhttps://developers.arcgis.com/arcade/playground/
Using Arcade with JS APIhttps://developers.arcgis.com/javascript/latest/guide/arcade/index.html
Blogs and Postshttps://www.esri.com/arcgis-blog/?s=#&tag=arcade-expressions
Arcade Expression sharing repohttps://github.com/Esri/arcade-expressions/
Complete answersand select “Submit”
Scroll down to find the feedback section
Select the session you attended
Download the Esri Events app and find your event
Please Take Our Survey on the App
Recommended