南昌市物联网技防平台-前端
Administrator
2021-05-07 14e02654e0545ee69456d64aef2f35c7c219d708
public/map/widgets/securityMap/SecurityMap.js
@@ -3,18 +3,18 @@
 * @Version: 1.0
 * @Author: yangsx
 * @Date: 2019-12-09 19:01:40
 * @LastEditors: song
 * @LastEditTime: 2021-02-25 13:59:29
 * @LastEditors: yangsx
 * @LastEditTime: 2019-12-14 14:44:57
 */
define([
    "dojo",
    "dojo/_base/declare",
    "dojo/_base/lang",
    "base/BaseWidget",
    "dojo/text!widgets/SecurityMap/template.html",
    "dojo/text!widgets/securityMap/template.html",
    "base/AppEvent",
    "base/ConfigData",
    "widgets/realTimePolice/config",
    "widgets/securityMap/config",
    "dojo/dom",
    "dojo/dom-construct",
    "dojo/dom-attr",
@@ -31,8 +31,12 @@
    "esri/tasks/query",
    "esri/tasks/QueryTask",
    "esri/Color",
    "esri/toolbars/edit",
    "esri/graphic",
    "esri/geometry/Point",
    "esri/geometry/Polyline",
    "esri/geometry/Polygon",
    "esri/geometry/Extent",
    "esri/tasks/FeatureSet",
    "esri/renderers/HeatmapRenderer",
    "esri/symbols/SimpleLineSymbol",
@@ -55,9 +59,8 @@
    "esri/layers/ImageParameters",
    "esri/geometry/geometryEngine",
    "esri/dijit/PopupTemplate",
    "widgets/SecurityMap/FlareClusterLayer_v3",
    "dojo/domReady!",
    "widgets/realTimePolice/LayUIDataTable"
    "widgets/securityMap/FlareClusterLayer_v3",
    "dojo/domReady!"
], function(
    dojo,
    declare,
@@ -83,8 +86,12 @@
    Query,
    QueryTask,
    Color,
    Edit,
    Graphic,
    Point,
    Polyline,
    Polygon,
    Extent,
    FeatureSet,
    HeatmapRenderer,
    SimpleLineSymbol,
@@ -112,42 +119,32 @@
    var Widget = declare([BaseWidget], {
        widgetName: "SecurityMap",
        label: "处警队伍管理",
        templateString: template,
        _map: null,
        objThis: null,
        // 现场图层
        _siteLayer: new GraphicsLayer(),
        layuiLayer: null,
        layuiLadate: null,
        tabIndex: 0,
        // 保留添加实体图层的变量
        addEntitys: null,
        entitysData: [],
        // 是否派发保安的 文字
        treatmentIndex: null,
        securityFlag: false,
        editParentInd: null,
        // 存储新增点,线,面,数据的地方
        polygonData: [],
        polygonFlag: false,
        editToolbar: null,
        addPolygonEntitys: null,
        addLineEntitys: null,
        // 所有的面图层
        entityPolygonAll: null,
        //是否选中电子围栏区域
        isChecked: false,
        // 用来存储区域名称
        globalRegionName: null,
        //当前处警员是否已有电子围栏
        isEngineer: false,
        // 用来区域得最大最小经纬度
        currentDrawing: [],
        // 巡逻区域或者巡逻路线的描述
        routeOrRegionDescribe: null,
        //是否可编辑
        isEdit: false,
        // 用来记录巡逻区域或者巡逻路线的下标的
        patrolIndex: 0,
@@ -158,201 +155,575 @@
        y: 0,
        offset: null,
        moveThis: null,
        //编辑工具激活后为true
        editToolbarStatus: false,
        //基础路径
        //pathUrl: "http://localhost:89",
        pathUrl: "https://web.byisf.com/api/blade-jfpts",
        // 电子围栏需要新增的Id
        newElectronicFenceId: null,
        // 新增路线时,派发人员,人员名称,以及人员id
        peopleRealName: null,
        pepleRealId: null,
        anumber: null,
        realname: null,
        //存放聚合实体
        clusterLayer: null,
        constructor: function(options, srcRefNode) {
            debugger;
            console.log("option=" + options);
            this._map = options.map;
            objThis = this;
            this.addEntitys = new GraphicsLayer({ id: 'addEntitys' });
            //创建图层
            this.addEntitys = new GraphicsLayer({
                id: 'addEntitys'
            });
            // 添加点面线的图层
            this.addPolygonEntitys = new GraphicsLayer({ id: 'addPolygonEntitys' });
            this.addPolygonEntitys = new GraphicsLayer({
                id: 'addPolygonEntitys'
            });
            // 添加线的图层
            this.addLineEntitys = new GraphicsLayer({
                id: 'addLineEntitys'
            });
            // 添加所有图层的地方
            this.entityPolygonAll = new GraphicsLayer({ id: 'entityPolygonAll' });
            this.entityPolygonAll = new GraphicsLayer({
                id: 'entityPolygonAll'
            });
            this._map.addLayer(this.addEntitys);
            this._map.addLayer(this.addPolygonEntitys);
            this._map.addLayer(this.addLineEntitys);
            this._map.addLayer(this.entityPolygonAll);
        },
        startup: function() {
            objThis._map.addLayer(objThis._siteLayer);
            var that = this;
            // 保安出警管理表格中点击事件
            $('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody').off('click', 'input').on('click', 'input', function(event) {
                event.stopPropagation();
                var lgtd = Number($(this).parent().parent().attr('lgtd'));
                var lttd = Number($(this).parent().parent().attr('lttd'));
                var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({ wkid: 4326 })); //根据输入坐标信息找地图上的点
                that.newElectronicFenceId = null;
                that._map.centerAndZoom(position, 18); //缩放,10是缩放级别,可以自定义,数值越大缩放越大
                var graphic = that.entityPolygonAll.graphics;
                for (var i = 0; i < graphic.length; i++) {
                    if (graphic[i].objId.id == $(this).attr('resultid')) {
                        if (graphic[i].geometry.rings[0].length > 0) {
                            that.polygonFlag = false;
                            that.electronicFence();
                            that.activateToolbar(graphic[i]);
            //删除电子围栏点击事件
            $(".mapBtn .delBtn").click(function() {
                if (!that.isEngineer) {
                    layui.use('layer', function() {
                        layui.layer.msg('请先新增电子围栏信息!')
                    })
                    return;
                }
                //需选中电子围栏,然后进行删除
                layer.confirm('是否确认删除', {
                    btn: ['确定', '取消'], //按钮
                    title: false
                }, function() {
                    //删除数据库数据
                    $.ajax({
                        url: that.pathUrl + '/enclosure/enclosure/deleteByAnumber',
                        type: 'POST',
                        dataType: 'JSON',
                        data: {
                            anumber: anumber
                        },
                        success: function(result) {
                            if (result.code == 200) {
                                layui.use('layer', function() {
                                    layui.layer.msg('删除电子围栏成功!')
                                })
                            }
                        }
                    })
                    that.addPolygonEntitys.clear();
                    //修改围栏状态
                    that.isEngineer = false;
                })
            })
            //新增电子围栏
            $('.mapBtn .insBtn').click(function() {
                //修改按钮样式
                $("#insertEngineeringMap").css("color", "#3385FF")
                    //判断
                if (that.isEngineer) {
                    layui.use('layer', function() {
                            layui.layer.msg('已存在电子围栏');
                        })
                        //新增按钮颜色改回
                    $("#insertEngineeringMap").css("color", "#757575");
                } else {
                    layui.use('layer', function() {
                        layui.layer.msg('请开始划分电子围栏');
                    })
                    that.polygonFlag = true;
                }
            })
            //编辑电子围栏
            $('.mapBtn .editBtn').click(function() {
                if (!that.isEngineer) {
                    layui.use('layer', function() {
                        layui.layer.msg('请先新增电子围栏信息!')
                    })
                    return;
                }
                $("#editEngineeringMap").css("color", "#3385FF");
                //修改为可编辑状态
                that.isEdit = true;
                layui.use('layer', function() {
                    layui.layer.msg('点击电子围栏图形即可编辑');
                })
            })
        },
        //根据key 取value值
        getQueryStringByKey: function(key) {
            return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
        },
        //带有中文的解码
        getQueryString: function(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURI(r[2]);
            return null;
        },
        //页面打开后,获取参数数据
        open: function() {
            var that = this;
            //获取父页面传过来的参数
            var lgtd = that.getQueryStringByKey('jd');
            var lttd = that.getQueryStringByKey('wd');
            anumber = that.getQueryStringByKey('code');
            realname = that.getQueryString('name');
            //如果处警员的位置信息存在
            if (lgtd != null && lgtd != "") {
                //所在位置标记
                that.addPoint(that.addEntitys, lgtd, lttd, './images/security.png');
            }
            //获取当前处警员的电子围栏信息
            $.ajax({
                url: this.pathUrl + '/enclosure/enclosure/selectEnclosureDetail',
                type: 'GET',
                dataType: 'JSON',
                data: {
                    anumber: anumber
                },
                success: function(result) {
                    //如果已有电子围栏信息,展示出围栏区域,并且可以编辑
                    if (result.code == 200) {
                        if (JSON.stringify(result.data) != "{}") {
                            var entityArr = [];
                            var coordinate = result.data.coordinate.match(/\(([^)]*)\)/).toString();
                            var a = coordinate.indexOf("(");
                            var b = coordinate.indexOf(")");
                            coordinate = coordinate.substring(a + 1, b) + "";
                            if (coordinate && coordinate != '') {
                                coordinate = coordinate.split(',');
                                for (var i = 0; i < coordinate.length; i++) {
                                    entityArr.push([Number(coordinate[i].split(' ')[0]), Number(coordinate[i].split(' ')[1])]);
                                }
                            }
                            that.isEngineer = true;
                            that.addPolygon(that.addPolygonEntitys, entityArr);
                        } else {
                            layui.use('layer', function() {
                                layui.layer.msg('请开始划分电子围栏');
                            })
                            that.polygonFlag = true;
                            that.newElectronicFenceId = graphic[i].objId;
                            //如果无电子围栏信息,则提示请编辑电子围栏信息
                            //编辑好电子围栏信息后,将当前处警员的电子围栏信息保存到数据库
                            that.newElectronicFenceId = null;
                            that.newElectronicFenceId = anumber;
                        }
                    }
                }
            })
            $('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody').off('click', 'tr').on('click', 'tr', function(event) {
                event.stopPropagation();
                var lgtd = Number($(this).attr('lgtd'));
                var lttd = Number($(this).attr('lttd'));
                var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({ wkid: 4326 })); //根据输入坐标信息找地图上的点
            //调用点击事件
            that.clickHand();
                that._map.centerAndZoom(position, 18); //缩放,10是缩放级别,可以自定义,数值越大缩放越大
                var snumber = $(this).attr('term-snumber');
                var url = './popup/html/personnel-information-management.html?id=' + code;
                layui.use('layer', function() {
                    that.layuiLayer = layui.layer;
                    that.layuiLayer.config({
                        extend: 'myskin/personnel-information-management.css'
                    });
                    that.layuiLayer.close(that.layuiLayer.index);
                    that.layuiLayer.open({
                        title: '保安人员信息',
                        type: 2,
                        shadeClose: true,
                        shade: false,
                        maxmin: false, //开启最大化最小化按钮
                        area: ['400px', '220px'],
                        offset: 'auto',
                        skin: 'personnel-information-management',
                        content: url,
                        closeBtn: 1,
                    });
                })
            })
        },
        open: function() {
            var that = this;
            debugger;
            $.ajax({
                url: '/api/blade-jfpts/alarm/alarm/listAll?',
                type: 'get',
                dataType: 'JSON',
                success: function(data) {
                    var datas = data.data;
                    for (var i = 0; i < datas.length; i++) {
                        datas[i].x = Number(datas[i].jd);
                        datas[i].y = Number(datas[i].wd);
            //鼠标右击事件
            document.getElementById('mainMapWidget').onmousedown = function(event) {
                //去除系统默认右键功能
                document.oncontextmenu = function() {
                        //alert("当前页面不能使用右键!");
                        return false;
                    }
                    debugger;
                    that.flareClusterLayer(datas);
                    //event.preventDefault();
                if (event.button == 2) {
                    if (that.polygonFlag == true) {
                        if (that.polygonData.length >= 2) {
                            // 勾画最后一个点
                            var normalizedVal = webMercatorUtils.xyToLngLat(event.mapPoint.x, event.mapPoint.y);
                            that.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                            // 声明空字符串,存储数据
                            var dataStr = '';
                            var data = null;
                            if (that.patrolIndex == 1) {
                                that.addPolyline(that.addPolygonEntitys, that.polygonData);
                                // 获取数据
                                data = that.addPolygonEntitys.graphics[0].geometry.paths[0];
                            } else {
                                that.addPolygon(that.addPolygonEntitys, that.polygonData);
                                // 获取数据
                                data = that.addPolygonEntitys.graphics[0].geometry.rings[0];
                            }
                            // 组装数据
                            for (var i = 0; i < data.length; i++) {
                                dataStr += (data[i][0] + ' ' + data[i][1] + ',');
                            }
                            dataStr = dataStr.substring(0, dataStr.length - 1);
                            //将数据存入数据库
                            $.ajax({
                                url: that.pathUrl + '/enclosure/enclosure/insertes',
                                type: 'POST',
                                dataType: 'JSON',
                                data: {
                                    aname: realname,
                                    anumber: anumber,
                                    routeInfo: dataStr
                                },
                                success: function(result) {
                                    if (result.code == 200) {
                                        layui.use('layer', function() {
                                                layui.layer.msg('新增电子围栏成功!')
                                            })
                                            //清除点信息
                                        that.polygonData = [];
                                        //新增按钮颜色改回
                                        $("#insertEngineeringMap").css("color", "#757575");
                                        //清空线图层信息
                                        that.addLineEntitys.clear();
                                        //修改电子围栏数据状态
                                        that.isEngineer = true;
                                        //修改电子围栏选中状态
                                        that.isChecked = false;
                                        //修改电子围栏编辑状态
                                        that.polygonFlag = false;
                                    }
                                }
                            })
                        }
                    }
                }
            });
        },
        close: function() {
            }
        },
        // 鼠标点击事件
        clickHand: function() {},
        //聚合图层事件
        flareClusterLayer: function(datas) {
            debugger;
        clickHand: function() {
            var that = this;
            var self = this;
            self._map.onClick = mapClick;
            var preClustered = false;
            var displaySingleFlaresAtCount = 10;
            var areaDisplayMode = "";
            // var allData = JSON.parse(DATA);
            // DataManager.setData(allData);
            //init the layer, more options are available and explained in the cluster layer constructor
            that.clusterLayer = new FlareClusterLayer({
                id: "flare-cluster-layer",
                spatialReference: new esri.SpatialReference({ "wkid": 4326 }),
                subTypeFlareProperty: "facilityType",
                singleFlareTooltipProperty: "name",
                displaySubTypeFlares: true,
                displaySingleFlaresAtCount: displaySingleFlaresAtCount,
                flareShowMode: "mouse",
                preClustered: preClustered,
                clusterRatio: 75,
                clusterAreaDisplay: areaDisplayMode,
                clusteringBegin: function() {
                    console.log("clustering begin");
                },
                clusteringComplete: function() {
                    console.log("clustering complete");
            //点击事件
            function mapClick(evt) {
                //坐标格式转换
                var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
                var y = self._map.toMap({
                    spatialReference: '4326',
                    type: "point",
                    x: evt.screenPoint.x,
                    y: evt.screenPoint.y,
                });
                // 编辑中的
                if (self.polygonFlag == true) {
                    if (self.polygonData.length == 0) {
                        self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                        self.addPoint(self.addPolygonEntitys, normalizedVal[0], normalizedVal[1]);
                    } else if (self.polygonData.length == 1) {
                        self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                        self.addPolyline(self.addPolygonEntitys, self.polygonData);
                        return;
                    } else if (self.polygonData.length > 1) {
                        self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                        self.addPolygon(self.addPolygonEntitys, self.polygonData);
                    }
                } else { // 不在编辑中
                    if (evt.graphic) { // 点击在图形上
                        // 保存当前点击得图形
                        // self.currentDrawing = evt.graphic;
                        that.isChecked = true;
                        //self.modifyPolygon();
                        //进入编辑状态
                        //self.activateToolbar(evt.graphic);
                    } else { // 点击不在图形上
                        //修改电子围栏选中状态
                        that.isChecked = false;
                        self.modifyPolygon()
                    }
                    if (that.isEdit) {
                        that.isChecked = true;
                        self.modifyPolygon();
                        //进入编辑状态
                        self.activateToolbar(evt.graphic);
                    }
                }
            }
            // 鼠标移动监听事件
            $(document).off('mousemove').mousemove(function(ev) {
                var oEvent = ev || event;
                //鼠标移动,提示语
                var oDiv1 = document.getElementById('securityMapTips1');
                var oDiv2 = document.getElementById('securityMapTips2');
                var oDiv3 = document.getElementById('securityMapTips3');
                var oDiv4 = document.getElementById('securityMapTips4');
                //新增电子围栏提示语
                if (self.polygonFlag == true) {
                    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                    var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
                    if (self.polygonData.length == 0) {
                        oDiv1.style.left = oEvent.clientX + scrollLeft + 15 + 'px';
                        oDiv1.style.top = oEvent.clientY + scrollTop + 'px';
                        oDiv1.style.display = 'block';
                    }
                    if (self.polygonData.length == 1) {
                        oDiv1.style.display = 'none';
                        oDiv2.style.left = oEvent.clientX + scrollLeft + 15 + 'px';
                        oDiv2.style.top = oEvent.clientY + scrollTop + 'px';
                        oDiv2.style.display = 'block';
                    }
                    if (self.polygonData.length > 1) {
                        oDiv2.style.display = 'none';
                        oDiv3.style.left = oEvent.clientX + scrollLeft + 15 + 'px';
                        oDiv3.style.top = oEvent.clientY + scrollTop + 'px';
                        oDiv3.style.display = 'block';
                    }
                    //已经有一个点或以上
                    if (self.polygonData.length >= 1) {
                        //鼠标移动,上个点和当前点之间画线
                        //临时的线数据
                        var tempLineData = [];
                        //鼠标当前点的数据
                        var normalizedVal = webMercatorUtils.xyToLngLat(oEvent.originalEvent.mapPoint.x, oEvent.originalEvent.mapPoint.y);
                        //获取面数据
                        var polygonArr = self.polygonData;
                        //上个点的数据
                        var prevPointArr = polygonArr[self.polygonData.length - 1];
                        //封装数据
                        tempLineData.push([prevPointArr[0], prevPointArr[1]]);
                        tempLineData.push([normalizedVal[0], normalizedVal[1]]);
                        console.log(tempLineData, 123);
                        //画线
                        self.addLine(self.addLineEntitys, tempLineData);
                    }
                } else {
                    oDiv3.style.display = 'none';
                }
                //编辑电子围栏提示语
                if (that.editToolbarStatus) {
                    $("#securityMapTips4").css("width", "220px");
                    $("#securityMapTips4").css("height", "40px");
                    $("#securityMapTips4").css("line-height", "20px");
                    $("#securityMapTips4 span").css("line-height", "20px");
                    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                    var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
                    oDiv4.style.left = oEvent.clientX + scrollLeft + 15 + 'px';
                    oDiv4.style.top = oEvent.clientY + scrollTop + 'px';
                    oDiv4.style.display = 'block';
                } else {
                    oDiv4.style.display = 'none';
                }
            })
        },
        /**
         * 新增线图层
         * @param {*} entitys  addPolygonEntitys
         * @param {*} path  坐标点的数据
         */
        addPolyline: function(entitys, path) {
            entitys.clear();
            var polylineSymbol = new SimpleLineSymbol();
            polylineSymbol.color = [255, 0, 0, 1];
            polylineSymbol.width = 2;
            var polyline = new Polyline({
                "paths": [path],
                "spatialReference": {
                    "wkid": 4326
                }
            });
            //set up a class breaks renderer to render different symbols based on the cluster count. Use the required clusterCount property to break on.
            var defaultSym = new PictureMarkerSymbol("./images/ceshi.png", 32, 32).setOffset(0, 15);
            var renderer = new ClassBreaksRenderer(defaultSym, "clusterCount");
            var xlSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 32, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([200, 52, 59, 0.8]), 1), new dojo.Color([250, 65, 74, 0.8]));
            var lgSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 28, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([41, 163, 41, 0.8]), 1), new dojo.Color([51, 204, 51, 0.8]));
            var mdSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 24, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([82, 163, 204, 0.8]), 1), new dojo.Color([102, 204, 255, 0.8]));
            var smSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 22, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([230, 184, 92, 0.8]), 1), new dojo.Color([255, 204, 102, 0.8]));
            renderer.addBreak(0, 19, smSymbol);
            renderer.addBreak(20, 150, mdSymbol);
            renderer.addBreak(151, 1000, lgSymbol);
            renderer.addBreak(1001, Infinity, xlSymbol);
            entitys.add(new Graphic(polyline, polylineSymbol));
        },
            that.clusterLayer.setRenderer(renderer); //use standard setRenderer.
            //set up a popup template
            var template = new PopupTemplate({
                title: "{name}",
                fieldInfos: [
                    { fieldName: "facilityType", label: "Facility Type", visible: true },
                    { fieldName: "postcode", label: "Post Code", visible: true },
                    { fieldName: "isOpen", label: "Opening Hours", visible: true }
                ]
        /**
         * 新增线图层
         * @param {*} entitys  addLineEntitys
         * @param {*} path  坐标点的数据
         */
        addLine: function(entitys, path) {
            entitys.clear();
            var polylineSymbol = new SimpleLineSymbol();
            //var polylineSymbol = new SimpleMarkerSymbol();
            polylineSymbol.color = [255, 0, 0, 1];
            polylineSymbol.width = 2;
            polylineSymbol.style = "short-dot";
            var polyline = new Polyline({
                "paths": [path],
                "spatialReference": {
                    "wkid": 4326
                }
            });
            //clusterLayer.infoTemplate = template;
            that._map.infoWindow.titleInBody = false;
            entitys.add(new Graphic(polyline, polylineSymbol));
        },
            that._map.addLayer(that.clusterLayer);
            //var data = DataManager.getData();
            that.clusterLayer.addData(datas);
        //编辑电子围栏(多边形)
        modifyPolygon: function() {
            var self = this;
            if (self.editToolbar != null) {
                //获取当前的多边形数据
                var polygon = self.editToolbar.getCurrentState();
                //释放编辑后
                self.editToolbar.deactivate();
                self.editToolbar = null;
                // 声明空字符串,存储数据
                var dataStr = '';
                // 获取数据
                var data = polygon.graphic.geometry.rings[0];
                // 组装数据
                for (var i = 0; i < data.length; i++) {
                    dataStr += (data[i][0] + ' ' + data[i][1] + ',');
                }
                dataStr = dataStr.substring(0, dataStr.length - 1);
                //更新电子围栏数据
                $.ajax({
                    url: this.pathUrl + '/enclosure/enclosure/updatee',
                    type: 'POST',
                    dataType: 'JSON',
                    data: {
                        anumber: anumber,
                        routeInfo: dataStr
                    },
                    success: function(result) {
                        if (result.code == 200) {
                            layui.use('layer', function() {
                                layui.layer.msg('电子围栏修改成功!');
                            })
                            $("#editEngineeringMap").css("color", "#757575");
                            $("#securityMapTips4").css("display", "none");
                            self.isEdit = false;
                            self.editToolbarStatus = false;
                        }
                    }
                })
            }
        },
        activateToolbar: function(graphic) {
            var that = this;
            that.editToolbarStatus = true;
            var tool = 0;
            this.editToolbar = new Edit(this._map);
            // if (registry.byId("tool_move").checked) {
            tool = tool | Edit.MOVE;
            // }
            // if (registry.byId("tool_vertices").checked) {
            tool = tool | Edit.EDIT_VERTICES;
            // }
            // if (registry.byId("tool_scale").checked) {
            tool = tool | Edit.SCALE;
            // }
            // if (registry.byId("tool_rotate").checked) {
            tool = tool | Edit.ROTATE;
            // }
            // enable text editing if a graphic uses a text symbol
            // if ( graphic.symbol.declaredClass === "esri.symbol.TextSymbol" ) {
            tool = tool | Edit.EDIT_TEXT;
            // }
            var options = {
                allowAddVertices: true,
                allowDeleteVertices: true,
                uniformScaling: true
            };
            this.editToolbar.activate(tool, graphic, options);
        },
        clearLayer: function() {
            var that = this;
            that._map.removeLayer(that.clusterLayer);
            that.clusterLayer = null;
        close: function() {},
        // 创建实体图层
        createEntitys: function(entitys, entityContent, name, item, lgtd, lttd, outlineColors) {
            var symbol = new esri.symbol.PictureMarkerSymbol(outlineColors, 33, 48);
            symbol.name = name;
            var pt = new Point(lgtd, lttd, new esri.SpatialReference({
                wkid: 4326
            }));
            pt.entityData = item;
            var graphic = new esri.Graphic(pt, symbol);
            entitys.add(graphic);
            entityContent.push(item);
        },
        //在地图上新增点
        addPoint: function(entitys, lgtd, lttd, img) {
            if (img == undefined) {
                var symbol = new esri.symbol.PictureMarkerSymbol('./images/point.png', 22, 22);
            } else {
                var symbol = new esri.symbol.PictureMarkerSymbol(img, 22, 22);
            }
            var pt = new Point(lgtd, lttd, new SpatialReference({
                wkid: 4326
            }));
            var graphic = new esri.Graphic(pt, symbol);
            entitys.add(graphic);
        },
        //绘制多边形
        addPolygon: function(entitys, rings) {
            entitys.clear();
            var polygonSymbol = new SimpleFillSymbol();
            polygonSymbol.color = [24, 255, 243, 0.411];
            var polygon = new Polygon({
                "rings": [rings],
                "spatialReference": {
                    "wkid": 4326
                }
            });
            entitys.add(new Graphic(polygon, polygonSymbol));
        }
    });
    return Widget;
});