ArcGIS 图层上点的编辑

在之前研究ArcGIS由于资料少,研究有点费力,经过努力总算完成。这里有必要记载下

1.绘点 

//图层上点的数组
var datasvalue= [];
dojo.require("dijit.layout.BorderContainer");
        dojo.require("dijit.layout.ContentPane");
        dojo.require("esri.map");
        jQuery(document).ready(function () {
            var Datumelevations;
          //获取后台的点数据信息
            var data = "@Model.JsonList";
          //格式化json串
            var dataJson = data.replace(new RegExp(""", "g"), "\"");
            if (dataJson.length != 0) {
                var json = (new Function("", "return " + dataJson))();
            //遍历取出点信息 自定义数据模型
                $.each(json, function (i, item) {
                    var da = new Object();
                    da.Id = item.ID;
                    da.ProjectId = item.ProjectId;
                    da.ID = i + 1;
                    da.TagName = item.TagName;
                    da.JD = item.JingDu;
                    da.WD = item.WeiDu;
                    da.Workpoint = item.WorkPoint;
                    da.AreaId = item.AreaId
                    da.SHDId = item.SHD_ID;
                    da.LineNo = item.Line_No;
                    da.Status = item.Status == 0 ? "允许" : "未允许";
                    da.TagTypes = item.TagType;
                    da.Datumelevation = item.Datumelevation;
                    da.Measurement = item.Measurement;
                    da.DataRange = item.DataRange;
                    da.IUPR = item.IUPR;
                    da.Usertype = item.Usertype == 0 ? "业主" : "施工单位";
                    da.Detailed = item.Detailed;
                    da.imageurl = item.imageurl;
                    da.Baojing = item.Baojing == 0 ? 0 : 1;
                    datasvalue[i] = da;
                });

2.加点 

//加点
        function addMarker(xx, yy, xs) {
     //该ID是我加的特定属性,方便没有保存的点删除使用
            id = datasvalue.length + j;
            var pt = new esri.geometry.Point(xx, yy, map.spatialReference);
            pt0 = pt;
            var z = "http://" + x + ":" + m + "/Content/Images/tag/" + xs;
            var symbol1 = new esri.symbol.PictureMarkerSymbol(z, 25, 25);
            //要在模版中显示的参数  
            attr = {
                ID: s,
                Id: 0,
                address: "武侯区311号",
                JD: xx,
                WD: yy,
                BH: "",
                LB: types,
                ZT: "",
                GC: "",
                JP: "",
                YH: "",
                XX: "",
                SG: ""
            };
            //模版太长省略
            //创建图像  
            graphic = new esri.Graphic(pt, symbol1, attr, infoTemplate);
            //把图像添加到刚才创建的图层上  
            graphicLayer.add(graphic);
            Arrays.push(graphic);
            j++;
            CloseWaitingDialog();
            setMapCenter(xx, yy, map.getLevel());
        }

3.删除图层上的点

//测点删除方法id为图层上的id,ID为数据库的ID
        function deleteMarker(id, ID) {
            if (ID <= 0) {
                graphicLayer.remove(Arrays[id - 1]);
                map.infoWindow.hide();
            }
            else {
                $.ajax({
                    url: '/Cms/ProjectGIS/Removepoint',
                    data: { ID: ID },
                    type: 'post',
                    success: function (data) {
                        graphicLayer.remove(Arrays[id - 1]);
                        map.infoWindow.hide();
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        window.parent.LoadingUtils.Close();
                    }
                });
            }
        }

 

 

你可能感兴趣的:(GIS)