AnsweredAssumed Answered

adding new geometry to featurelayer but doesn't save

Question asked by tamimicg on May 21, 2015
Latest reply on May 21, 2015 by kenbuja

Dear all,

 

i am trying to add polylin, point geometry to feature layer but its not saving in the database. actually data is stored in oracle spatial and i am publishing featurelayer from arcgis server.

 

after i add geometry it adds but when i refresh it disappear another thing when i add geometry i check in oracle it doesn't insert

 

here is following code please check it

 

<!DOCTYPE html>

<html>

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <!--The viewport meta tag is used to improve the presentation and behavior of the samples

      on iOS devices-->

    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">

    <title>Landuse</title>

 

    <link rel="stylesheet" href="http://js.arcgis.com/3.13/dijit/themes/claro/claro.css">

    <link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css">

    <style>

      html, body {

        height: 100%;

        width: 100%;

        margin: 0;

        padding: 0;

        overflow:hidden;

      }

      #header {

        border:solid 2px #462d44;

        background:#fff;

        color:#444;

        -moz-border-radius: 4px;

        border-radius: 4px;

        font-family: sans-serif;

        font-size: 1.1em

        padding-left:20px;

      }

      #map {

        padding:1px;

        border:solid 2px #444;

        -moz-border-radius: 4px;

        border-radius: 4px;

      }

      #rightPane {

        border:none;

        padding: 0;

        width:228px;

      }

      .templatePicker {

        border: solid 2px #444;

      }

    </style>

 

    <script src="http://js.arcgis.com/3.13/"></script>

    <script>

      var map;

      var _public = {};

     

      require([

        "esri/map",

        "esri/toolbars/draw",

        "esri/toolbars/edit",

        "esri/graphic",

        "esri/config",

        "esri/layers/ArcGISDynamicMapServiceLayer",

        "esri/layers/ImageParameters",

        "esri/layers/FeatureLayer",

 

        "esri/symbols/SimpleMarkerSymbol",

        "esri/symbols/SimpleLineSymbol",

        "esri/symbols/SimpleFillSymbol",

 

        "esri/dijit/editing/TemplatePicker",

 

        "dojo/_base/array",

        "dojo/_base/event",

        "dojo/_base/lang",

        "dojo/parser",

        "dijit/registry",

 

        "dijit/layout/BorderContainer", "dijit/layout/ContentPane",

        "dijit/form/Button", "dojo/domReady!"

      ], function(

        Map, Draw, Edit, Graphic, esriConfig,

        ArcGISDynamicMapServiceLayer,

        ImageParameters,

        FeatureLayer,

        SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol,

        TemplatePicker,

        arrayUtils, event, lang, parser, registry

      ) {

        parser.parse();

 

        // refer to "Using the Proxy Page" for more information:  https://developers.arcgis.com/javascript/jshelp/ags_proxy.html

        esriConfig.defaults.io.proxyUrl = "/proxy/";

       

        // This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications.

        esriConfig.defaults.geometryService = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

       

        map = new Map("map", {

            sliderOrientation : "horizontal"

          });

         

          var imageParameters = new ImageParameters();

          imageParameters.format = "jpeg"; //set the image type to PNG24, note default is PNG8.

 

          //Takes a URL to a non cached map service.

          var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://192.168.100.72:6080/arcgis/rest/services/ksa_bound/MapServer", {

            "opacity" : 0.5,

            "imageParameters" : imageParameters

          });

         

        map.addLayer(dynamicMapServiceLayer);

       

        map.on("layers-add-result", initEditing);

       

        var landusePointLayer = new FeatureLayer("http://192.168.100.72:6080/arcgis/rest/services/ksa_cities_fl/MapServer/0", {

          mode: FeatureLayer.MODE_SNAPSHOT,

          outFields: ["*"]

        });

        var landuseLineLayer = new FeatureLayer("http://192.168.100.72:6080/arcgis/rest/services/ksa_mot_roads/FeatureServer/0", {

          mode: FeatureLayer.MODE_SNAPSHOT,

          outFields: ["*"]

        });

        var landusePolygonLayer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/FeatureServer/9", {

          mode: FeatureLayer.MODE_SNAPSHOT,

          outFields: ["*"]

        });

 

        map.addLayers([landusePointLayer, landuseLineLayer, landusePolygonLayer]);

 

       

       

        function initEditing(evt) {

          console.log("initEditing", evt);

          _public._kabevt=evt;

          // var map = this;

      var currentLayer = null;

          var layers = arrayUtils.map(evt.layers, function(result) {

            return result.layer;

          });

          _public._kablayers=layers;

          console.log("layers", layers);

 

          var editToolbar = new Edit(map);

          editToolbar.on("deactivate", function(evt) {

            currentLayer.applyEdits(null, [evt.graphic], null);

            console.log("mkabeer",currentLayer );

            _public._kabcurrentLayer=currentLayer.applyEdits(null, [evt.graphic], null);

          });

 

         

         

          arrayUtils.forEach(layers, function(layer) {

            var editingEnabled = false;

            layer.on("dbl-click", function(evt) {

              event.stop(evt);

              if (editingEnabled === false) {

                editingEnabled = true;

                editToolbar.activate(Edit.EDIT_VERTICES , evt.graphic);

              } else {

                currentLayer = this;

                editToolbar.deactivate();

                editingEnabled = false;

              }

            });

 

            layer.on("click", function(evt) {

              event.stop(evt);

              if (evt.ctrlKey === true || evt.metaKey === true) {  //delete feature if ctrl key is depressed

                layer.applyEdits(null,null,[evt.graphic]);

                currentLayer = this;

                editToolbar.deactivate();

                editingEnabled=false;

              }

            });

          });

 

          var templatePicker = new TemplatePicker({

            featureLayers: layers,

            rows: "auto",

            columns: 2,

            grouping: true,

            style: "height: auto; overflow: auto;"

          }, "templatePickerDiv");

 

          templatePicker.startup();

 

          var drawToolbar = new Draw(map);

 

          var selectedTemplate;

          templatePicker.on("selection-change", function() {

            if( templatePicker.getSelected() ) {

              selectedTemplate = templatePicker.getSelected();

            }

            switch (selectedTemplate.featureLayer.geometryType) {

              case "esriGeometryPoint":

                drawToolbar.activate(Draw.POINT);

                break;

              case "esriGeometryPolyline":

                drawToolbar.activate(Draw.POLYLINE);

                break;

              case "esriGeometryPolygon":

                drawToolbar.activate(Draw.POLYGON);

                break;

            }

          });

 

          drawToolbar.on("draw-end", function(evt) {

             console.log(evt);

            drawToolbar.deactivate();

            editToolbar.deactivate();

            var newAttributes = lang.mixin({}, selectedTemplate.template.prototype.attributes);

            console.log("newAttributes", newAttributes)

            var newGraphic = new Graphic(evt.geometry, null, newAttributes);

            console.log("newGraphic", newGraphic)

            selectedTemplate.featureLayer.applyEdits([newGraphic], null, null);

            _public._kabselectedTemplate=selectedTemplate;

          });

        }

      });

    </script>

  </head>

  <body class="claro">

    <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="gutters:true, design:'headline'" style="width:100%;height:100%;">

      <div data-dojo-type="dijit/layout/ContentPane"  id="header" data-dojo-props="region:'top'">Use ctrl or cmd + click on graphic to delete.  Double click on graphic to edit vertices. </div>

      <div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>

      <div id="rightPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'right'">

        <div id="templatePickerDiv"></div>

      </div>

    </div>

  </body>

</html>

 

 

here is the console example it shows KSA_MOT_ROADS_ID: 13033

newGraphic Object {geometry: Object, symbol: null, attributes: Object, infoTemplate: undefined, declaredClass: "esri.Graphic"…}_count: 1_extent: Object_graphicsLayer: Object_layer: Object_offsets: Array[1]_shape: Objectattributes: ObjectIGDS_CLASS: nullIGDS_COLOR: nullIGDS_GRAPHIC_GROUP: nullIGDS_STYLE: nullIGDS_WEIGHT: nullKSA_MOT_ROADS_ID: 13033__proto__: Objectgeometry: Object_path: 0cache: Objectpaths: Array[1]spatialReference: Objecttype: "polyline"__proto__: ObjectinfoTemplate: undefinedsymbol: null__proto__: Object

 

Thanks

Kabeer

Outcomes