Select to view content in your preferred language

Editor Widget and TypeScript - can layerInfo accept GeoJSON layers?

1783
7
Jump to solution
11-18-2020 12:37 PM
yuruiology
New Contributor II

Hi - we are trying to use the Editor widget (JS API 4.17) in our web app however it seems it automatically enables editing for all editable FeatureLayers and GeoJSON Layers. We want to disable add/edit for all the GeoJSON Layers - according to the documentation we could do that by providing `layerInfos` with the right flags - however, `layerInfos.layer` seems to only allow `FeatureLayer` (in TS typings and as described in the documentation) but not other types.

Force casting GeoJSONLayer type to "FeatureLayer" seems to work but it definitely isn't ideal - I'm wondering if this is an issue with the documentation & TS typings, or if there is a better way to do this?

Thanks!

Tags (3)
1 Solution

Accepted Solutions
HeatherGonzago
Esri Contributor

Your workaround would be the best suggestion for now. 

View solution in original post

7 Replies
HeatherGonzago
Esri Contributor

The doc is correct it is currently only implemented for FeatureLayer types. I have added this to our list of enhancements for the Editor. Thanks for the feedback.

yuruiology
New Contributor II

Thanks - the code seems to work if we force a GeoJSON layer into `layerInfo` - is there a better workaround? 

HeatherGonzago
Esri Contributor

Your workaround would be the best suggestion for now. 

Esri_PrajaktaPatil
New Contributor

Hello Heather,

I am new to the community. I am working on the geoJSON layer. I have added an editor to edit and add features to this layer. after edit, I need to save these edits or newly added features to GeoJson  so I added one button and on click event, I am trying to send it to an external API to update my existing GEOJSON. But I am not able to access my geojson layer on button click event.Please help me with this.I appriciate your responce.

Thank you!

0 Kudos
dndhm
by
New Contributor

Is there any update on this? It's not mentioned as a known limitation of the GeoJSONLayer in your docs and converting GeoJSONLayers to FeatureLayers just for this functionality is a large amount of work, especially when every other required piece of functionality is there.

0 Kudos
dndhm
by
New Contributor

And, unsurprisingly, when incorrectly casting GeoJSONLayer as FeatureLayer to force LayerInfo to accept it, you run into errors further down the line. This may have worked as a workaround in the specific example given by the OP, but this is not an acceptable workaround in general.

0 Kudos
HeatherGonzago
Esri Contributor

Hi, you should be able to edit GeoJSONLayers using the editor. I don't know the extent to how you are working with the layers and how you are adding them, (ie. feature collection or referenced by URL), but here is an app showing how to use a GeoJsonLayer referenced by URL and accessed in the Editor. The documentation needs to be updated to include this layer type for the Editor.layerInfos. We will make sure to include that in the next doc update.

0 Kudos