SOLVED: [esri.views.LayerViewManager] Failed to create layerview for layer title:'GeoJSON' on ArcGIS 4.21.x

1459
1
11-15-2021 02:28 PM
ironmaskito
New Contributor III

I am unable to see the geojson layer when I switch between map view and scene view after I apply edits to a GeoJSONLayer. I am seeing the following errors, and the layer doesn't get rendered: 

react_devtools_backend.js:2540 [esri.views.3d.layers.GeoJSONLayerView3D] #resolve() Failed to resolve layer view (layer title: 'GeoJSON', id: '17d25b1be7e-layer-4') TypeError: s.equals is not a function
at s (projectExtentUtils.js:5)
at FeatureLikeLayerView3D.js:5

react_devtools_backend.js:2540 [esri.views.LayerViewManager] Failed to create layerview for layer title:'GeoJSON', id:'17d25b1be7e-layer-4' of type 'geojson'

The errors happen after I apply edits to an existing GeoJSONLayer. I think I have found the problem: when ApplyEdits() is called, certain properties belonging to the feature are changed, even though I didn't change them. The below pic shows a comparison of the same feature before (right) and after (left) applyEdits is called. You can see the fullExtent property has changed, which is referenced in the code throwing the error.

---------------------

SOLUTION: So after applyEdits the fullExtent property of the modified layer gets changed, which causes an error upon toggling mapView/sceneView. The solution is to store the original fullExtent and reassign it to the layer after its features have been updated. This seems like a bug since I don't see it documented anywhere.

---------------------

problem with applyEdits features.png

Here is the code where I call applyEdits() on a geojsonlayer

 

 

 

 

 

 

  private handleHighlightEvent(layer: GeoJSONLayer): void {
   const query = layer.createQuery();
    query.where = "featureId = '" + this.id + "'"; // select the feature by attribute

    layer.queryFeatures(query).then((results) => {
      const features = results.features;
      this.updateFeatures(features, layer);
    });
  }

  private updateFeatures(results, layer: GeoJSONLayer)
  {
    if (results.length >  0)
    {
      const updatedGraphics = {
        updateFeatures: []
      }

      results.forEach((feature) => {
        const isStyleChanged: boolean = feature.attributes[UNIQUE_VALUE_RENDERER_FIELD] != this.style;
        feature.attributes[UNIQUE_VALUE_RENDERER_FIELD] = this.style; // apply an alternate style to feature
        if (isStyleChanged) // if style changed update graphic
        {
          updatedGraphics.updateFeatures.push(feature); // update feature
        }
      })

      if (updatedGraphics.updateFeatures.length > 0){
        this.applyEditsToGeoJSON(updatedGraphics, layer); // causes error when toggling 
      }

    }
  }

  private applyEditsToGeoJSON(params, layer: GeoJSONLayer)
  {
    layer.applyEdits(params);
  }

 

 

 

 

 

 

 

Tags (2)
0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

This sounds like a legitimate bug. Will test locally and create an issue to fix it. I will let you know when it is fixed. I also want to point out that GeoJSONLayer will not be editable by default starting at version 4.22. You will need to set its editingEnabled property to true to edit your geojson features.

 

-Undral