ArcGIS API for JS starter Development series 19 Layers online editing

Source: Internet
Author: User

This article mainly describes the use of the ArcGIS API implementation layer Online editing function module, as follows:

Implementation ideas:

The layer online editing capabilities provided by the Featureserver service released by the 1.arcgis server:

2. Implementation of online editing (deletion), mainly through the front-end Ajax request Background Featureserver service to achieve

(1) Http://120.199.78.138:6080/arcgis/rest/services/dlsde/FeatureServer/0/updateFeatures

void ProcessRequest (HttpContext context) {        = context. request.params["Featureserverurl"];         = Context. request.params["Features"];         = "features=" + features + "&f=json";         = Featureserverurl + "/updatefeatures";         = Postdatatourl (param, url, "application/x-www-form-urlencoded");        Context. Response.Write (ret);}

(2) Http://120.199.78.138:6080/arcgis/rest/services/dlsde/FeatureServer/0/addFeatures

    void ProcessRequest (HttpContext context) {        = context. request.params["Featureserverurl"];         = Context. request.params["Features"];         = "features=" + features + "&f=json";         = Featureserverurl + "/addfeatures";         = Postdatatourl (param, url, "application/x-www-form-urlencoded");        Context. Response.Write (ret);    }

(3) Http://120.199.78.138:6080/arcgis/rest/services/dlsde/FeatureServer/0/deleteFeatures

    void ProcessRequest (HttpContext context) {        = context. request.params["Featureserverurl"];         = Context. request.params["OBJECTID"];         = "where=objectid=" + ID + "&f=json";         = Featureserverurl + "/deletefeatures";         = Postdatatourl (param, url, "application/x-www-form-urlencoded");        Context. Response.Write (ret);        Context. Response.End ();    }

3. Front-End AJAX requests

(1) Add a record:

        varfeatures = []; varREC = {}; Rec.attributes= {};Rec.geometry=DCI.editLayers.geometry;rec.attributes["NAME"] = $ ("#update_name"). Val (); rec.attributes["KIND" = $ ("#update_kind")). Val ();        Features.push (REC); varFeats =json.stringify (features); /*[{"Attributes": {"NAME": "KIND": "4080"}, "geometry": {"type": "Point", "X": 121.29894825018249, "y": 39.72 910692098025, "spatialreference": {"Wkid": 4326}}]*/        varparams = {features:feats, f: "Pjson", Featureserverurl:MapConfig.sdeURL}; $.ajax ({type:"POST",                //dataType: "JSON",Url:getrootpath () + "Handler/addfeaturehandler.ashx", Data:params,//async:false,//SynchronizationSuccessfunction(response, textstatus) {varRET =Json.parse (response); if(Ret.addresults && Ret.addresults[0].success) {Promptdialog ("Prompt", "Add success!"); DCI.editLayers.InitSde ("");                    DCI.editLayers.map.infoWindow.hide (); } Else{Promptdialog ("Prompt", "Add failed!"); }}, Error:function(e) {varError =e; Promptdialog ("Prompt", "Response timed out!"); }            });

(2) Modify a record:

        varfeatures = []; varREC = {}; Rec.attributes= {};rec.attributes["OBJECTID"] =parseint (Objectid); rec.attributes["NAME"] = $ ("#update_name"). Val (); rec.attributes["KIND" = $ ("#update_kind")). Val ();        Features.push (REC); varFeats =json.stringify (features); /*[{"Attributes": {"NAME": "KIND": "4080"}, "geometry": {"type": "Point", "X": 121.29894825018249, "y": 39.72 910692098025, "spatialreference": {"Wkid": 4326}}]*/        varparams = {features:feats, f: "Pjson", Featureserverurl:MapConfig.sdeURL}; $.ajax ({type:"POST",                //dataType: "JSON",Url:getrootpath () + "Handler/updatefeaturehandler.ashx", Data:params,//async:false,//SynchronizationSuccessfunction(response, textstatus) {varRET =Json.parse (response); if(ret.updateresults[0].success) {Promptdialog ("Prompt", "Update succeeded!"); DCI.editLayers.InitSde ("");                    DCI.editLayers.map.infoWindow.hide (); } Else{Promptdialog ("Prompt", "Update failed!"); }}, Error:function(e) {varError =e; Promptdialog ("Prompt", "Response timed out!"); }            });

(3) Delete a record:

      varObjectid =parseint (ID); varparams ={objectid:objectid, Featureserverurl:MapConfig.sdeURL}; $.ajax ({type:"POST",                         //dataType: "JSON",Url:getrootpath () + "Handler/deletefeaturehandler.ashx", Data:params,//async:false,//SynchronizationSuccessfunction(response, textstatus) {varRET =Json.parse (response); if(ret.success) {Promptdialog ("Prompt", "Delete succeeded!"); DCI.editLayers.InitSde ("");                             DCI.editLayers.map.infoWindow.hide (); } Else{Promptdialog ("Prompt", "Delete failed!"); }}, Error:function(e) {varError =e; Promptdialog ("Prompt", "Response timed out!"); }       });

ArcGIS API for JS starter Development series 19 Layers online editing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.