The new ArcGIS API for JavaScript 4.0 is a “next-generation” release that not only introduces new functionality but is also a fundamental change from 3.x versions. This blog post highlights some of the new functionality and changes that come with the new API.
Why a new API?
Released last May, the ArcGIS API for JavaScript 4.0 is now available for building web apps. This new API is an improvement from the older versions, incorporating new technology while at the same time removing what´s no longer useful. It´s also a major update including fundamental changes. People without experience with previous versions will be best served with this new, redesigned, simplified and clean API, while those familiar with older versions will have to adapt to many changes, such as reorganized modules and packages. Let´s have a look at some things that are brand new in the API:
3D support
The most immediate eye-catching feature is 3D support, following the trend of 3D support through the almost the entire product range. Esri calls the new API’s driving reason for existence “the introduction of 3D capabilities into the world of ArcGIS JavaScript development”.
3D apps are powered by Web Scenes that can include terrain, basemaps, imagery, features, and 3D objects that can be streamed in via tile, feature, image and scene services. 3D maps using web scenes can be authored in ArcGIS Online and Portal for ArcGIS and then consumed in an app by referencing the web map’s ID.
With the API comes added support for 3D scenes: SceneViews display 3D views of a map or Web Scene instance using WebGL (a Web Scene is the core element of 3D mapping across the ArcGIS platform). New layer types and 3D symbology are also supported, as well as Viewpoint and Camera classes, providing the visible extent of a 3D view and the point of view for either 2D or 3D view respectively.
Widgets
API widgets have been built from the ground up with a clean user experience. Each widget’s presentation is separate from its properties, methods, and data. The separation of core logic and presentation makes each widget customizable when working with other frameworks and libraries such as Bootstrap, React, and JQuery. The idea behind the new API is “mobile first”, meaning that design of widgets work great on mobile devices as well as the traditional desktop browser.
New Coding patterns
A new architecture also means new coding patterns. The new API is AMD-only and offers no support for legacy modules. AMD stands for Asynchronous Module Definition, which is a JavaScript API that defines code modules and their dependencies, loading only what you need, resulting in a better performance. A number of new core patters are introduced with the new API, such as a new base class for getting and setting properties values. Better performance is also attained by introducing the promise philosophy, meaning that you can trigger numerous requests at once and then handle them when each is ready.
Choosing a version
Because not all 2D layers and capabilities supported in the 3.x API are supported in 4.0, Esri created an online guide for developers to help them evaluate whether the current 4.x or 3.x release has the desired capabilities. It is part of the new API reference, available at https://developers.arcgis.com/javascript/.