AnsweredAssumed Answered

GeoJSON Edit/Add Feature

Question asked by kawish on Nov 13, 2019
Latest reply on Nov 14, 2019 by odoe

Hi 

I have geojson service but when i use Editor widget to add feature on map. The problem is that feature shows on map after editing but not save into database...

Can any one guide me to solve this problem...

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <title>GeoJSONLayer - 4.13</title>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    </style>

    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.13/esri/themes/light/main.css"
    />
    <script src="https://js.arcgis.com/4.13/"></script>

    <script>
      require([
        "esri/Map",
        "esri/layers/GeoJSONLayer",
        "esri/views/MapView",
          "esri/widgets/Editor"
      ], function(Map, GeoJSONLayer, MapView, Editor) {

        const url =
          "http://localhost:3000/data";

        const geojsonLayer = new GeoJSONLayer({
          url: url
        });

        const map = new Map({
          basemap: "gray",
          layers: [geojsonLayer]
        });

        const view = new MapView({
          container: "viewDiv",
          center: [68.589073, 26.092168],
          zoom: 8,
          map: map
        });

      view.when(() => {

          let editor = new Editor({
            view:view
          })
          view.ui.add(editor, 'top-right')
         
        });
      });
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>

Outcomes