geospatial-sdk / core/lib / computeMapContextDiff
computeMapContextDiff()
ts
function computeMapContextDiff(nextContext, previousContext): MapContextDiff
The following logic is produced by identifying layers in both context and determining whether they have been added, removed, changed or reordered.
Identifying layers to determine if they have been added/removed/reordered is done like so:
- For layers with an
id
property, use non-strict equality on it (e.g. '2' and 2 are equivalent); - For layers without
id
, compute a hash of their base properties excluding theextras
property
Determining whether layers have changed is done like so:
- For layers with an
id
property, the value of theversion
field is compared; if values are different (using non-strict equality), then the layer is considered to have changed; otherwise it is considered to have remained the same - For layers without
id
, a full hash is computed including theextras
property; this means that a layer which only had changes in itsextras
object will not be considered added/removed, but only changed
Parameters
• nextContext: MapContext
• previousContext: MapContext