Changes for SketchViewModel at 4.10
SketchViewModel has significant breaking changes at 4.10 that will allow you to accomplish same functionality with less code. For example, we condensed over 20 events into 4 events without losing functionality. This change should make it easier and more straightforward to maintain your code to respond to these events. The following list covers all the breaking changes.
Property changes
SketchViewModel.layer is now a required property. Additionally, only graphics added to this layer are recognized as candidates for updates by SketchViewModel. When SketchViewModel is initialized, you must set the layer property as shown below:
The SketchViewModel.graphic
property was removed. Use the SketchViewModel.createGraphic or SketchViewModel.updateGraphics properties to get references to graphics being created or updated.
Method changes
The parameters for the SketchViewModel.update() method were changed. The update
method now accepts an array of graphics for the first parameter, instead of a single graphic. This also means users can update multiple graphics simultaneously. An optional second parameter, updateOptions
, was added to allow users to modify the default behavior of SketchViewModel during an update operation.
At 4.9 and previous versions of the API, developers were required to add custom application logic to identify a specific graphic for an update operation. This was typically done by utilizing MapView's click event, along with MapView.hittest() to identify the candidate graphic to be updated. At 4.10, this logic was integrated into the default behavior of SketchViewModel, so less custom logic is needed in your application. If you have a specific workflow that conflicts with this default behavior, you can still opt out by setting the SketchViewModel.updateOnGraphicClick property to false
.
Events changes
At 4.9, SketchViewModel emitted more than 20 events depending on whether a user was creating or updating a graphic. At 4.10, we condensed these into four distinct events: create, update, undo and redo. See Sketch update validation sample and Query statistics by geometry sample.
Sample updates
The following samples were updated to reflect these changes.