Skip to content

Javascript API 4.0 Impact

James Rae edited this page Oct 25, 2016 · 3 revisions

General

All collections now use the same interface. In particular, functions add() and addMany()

The API has moved away from events (there are still a few), and now focuses on watches.

// 3.x approach
layer.on('update-start', () => spinner.show());

// 4.x approach
layer.watch('loadStatus', newValue => { if (newValue === 'loading') { spinner.show(); }});

All properties in esriConfig.defaults have been moved up to the esriConfig object. esriConfig.defaults.io is now esriConfig.request

Object constructors no longer support raw JSON as an argument. Now use the static class method fromJSON()

In general, asynchronous methods will now return a Promise instead of a Deferred

Map

layers property instead of split between feature-based and image based layers. The basemap is no longer in the stack and is in it's own special world.

addLayer() and addLayers() are now layers.add(), layers.addMany(), or map.addMany()

reorderLayer() is now reorder()

Map View

The map no longer draws anything on the screen. It is merely the data structure that holds layers together. Rendering is done by a new object called MapView.

This object contains all the visual properties that used to be found in Map, such as extent, center, height, width.

New boolean properties ready and updating replaces the old events on the map.

There is now a Zoom widget; the zoom buttons are no longer baked into the map.

The BasemapGallery, Scalebar, and OverviewMap widgets are not yet implemented.

Layers

Property loadStatus with values can be used with the watch() function to track loading, updating, and errors. This will replace the events we currently listen to (load, update-start, update-end, error).

Property loadError gives additional info about any errors that occur (as there is no longer an event parameter).

Layer objects themselves are Promises. Each layer instance exposes .then() which fires after the layer loads (what "loads" means is currently unclear. I believe it may be the equivalent of loaded in API 3, as in the layer has initialized but has not pulled any data yet).

There is now a cancelLoad() method which will be useful for our Trash button

Layer View

Similar to the Map View, layers have views as well. Of note, it has an updating property that appears to be analagous to old update-start and update-end events.

Feature Layer

Features are now stored in a Collection property called source, rather than graphics array.

For layers hosted in ArcGIS Server 10.3+, there is no longer a server defined maximum record count. It is now a hard maximum of 16,000 points and 4,000 lines or polygons.

There is no more snapshot or onDemand mode. The layer manages the downloading of data automatically. As of v4.0 it appears to be a greedy version of onDemand, with more performance updates coming in later versions.

Dynamic Layer

Now called MapImageLayer

All information on the constituant layers is now in a property called sublayers. There is no more visibleLayers array.

layerDrawingOptions are not yet supported. We used this to adjust transparency of child layers

Tile Layer

Now called TileLayer

WMS Layer

It is not supported at 4.0. ESRI plans to add it later.

Group Layer

A new class that may offer some support for our attempts to support FeatureServer and ArcGIS Online (see Issue 580)

Utilities

graphicsUtils is currently not implemented. We use this to determine the extent of a set of graphics.

graphic.getShape() is not supported, nor are there plans to support it. We use this to re-arrange the z-order of graphics in the map; particularly useful for the highlighting module.

CartographicLineSymbol is no longer supported. Not sure what this means if we encounter a layer with that type of symbol.

Summary of Missing Things Required by the Viewer

Not Yet Implemented

  • WMSLayer
  • BasemapGallery
  • OverviewMap
  • Scalebar
  • graphicsUtils
  • MapImageLayer.layerDrawingOptions

No Longer Supported

  • graphic.getShape()

See Functionality Matrix and Migration Guide for more info.

Timelines

Taken from Version 4.1 Release Announcement Comments:

3.x will be covered by technical support through 2020. Our goal is to get close [to feature parity] by Q3 2017, and finish other critical functionality towards the end of 2017