AnsweredAssumed Answered

Automatically update the feature attributes  based on the location(spatial join) concept using javascript

Question asked by mondyagu on Jun 13, 2016

Unable to auto update the specific feature attributes when the feature location is moved from one region to another region?

In the editor tool,taken feature service for editing,so when activate the edit tool,user can edit the feature &move the position from one location to another, the point feature attributes must be changed as per the new layer attributes which are lying in the polygon.

 

this.inherited(arguments);

            this.own(topic.subscribe('mapClickMode/currentSet', lang.hitch(this, 'setMapClickMode')));

            if (this.parentWidget && this.parentWidget.toggleable) {

                this.own(aspect.after(this.parentWidget, 'toggle', lang.hitch(this, function () {

                    this.onLayoutChange(this.parentWidget.open);

                })));

            }

        },

        toggleEditing: function () {

            if (!this.isEdit) {

                var ops = lang.clone(this.settings);

                ops.map = this.map;

                ops.layerInfos = this.layerInfos;

 

                require(['esri/dijit/editing/Editor', 'esri/tasks/QueryTask', 'esri/tasks/query', 'dojo/on'], lang.hitch(this, function (Editor, QueryTask, Query, on) {

                    var task = new QueryTask("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2");

                    var query = new Query();

                    query.returnGeometry = true;

                    query.outFields = ['*'];

 

 

                    this.editor = new Editor({

                        settings: ops

                    }, con);

                    this.editor.startup();

                    //Here lets add event...

                    console.log(this.editor);

                    var self = this;

                    setTimeout(function () {

                        self.editor.editToolbar.on('graphic-click', function (evt) {

                            alert("I ran");

                            console.log(evt);

                             //query.geometry = evt.graphic.geometry;

                            //task.execute(query, function (result) {

                            //  console.log(result);

                            // });

                        });

                               }));

 

 

                this.toggleBTN.set('label', this.i18n.labels.stopEditing);

                this.toggleBTN.set('class', 'danger');

                this.isEdit = true;

                topic.publish('mapClickMode/setCurrent', 'editor');

            } else {

                this.endEditing();

                topic.publish('mapClickMode/setDefault');

            }

        },

        endEditing: function () {

            if (this.editor && this.editor.destroyRecursive) {

                this.editor.destroyRecursive();

            }

            this.toggleBTN.set('label', this.i18n.labels.startEditing);

            this.toggleBTN.set('class', 'success');

            this.isEdit = false;

            this.editor = null;

        },

 

 

        onLayoutChange: function (open) {

            // end edit on close of title pane

            if (!open && this.mapClickMode === 'editor') {

                this.endEditing();

                topic.publish('mapClickMode/setDefault');

            }

        },

        setMapClickMode: function (mode) {

            this.mapClickMode = mode;

            if (mode !== 'editor') {

                this.endEditing();

            }

        },

Outcomes