arcgis api for js4.x 图层要素的增删改---使用服务地址的/applyEdits直接进行删除

添加新要素到图层

javascript 复制代码
_addGeo(){
        cosnt self = this
        let url = https://......./featurelayer/某某某图层/3
        let geo = 你新绘制的图形
        let attributes = 你新绘制图形的属性信息
        let addingGraphics = Graphic({
               geometry:geo,
               attributes:attributes
        })
        const pro = self._addToLayer(url , JSON.stringify(addingGraphics).replaceAll("\\", ""))
        Promise.all([pro]).then((result) => {
            const response = JSON.parse(result)
            if (response.addResults != undefined && response.addResults.length > 0) {                   
                self.$message.success("保存成功");
            } else {
                self.$message.error("保存失败,请检查服务。");
            }
            self.mapClear();
        })
},

_addToLayer(url, param) {
            var formData = new FormData();
            formData.append("f", "pjson");
            formData.append("adds", param);
            return new Promise((resolve, reject) => {
                const A= "A"
                const B= "B"
                $.ajax({
                    url: `${url}/applyEdits`,
                    type: "post",
                    async: true,
                    data: formData,
                    processData: false,
                    contentType: false,
                    headers: { //头部信息添加到这里
                        A: A,
                        B: B,
                    },
                    success: function (response) {
                        resolve(response)
                    },
                    error: function (e) {
                        reject(null)
                    },
                });
            })
        },
javascript 复制代码
deletegeo(){
        cosnt self = this
        let url = https://......./featurelayer/某某某图层/3
        let feat= 你要删除的要素
let objs = [feat.attributes.objectid]  //objs是数组,可以删除多个。objectid是服务的标识字段值
 let pro1 = self._delFromLayer(url, objs)
Promise.all([pro1]).then((result) => {
                const response1 = JSON.parse(result[0])
                if (response1.deleteResults != undefined && response1.deleteResults.length > 0 ) {
                    self.$message.success("删除成功。");
                } else {
                    self.$message.error("删除失败,请检查服务。");
                }
            })

},

_delFromLayer(url, param) {
            const self = this
            var formData = new FormData();
            formData.append("f", "pjson");
            formData.append("deletes", param);
            return new Promise((resolve, reject) => {
                const A= "A"
                const B= "B"
                $.ajax({
                    url: `${url}/applyEdits`,
                    type: "post",
                    async: true,
                    data: formData,
                    processData: false,
                    contentType: false,
                    headers: {
                        A: A,
                        B: B
                    },
                    success: function (response) {
                        resolve(response)
                    },
                    error: function (e) {
                        reject(null)
                    },
                });
            })
        },
相关推荐
jiushidt4 天前
ArcGIS Pro Add‑in 打包流程详解
arcgis·c#·.net·arcgispro
蓝悦无人机4 天前
《地面站软件开发》-第2章ArcGIS Maps SDK for Qt 改变视角
arcgis·上位机·地面站·qml·qt6·qt quick·天地图
bug嘛我经常写5 天前
MIKE21结合ArcGIS制作随时间变化的降水文件(.dfs2)-笔记
经验分享·笔记·arcgis
paiooo6 天前
用 XML 保存 LLM 会话得到高可读性会话
arcgis
Q一件事6 天前
ArcGIS中TypeError: can‘t multiply sequence by non-int of type ‘str‘错误
前端·javascript·arcgis
萧行之7 天前
Observable Plot 源码深度解析——1 认识 Observable Plot
arcgis
ノBye~7 天前
Codex CLI使用记录
arcgis
2601_962381589 天前
ArcGIS+Python+AI赋能高标准农田建设项目审计提质增效
python·arcgis·ai·高标准农田审计·大数据审计
飞鹰@四海9 天前
Claude Code 报「与 Windows 版本不兼容」——完整排查与修复指南
arcgis
非科班Java出身GISer11 天前
ArcGIS JS 基础教程(30):体元系列 - VoxelSlice 体元切片
arcgis·arcgis js 体元图层·arcgis js 体元·arcgis 体元图层·arcgis js 体元切片·arcgis 体元切片·arcgis 体元