| | |
| | | _siteLayer: new GraphicsLayer(), |
| | | layuiLayer: null, |
| | | layuiLadate: null, |
| | | tabIndex: 0, |
| | | |
| | | // 保留添加实体图层的变量 |
| | | addEntitys: null, |
| | | entitysData: [], |
| | | |
| | | |
| | | // 用来存储区域名称 |
| | | globalRegionName: null, |
| | | |
| | | // 用来区域得最大最小经纬度 |
| | | currentDrawing: [], |
| | | |
| | | // 存储新增点,线,面,数据的地方 |
| | | polygonData: [], |
| | |
| | | |
| | | //当前处警员是否已有电子围栏 |
| | | isEngineer: false, |
| | | |
| | | //当前处警员是否有位置信息 |
| | | isPosition: true, |
| | | |
| | | // 用来记录巡逻区域或者巡逻路线的下标的 |
| | | patrolIndex: 0, |
| | |
| | | this._map = options.map; |
| | | objThis = this; |
| | | |
| | | //创建图层 |
| | | this.addEntitys = new GraphicsLayer({ |
| | | id: 'addEntitys' |
| | | }); |
| | |
| | | //删除电子围栏点击事件 |
| | | $(".mapBtn .delete").click(function() { |
| | | //需选中电子围栏,然后进行删除 |
| | | if (that.isChecked) { |
| | | that.addPolygonEntitys.clear(); |
| | | 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) {} |
| | | 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.isEngineer = false; |
| | | } else { |
| | | layui.use('layer', function() { |
| | | layui.layer.msg('请先选中需要删除的电子围栏'); |
| | | } |
| | | }) |
| | | } |
| | | that.addPolygonEntitys.clear(); |
| | | //修改围栏状态 |
| | | that.isEngineer = false; |
| | | }) |
| | | }) |
| | | |
| | | //新增电子围栏 |
| | | $('.mapBtn .insert').click(function() { |
| | | if (that.isPosition) { |
| | | if (that.isEngineer) { |
| | | layui.use('layer', function() { |
| | | layui.layer.msg('已存在电子围栏'); |
| | | }) |
| | | } else { |
| | | layui.use('layer', function() { |
| | | layui.layer.msg('请开始划分电子围栏'); |
| | | }) |
| | | that.polygonFlag = true; |
| | | } |
| | | if (that.isEngineer) { |
| | | layui.use('layer', function() { |
| | | layui.layer.msg('已存在电子围栏'); |
| | | }) |
| | | } else { |
| | | layui.use('layer', function() { |
| | | layui.layer.msg('当前处警员无位置信息,不能划分电子围栏'); |
| | | layui.layer.msg('请开始划分电子围栏'); |
| | | }) |
| | | that.polygonFlag = true; |
| | | } |
| | | }) |
| | | |
| | |
| | | var lttd = that.getQueryStringByKey('wd'); |
| | | anumber = that.getQueryStringByKey('code'); |
| | | realname = that.getQueryString('name'); |
| | | console.log(lgtd, 1111); |
| | | //如果处警员的位置信息存在 |
| | | 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])]); |
| | | } |
| | | } |
| | | |
| | | //获取当前处警员的电子围栏信息 |
| | | $.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 { |
| | | //如果无电子围栏信息,则提示请编辑电子围栏信息 |
| | | //编辑好电子围栏信息后,将当前处警员的电子围栏信息保存到数据库 |
| | | that.newElectronicFenceId = null; |
| | | //that.polygonFlag = true; |
| | | that.newElectronicFenceId = anumber; |
| | | } |
| | | that.isEngineer = true; |
| | | that.addPolygon(that.addPolygonEntitys, entityArr); |
| | | } else { |
| | | //如果无电子围栏信息,则提示请编辑电子围栏信息 |
| | | //编辑好电子围栏信息后,将当前处警员的电子围栏信息保存到数据库 |
| | | that.newElectronicFenceId = null; |
| | | that.newElectronicFenceId = anumber; |
| | | } |
| | | } |
| | | }) |
| | | } else { |
| | | //当前处警员没有位置信息,则默认定位到市中心位置 |
| | | that.isPosition = false; |
| | | } |
| | | } |
| | | }) |
| | | |
| | | //调用点击事件 |
| | | that.clickHand(); |
| | |
| | | |
| | | //将数据存入数据库 |
| | | $.ajax({ |
| | | url: that |
| | | .pathUrl + '/enclosure/enclosure/insertes', |
| | | url: that.pathUrl + '/enclosure/enclosure/insertes', |
| | | type: 'POST', |
| | | dataType: 'JSON', |
| | | data: { |
| | |
| | | routeInfo: dataStr |
| | | }, |
| | | success: function(result) { |
| | | if (result.code == 200) {} |
| | | if (result.code == 200) { |
| | | layui.use('layer', function() { |
| | | layui.layer.msg('新增电子围栏成功!') |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | |
| | | // 鼠标点击事件 |
| | | clickHand: function() { |
| | | var that = this; |
| | | |
| | | var self = this; |
| | | self._map.onClick = mapClick; |
| | | |
| | |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | return Widget; |
| | | }); |