| New file |
| | |
| | | /* |
| | | * @Description: |
| | | * @Version: 1.0 |
| | | * @Author: yangsx |
| | | * @Date: 2019-12-09 19:01:40 |
| | | * @LastEditors: yangsx |
| | | * @LastEditTime: 2019-12-14 14:44:57 |
| | | */ |
| | | define([ |
| | | "dojo", |
| | | "dojo/_base/declare", |
| | | "dojo/_base/lang", |
| | | "base/BaseWidget", |
| | | "dojo/text!widgets/task/template.html", |
| | | "base/AppEvent", |
| | | "base/ConfigData", |
| | | "widgets/task/config", |
| | | "dojo/dom", |
| | | "dojo/dom-construct", |
| | | "dojo/dom-attr", |
| | | "dojo/dom-style", |
| | | "dojo/on", |
| | | "esri/layers/ArcGISDynamicMapServiceLayer", |
| | | "esri/layers/ArcGISTiledMapServiceLayer", |
| | | "esri/layers/FeatureLayer", |
| | | "controls/tab/TabControl", |
| | | "esri/dijit/SymbolStyler", |
| | | "esri/styles/basic", |
| | | "dojo/_base/array", |
| | | "esri/InfoTemplate", |
| | | "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", |
| | | "esri/symbols/SimpleFillSymbol", |
| | | "esri/symbols/PictureMarkerSymbol", |
| | | "esri/symbols/SimpleMarkerSymbol", |
| | | "esri/SpatialReference", |
| | | "esri/tasks/GeometryService", |
| | | "esri/tasks/ProjectParameters", |
| | | "esri/layers/GraphicsLayer", |
| | | "esri/layers/LabelLayer", |
| | | "esri/symbols/TextSymbol", |
| | | "esri/renderers/SimpleRenderer", |
| | | "esri/renderers/ClassBreaksRenderer", |
| | | "esri/tasks/Geoprocessor", |
| | | "esri/tasks/DataFile", |
| | | "esri/geometry/webMercatorUtils", |
| | | "esri/symbols/Font", |
| | | "esri/geometry/ScreenPoint", |
| | | "esri/layers/ImageParameters", |
| | | "esri/geometry/geometryEngine", |
| | | "esri/dijit/PopupTemplate", |
| | | "widgets/clientManagement/FlareClusterLayer_v3", |
| | | 'dojo/topic', |
| | | "dojo/domReady!" |
| | | ], function ( |
| | | dojo, |
| | | declare, |
| | | lang, |
| | | BaseWidget, |
| | | template, |
| | | AppEvent, |
| | | ConfigData, |
| | | config, |
| | | dom, |
| | | domConstruct, |
| | | domAttr, |
| | | domStyle, |
| | | on, |
| | | ArcGISDynamicMapServiceLayer, |
| | | ArcGISTiledMapServiceLayer, |
| | | FeatureLayer, |
| | | TabControl, |
| | | SymbolStyler, |
| | | basic, |
| | | arrayUtils, |
| | | InfoTemplate, |
| | | Query, |
| | | QueryTask, |
| | | Color, |
| | | Edit, |
| | | Graphic, |
| | | Point, |
| | | Polyline, |
| | | Polygon, |
| | | Extent, |
| | | FeatureSet, |
| | | HeatmapRenderer, |
| | | SimpleLineSymbol, |
| | | SimpleFillSymbol, |
| | | PictureMarkerSymbol, |
| | | SimpleMarkerSymbol, |
| | | SpatialReference, |
| | | GeometryService, |
| | | ProjectParameters, |
| | | GraphicsLayer, |
| | | LabelLayer, |
| | | TextSymbol, |
| | | SimpleRenderer, |
| | | ClassBreaksRenderer, |
| | | Geoprocessor, |
| | | DataFile, |
| | | webMercatorUtils, |
| | | Font, |
| | | ScreenPoint, |
| | | ImageParameters, |
| | | geometryEngine, |
| | | PopupTemplate, |
| | | FlareClusterLayer, |
| | | topic |
| | | ) { |
| | | var Widget = declare([BaseWidget], { |
| | | widgetName: "task", |
| | | label: "分发处置", |
| | | templateString: template, |
| | | _map: null, |
| | | objThis: null, |
| | | _siteLayer: new GraphicsLayer(), |
| | | layuiLayer: null, |
| | | layuiLadate: null, |
| | | tabIndex: 0, |
| | | |
| | | // 保留添加实体图层的变量 |
| | | addEntitys: null, |
| | | addEntitystra: null, |
| | | entitysData: [], |
| | | |
| | | |
| | | // 巡逻区域或者巡逻路线的描述 |
| | | routeOrRegionDescribe: null, |
| | | |
| | | // 用来记录巡逻区域或者巡逻路线的下标的 |
| | | patrolIndex: 0, |
| | | |
| | | // 拖拽 |
| | | isDown: false, |
| | | x: 0, |
| | | y: 0, |
| | | offset: null, |
| | | moveThis: null, |
| | | // 电子围栏需要新增的Id |
| | | newElectronicFenceId: null, |
| | | |
| | | // 新增路线时,派发人员,人员名称,以及人员id |
| | | peopleRealName: null, |
| | | pepleRealId: null, |
| | | constructor: function (options, srcRefNode) { |
| | | this._map = options.map; |
| | | objThis = this; |
| | | |
| | | this.addEntitys = new GraphicsLayer({ |
| | | id: 'addEntitys' |
| | | }); |
| | | this.addEntitystra = new GraphicsLayer({ |
| | | id: 'addEntitystra' |
| | | }); |
| | | |
| | | // 添加点面线的图层 |
| | | this.addPolygonEntitys = new GraphicsLayer({ |
| | | id: 'addPolygonEntitys' |
| | | }); |
| | | // 添加所有图层的地方 |
| | | this.entityPolygonAll = new GraphicsLayer({ |
| | | id: 'entityPolygonAll' |
| | | }); |
| | | |
| | | |
| | | this._map.addLayer(this.addEntitys); |
| | | this._map.addLayer(this.addEntitystra); |
| | | |
| | | |
| | | this._map.addLayer(this.addPolygonEntitys); |
| | | this._map.addLayer(this.entityPolygonAll); |
| | | |
| | | }, |
| | | |
| | | startup: function () { |
| | | |
| | | objThis._map.addLayer(objThis._siteLayer); |
| | | |
| | | |
| | | }, |
| | | |
| | | getQueryStringByKey: function (key) { |
| | | return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1]; |
| | | }, |
| | | location: function (ces) { |
| | | var that = this; |
| | | that.addEntitystra.clear(); |
| | | $.ajax({ |
| | | url: "/api/trar/selectLists?rid=" + ces.rwid + "&uid=" + ces.id, |
| | | type: 'get', |
| | | success: function (res) { |
| | | if (res == "" || res == null){ |
| | | return; |
| | | } |
| | | var baid = res; |
| | | var entityData = ''; |
| | | var entityArr = []; |
| | | entityData = baid.match(/\(([^)]*)\)/); |
| | | if (entityData && entityData != '') { |
| | | entityData = entityData[1].split(','); |
| | | for (var j = 0; j < entityData.length; j++) { |
| | | entityArr.push([Number(entityData[j].split(' ')[0]), Number(entityData[j].split(' ')[1])]); |
| | | } |
| | | |
| | | } |
| | | that.addPolygonAlltra(that.addEntitystra, entityArr); |
| | | that._map.centerAndZoom(new esri.geometry.Point(entityArr[Math.ceil(entityArr.length / 2)][0], entityArr[Math.ceil(entityArr.length / 2)][1], new esri.SpatialReference({wkid: 4326})), 14); |
| | | } |
| | | }) |
| | | }, |
| | | open: function () { |
| | | var that = this; |
| | | topic.subscribe("location", lang.hitch(this, this.location)); |
| | | var baid = decodeURI(that.getQueryStringByKey('baid')); |
| | | var entityData = ''; |
| | | var entityArr = []; |
| | | entityData = baid.match(/\(([^)]*)\)/); |
| | | // 此时result=["(dsfasjfj3124123)", "dsfasjfj3124123"]; |
| | | if (entityData && entityData != '') { |
| | | entityData = entityData[1].split(','); |
| | | console.log(entityData, 1) |
| | | for (var j = 0; j < entityData.length; j++) { |
| | | entityArr.push([Number(entityData[j].split(' ')[0]), Number(entityData[j].split(' ')[1])]); |
| | | // entityArr.push([Number(b[0]), Number(b[1])]); |
| | | } |
| | | |
| | | } |
| | | console.log(entityArr, 2) |
| | | that.addPolygonAll(that.addEntitys, entityArr); |
| | | that._map.centerAndZoom(new esri.geometry.Point(entityArr[Math.ceil(entityArr.length / 2)][0], entityArr[Math.ceil(entityArr.length / 2)][1], new esri.SpatialReference({wkid: 4326})), 14); |
| | | |
| | | }, |
| | | close: function () { |
| | | |
| | | }, |
| | | addPolygonAlltra: function (entitys, rings) { |
| | | // entitys.clear(); |
| | | var graphic = null; |
| | | var polylineSymbol = new SimpleLineSymbol(); |
| | | polylineSymbol.color = "#990707"; |
| | | polylineSymbol.width = 4; |
| | | var polyline = new Polyline({ |
| | | "paths": [rings], |
| | | "spatialReference": { |
| | | "wkid": 4326 |
| | | } |
| | | }); |
| | | graphic = new Graphic(polyline, polylineSymbol) |
| | | entitys.add(graphic); |
| | | }, |
| | | addPolygonAll: function (entitys, rings) { |
| | | // entitys.clear(); |
| | | var graphic = null; |
| | | var polylineSymbol = new SimpleLineSymbol(); |
| | | polylineSymbol.color = [255, 0, 0, 1]; |
| | | polylineSymbol.width = 4; |
| | | var polyline = new Polyline({ |
| | | "paths": [rings], |
| | | "spatialReference": { |
| | | "wkid": 4326 |
| | | } |
| | | }); |
| | | graphic = new Graphic(polyline, polylineSymbol) |
| | | entitys.add(graphic); |
| | | }, |
| | | addPoint: function (entitys, lgtd, lttd, img) { |
| | | var symbol = new esri.symbol.PictureMarkerSymbol(img, 22, 32); |
| | | symbol.xoffset = 0; |
| | | symbol.yoffset = -2; |
| | | var pt = new Point(lgtd, lttd, new SpatialReference({ |
| | | wkid: 4326 |
| | | })); |
| | | var graphic = new esri.Graphic(pt, symbol); |
| | | entitys.add(graphic); |
| | | }, |
| | | /** |
| | | * 添加实体的公共方法 |
| | | * @param {*} entitys 实体类 |
| | | * @param {Array} entityContent 存放每个点详细数据的数组 |
| | | * @param {string} name 实体的名字 |
| | | * @param {*} item 实体数据 |
| | | * @param {*} lgtd 经度 |
| | | * @param {*} lttd 纬度 |
| | | * @param {*} outlineColors 颜色 |
| | | */ |
| | | createEntitys: function (entitys, lgtd, lttd, image) { |
| | | |
| | | var symbol = new esri.symbol.PictureMarkerSymbol(image, 44, 44); |
| | | |
| | | var width = 44; |
| | | var height = 44; |
| | | var pt = new Point(lgtd, lttd, new SpatialReference({ |
| | | wkid: 4326 |
| | | })); |
| | | |
| | | var graphic = new esri.Graphic(pt, symbol); |
| | | |
| | | setInterval(function () { |
| | | if (width >= 60) { |
| | | width = 44; |
| | | height = 44; |
| | | } |
| | | width += 1; |
| | | height += 1; |
| | | symbol.width = width; |
| | | symbol.height = height; |
| | | graphic.setSymbol(symbol) |
| | | entitys.add(graphic); |
| | | }, 50) |
| | | |
| | | }, |
| | | /** |
| | | * 添加闪烁实体的公共方法 |
| | | * @param {*} entitys 实体类 |
| | | * @param {*} lgtd 经度 |
| | | * @param {*} lttd 纬度 |
| | | * @param {*} color 颜色 |
| | | */ |
| | | createTwinkleEntitys: function (entitys, lgtd, lttd, image, color) { |
| | | var symbol = new esri.symbol.PictureMarkerSymbol(image, 64, 64); |
| | | var width = 64; |
| | | var height = 64; |
| | | var pt = new Point(lgtd, lttd, new SpatialReference({ |
| | | wkid: 4326 |
| | | })); |
| | | |
| | | var graphic = new esri.Graphic(pt, symbol); |
| | | |
| | | setInterval(function () { |
| | | if (width >= 80) { |
| | | width = 64; |
| | | height = 64; |
| | | } |
| | | width += 1; |
| | | height += 1; |
| | | symbol.width = width; |
| | | symbol.height = height; |
| | | graphic.setSymbol(symbol) |
| | | entitys.add(graphic); |
| | | }, 50) |
| | | }, |
| | | addPoints: function (entitys, lgtd, lttd, img) { |
| | | var symbol = new esri.symbol.PictureMarkerSymbol(img, 20, 20); |
| | | var pt = new Point(lgtd, lttd, new SpatialReference({ |
| | | wkid: 4326 |
| | | })); |
| | | var graphic = new esri.Graphic(pt, symbol); |
| | | entitys.add(graphic); |
| | | } |
| | | }); |
| | | return Widget; |
| | | }); |