/* * @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/supervisoryMap/template.html", "base/AppEvent", "base/ConfigData", "widgets/supervisoryMap/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/supervisoryMap/FlareClusterLayer_v3", "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 ) { var Widget = declare([BaseWidget], { widgetName: "AlertSecurity", label: "地图模式", templateString: template, _map: null, objThis: null, _siteLayer: new GraphicsLayer(), layuiLayer: null, layuiLadate: null, tabIndex: 0, heatmapfeatureLayer: null,//liu热力图 // 保留添加实体图层的变量 addEntitys: null, entitysData: [], // 巡逻区域或者巡逻路线的描述 routeOrRegionDescribe: null, // 用来记录巡逻区域或者巡逻路线的下标的 patrolIndex: 0, // 拖拽 isDown: false, x: 0, y: 0, offset: null, moveThis: null, // 电子围栏需要新增的Id newElectronicFenceId: null, // 新增路线时,派发人员,人员名称,以及人员id peopleRealName: null, pepleRealId: null, //存放聚合实体 clusterLayer: null, constructor: function (options, srcRefNode) { this._map = options.map; objThis = this; this.addEntitys = new GraphicsLayer({ id: 'addEntitys' }); // 添加点面线的图层 this.addPolygonEntitys = new GraphicsLayer({ id: 'addPolygonEntitys' }); // 添加所有图层的地方 this.entityPolygonAll = new GraphicsLayer({ id: 'entityPolygonAll' }); this._map.addLayer(this.addEntitys); 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]; }, entityData: [], //左侧控制栏 analysisAddEntitys: null, constructor: function (options, srcRefNode) { this._map = options.map; objThis = this; this.analysisAddEntitys = new GraphicsLayer({ id: 'analysisAddEntitys' }); // this.addOneEntitys = new GraphicsLayer({ id: 'addOneEntitys' }); // this.addTwoEntitys = new GraphicsLayer({ id: 'addTwoEntitys' }); // this.addThreeEntitys = new GraphicsLayer({ id: 'addThreeEntitys' }); this._map.addLayer(this.analysisAddEntitys); this._map.addLayer(this.addOneEntitys); }, startup: function () { objThis._map.addLayer(objThis._siteLayer); var that = this; that.getEquipmentTable($('.analysis-container-equipment').find('.tbody tbody'),''); // 顶部tab得切换事件 $('.analysis-and-judgment-tab li').click(function () { // if (that.tabIndex == $(this).index()) return; // if ($(this).index() == 1) { return }; // if ($(this).index() == 2) { return }; if (that.entitysData.length > 0) { that.analysisAddEntitys.clear(); that.entitysData = []; } if (that.heatmapfeatureLayer_1.graphics.length > 0) { that.heatmapfeatureLayer_1.clear(); that.heatmapfeatureLayer_1.setRenderer(); $('.analysis-category input').prop('checked', false); } $(this).addClass('on').siblings().removeClass('on'); var ind = $(this).index(); $($('.analysis-container > div')[ind]).stop().show().siblings().stop().hide(); var overText = $('#policeCategory > div:eq(0)').text().trim() == '全部' ? '' : $('#policeCategory > div:eq(0)').text().trim(); var levelText = $('#policeArea > div:eq(0)').text().trim() == '全部' ? '' : $('#policeArea > div:eq(0)').attr('areaid'); if (ind == 0) { that.getArea($('#policeArea')); that.getPoliceTableAnalysis($($('.analysis-container > div')[ind]).find('.tbody tbody'), $('#analysis_select_time_start').val() + ':00', $('#analysis_select_time_end').val() + ':00', overText, levelText) } else if (ind == 1) { that.getOwnerType($('#ownerCategory')); that.getOwnerDj($('#ownerLevel'), ''); that.getOwnerTable($($('.analysis-container > div')[ind]).find('.tbody tbody'), '', ''); } else if (ind == 2) { that.getEquipmentTable($($('.analysis-container > div')[ind]).find('.tbody tbody'), ''); } that.tabIndex = $(this).index(); }) // 时间查询 $('#policeSelectTime').off('click').click(function () { var times = $(this).prevAll(); layui.use('layer', function () { var layer = layui.layer; // 开始时间 var startTime = $(times[2]).val(); // 结束时间 var endTime = $(times[0]).val(); if (startTime == '') { layer.msg('请选择开始时间!', { icon: 5, time: 2000 //2秒关闭(如果不配置,默认是3秒) }); return; } else { if (endTime == '') { layer.msg('请选择结束时间!', { icon: 5, time: 2000 //2秒关闭(如果不配置,默认是3秒) }); return; } else { var text = $('#policeCategory div:eq(0)').text().trim(); var levelText = $('#policeArea > div:eq(0)').text().trim() == '全部' ? '' : $('#policeArea > div:eq(0)').attr('areaid'); that.getPoliceTableAnalysis($('.analysis-container-police').find('.tbody tbody'), startTime, endTime, text == '全部' ? '' : text, levelText); } } }) }) // 警情列表中的点击事件 $('.analysis-container-police .analysis-table-content .tbody').off('click', 'tr').on('click', 'tr', function () { var id = $(this).attr('term-list'); var url = './popup/html/police-details.html?obj=' + id; layui.use('layer', function () { that.layuiLayer = layui.layer; that.layuiLayer.config({ extend: 'myskin/police-details.css' }); that.layuiLayer.close(that.layuiLayer.index); that.layuiLayer.open({ title: '警情详情', type: 2, shadeClose: true, shade: false, maxmin: false, //开启最大化最小化按钮 area: ['500px', '400px'], offset: 'auto', skin: 'police-details', content: url, closeBtn: 1, }); }) }) $('.analysis-container-police .analysis-table-content .tbody').off('click', '.location').on('click', '.location', function (event) { event.stopPropagation(); }) $('.analysis-container-police .analysis-table-content .tbody').off('click', '.location input').on('click', '.location input', 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._map.centerAndZoom(position, 18);//缩放,10是缩放级别,可以自定义,数值越大缩放越大 }) // 业主列表中的点击事件 $('.analysis-container-owner .analysis-table-content .tbody').off('click', 'tr').on('click', 'tr', function () { var id = $(this).attr('term-list'); var url = './popup/html/owner-details.html?id=' + id; layui.use('layer', function () { that.layuiLayer = layui.layer; that.layuiLayer.config({ extend: 'myskin/owner-details.css' }); that.layuiLayer.close(that.layuiLayer.index); that.layuiLayer.open({ title: '业主详情', type: 2, shadeClose: true, shade: false, maxmin: false, //开启最大化最小化按钮 area: ['500px', '340px'], offset: 'auto', skin: 'owner-details', content: url, closeBtn: 1, }); }) }) $('.analysis-container-owner .analysis-table-content .tbody').off('click', '.location').on('click', '.location', function (event) { event.stopPropagation(); }) $('.analysis-container-owner .analysis-table-content .tbody').off('click', '.location input').on('click', '.location input', 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._map.centerAndZoom(position, 18);//缩放,10是缩放级别,可以自定义,数值越大缩放越大 }) // 设备列表中的点击事件 $('.analysis-container-equipment .analysis-table-content .tbody').off('click', 'tr').on('click', 'tr', function () { var id = $(this).attr('term-listid'); var url = './popup/html/equipment-details.html?obj=' + id; layui.use('layer', function () { that.layuiLayer = layui.layer; that.layuiLayer.config({ extend: 'myskin/equipment-details.css' }); that.layuiLayer.close(that.layuiLayer.index); that.layuiLayer.open({ title: '警情详情', type: 2, shadeClose: true, shade: false, maxmin: false, //开启最大化最小化按钮 area: ['520px', '320px'], offset: 'auto', skin: 'equipment-details', content: url, closeBtn: 1, }); }) }) $('.analysis-container-equipment .analysis-table-content .tbody').off('click', '.location').on('click', '.location', function (event) { event.stopPropagation(); }) $('.analysis-container-equipment .analysis-table-content .tbody').off('click', '.location input').on('click', '.location input', 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._map.centerAndZoom(position, 18);//缩放,10是缩放级别,可以自定义,数值越大缩放越大 }) // 警情列表中得热力图是否选中事件 $('#policeHeatMap').click(function () { that.checkBoxSelect(this); }) // 业主信息列表中得热力图是否选中事件 $('#ownerHeatMap').click(function () { that.checkBoxSelect(this); }) // 设备信息列表的热力图是否选中事件 $('#equipmentHeatMap').click(function () { that.checkBoxSelect(this); }) // 警情信息中类别移入事件 $('#policeCategory').mouseenter(function () { if ($('#policeCategory .select-list').is(':hidden')) { $('#policeCategory .select-list').stop().slideDown(0); } }) // 警情信息中得类别移出事件 $('#policeCategory').mouseleave(function () { if (!$('#policeCategory .select-list').is(':hidden')) { $('#policeCategory .select-list').stop().slideUp(0); } }) // 警情信息中行政区移入事件 $('#policeArea').mouseenter(function () { if ($('#policeArea .select-list').is(':hidden')) { $('#policeArea .select-list').stop().slideDown(0); } }) // 警情信息中得行政区移出事件 $('#policeArea').mouseleave(function () { if (!$('#policeArea .select-list').is(':hidden')) { $('#policeArea .select-list').stop().slideUp(0); } }) // 业主信息中类别移入事件 $('#ownerCategory').mouseenter(function () { if ($('#ownerCategory .select-list').is(':hidden')) { $('#ownerCategory .select-list').stop().slideDown(0); } }) // 业主信息中得类别移出事件 $('#ownerCategory').mouseleave(function () { if (!$('#ownerCategory .select-list').is(':hidden')) { $('#ownerCategory .select-list').stop().slideUp(0); } }) // 业主信息中的等级移入事件 $('#ownerLevel').mouseenter(function () { if ($('#ownerLevel .select-list').is(':hidden')) { $('#ownerLevel .select-list').stop().slideDown(0); } }) // 业主信息中的等级移出事件 $('#ownerLevel').mouseleave(function () { if (!$('#ownerLevel .select-list').is(':hidden')) { $('#ownerLevel .select-list').stop().slideUp(0); } }) // 设备信息中类别移入事件 $('#equipmentCategory').mouseenter(function () { if ($('#equipmentCategory .select-list').is(':hidden')) { $('#equipmentCategory .select-list').stop().slideDown(0); } }) // 设备信息中得类别移出事件 $('#equipmentCategory').mouseleave(function () { if (!$('#equipmentCategory .select-list').is(':hidden')) { $('#equipmentCategory .select-list').stop().slideUp(0); } }) // 警情信息类,业主信息类,设备信息类别,具体项的点击事件 $('.analysis-container > div .select-list').off('click', 'li').on('click', 'li', function (event) { // console.log(event.currentTarget.innerHTML,'innerhtml') var text = $(this).text().trim(); // console.log(text,'text()') // console.log(that.tabIndex,'tabIndex') $(this).parent().parent().prev().html(text + ''); $(this).parent().parent().stop().slideUp(0); if ($(this).attr('areaid')) { $(this).parent().parent().prev().attr('areaid', $(this).attr('areaid')); } else if ($(this).attr('ownerid')) { $(this).parent().parent().prev().attr('ownerid', $(this).attr('ownerid')); } if (that.tabIndex == 1) { var levelText = $('#policeArea > div:eq(0)').text().trim() == '全部' ? '' : $('#policeArea > div:eq(0)').attr('areaid'); var overText = $('#policeCategory > div:eq(0)').text().trim() == '全部' ? '' : $('#policeCategory > div:eq(0)').text().trim(); if ($(this).attr('areaid')) { that.getPoliceTableAnalysis($('.analysis-container-police').find('.tbody tbody'), $('#analysis_select_time_start').val(), $('#analysis_select_time_end').val(), overText, levelText); } else { that.getPoliceTableAnalysis($('.analysis-container-police').find('.tbody tbody'), $('#analysis_select_time_start').val(), $('#analysis_select_time_end').val(), overText, levelText); } } else if (that.tabIndex == 2) { var categoryText = $('#ownerCategory > div:eq(0)').text().trim() == '全部' ? '' : $('#ownerCategory > div:eq(0)').attr('ownerid'); var levelText = $('#ownerLevel > div:eq(0)').text().trim() == '全部' ? '' : $('#ownerLevel > div:eq(0)').text().trim(); var parentId = $(this).parent().parent().parent().attr('id'); if (parentId == 'ownerCategory') { that.getOwnerDj($('#ownerLevel'), categoryText); that.getOwnerTable($('.analysis-container-owner').find('.tbody tbody'), categoryText, ''); } else { that.getOwnerTable($('.analysis-container-owner').find('.tbody tbody'), categoryText, levelText); } } else if (that.tabIndex == 0) { that.getEquipmentTable($('.analysis-container-equipment').find('.tbody tbody'), text == '全部' ? '' : text); } }) }, getArea: function (dom) { dom.children('.select-list').children('ul').empty(); dom.children('.select-list').children('ul').append($("
  • 全部
  • ")); var that = this; $.ajax({ url: 'https://web.byisf.com/api/blade-system/region/select?code=3601', type: 'GET', dataType: 'JSON', success: function (data) { var res = data.data; for (var i = 0; i < res.length; i++) { dom.children('.select-list').children('ul').append($("
  • " + res[i].name + "
  • ")); } } }) }, getPoliceTableAnalysis: function (dom, beginTime, endTime, waringType, addvcd) { dom.empty(); var that = this; $.ajax({ url: "https://web.byisf.com/api/blade-jfpts/alarm/alarm/page?current=1&size=99999&waringType=&beginTime=" + beginTime + "&endTime=" + endTime + "&province=36&city=3601&district=" + addvcd, type: 'get', dataType: 'JSON', success: function (data) { var result = data.data.records; var str = ''; that.entitysData = []; that.analysisAddEntitys.clear(); for (var a, time, t, e, y, h, i = 0; i < result.length; i++) { if (result[i].waringType == "紧急求救") { result[i].waringType = "一键求助" } that.createEntitysAnalysis(that.analysisAddEntitys, that.entitysData, '警情信息', { lgtd: result[i].jd, lttd: result[i].wd, id: result[i].id }, result[i].jd, result[i].wd, './images/police-situation.png'); t = result[i].alarmTime.substr(0, 10); e = result[i].alarmTime.substr(11); time = t + ' ' + e; y = result[i].alarmTime.substr(5, 5); h = result[i].alarmTime.substr(11, 5); a = Number(i) + 1; str += ''; str += '' + a + ''; str += '' + result[i].waringType + ''; str += '' + result[i].alarmPeople + ''; str += "" + y + ' ' + h + ""; str += " '; dom.append(str); str = ''; } for (var i = 0; i < 1000; i++) { var dd = Math.random(); var cc = Math.random(); } } }) }, // 获取设备信息列表 getEquipmentTable: function (dom, deviceType) { dom.empty(); var that = this; // console.log(dom, deviceType); // dom.append(deviceType); $.ajax({ url: '/api/blade-jfpts/equipment/equipment/selectList?deviceType=' + deviceType, type: 'GET', dataType: 'JSON', success: function (data) { var result = data.data; var str = ''; that.entitysData = []; that.analysisAddEntitys.clear(); for (var a, i = 0; i < result.length; i++) { that.createEntitysAnalysis(that.analysisAddEntitys, that.entitysData, '设备信息', { lgtd: result[i].jd, lttd: result[i].wd, id: result[i].id }, result[i].jd, result[i].wd, './images/ceshi.png'); a = Number(i) + 1; str += ""; str += '' + a + ''; str += '' + result[i].deviceName + ''; str += '' + result[i].deviceType + ''; str += '' + result[i].deviceNumber + ''; str += " '; dom.append(str); str = ''; } } }) }, // 创建实体图层 createEntitysAnalysis: function (entitys, entityContent, name, item, lgtd, lttd, outlineColors) { var symbol = new esri.symbol.PictureMarkerSymbol(outlineColors, 16, 16); symbol.name = name; var pt = new Point(lgtd, lttd, new SpatialReference({ wkid: 4326 })); pt.entityData = item; var graphic = new esri.Graphic(pt, symbol); entitys.add(graphic); entityContent.push(item); }, //左侧控制栏↑ open: function () { var that = this; $.ajax({ url: "https://web.byisf.com/api/blade-jfpts/equipment/equipment/listAll", type: 'get', dataType: 'JSON', success: function (res) { var datas = res.data; var heatmapRenderer = null; that.entityData = []; for (var i = 0; i < datas.length; i++) { datas[i].x = Number(datas[i].jd); datas[i].y = Number(datas[i].wd); that.entityData.push({ lgtd: Number(datas[i].jd), lttd: Number(datas[i].wd) }) } that.flareClusterLayer(datas); that.heatmapfeatureLayer = that.heatmFeaLayers(); that._map.addLayer(that.heatmapfeatureLayer); // that.checkBoxSelect();//左侧控制热力图重复 } }) var that = this; var intTime = () => { var time = this.getTime(); $("#tabcontainer").css("width", "360px"); $('#mapcontentClass').addClass('client-max-map'); //追加样式 AppEvent.dispatchAppEvent(AppEvent.APPLICATION_RESIZE, {}); that.tabIndex = 0; $('.analysis-and-judgment-tab li:eq(0)').addClass('on').siblings().removeClass('on'); $($('.analysis-container > div')[0]).stop().show().siblings().stop().hide(); that.heatmapfeatureLayer_1 = that.heatmFeaLayers(); that._map.addLayer(that.heatmapfeatureLayer_1); $('#analysis_select_time_start').val(time.tomorrow); $('#analysis_select_time_end').val(time.current); layui.use('laydate', function () { that.layuiLadate = layui.laydate; //执行一个laydate实例 开始 that.layuiLadate.render({ elem: '#analysis_select_time_start', //指定元素 type: "datetime", format: 'yyyy-MM-dd HH:mm', trigger: 'click' }); // 结束 that.layuiLadate.render({ elem: '#analysis_select_time_end', //指定元素 type: "datetime", format: 'yyyy-MM-dd HH:mm', trigger: 'click' }); }); that.getArea($('#policeArea')); that.getPoliceTableAnalysis($('.analysis-container-police').find('.tbody tbody'), time.tomorrow, time.current, '', ''); that.clickHand(); } intTime(); }, heatmFeaLayers: function () {// liu 热力图渲染器,加载热力图 var layerDefinition = { "geometryType": "esriGeometryPoint", "fields": [{ "num": "num", editable: true, nullable: true, "type": "esriFieldTypeInteger", "alias": "数量" }] }; var featureCollection = { layerDefinition: layerDefinition, featureSet: null }; //创建 FeatureLayer 图层 var featureLayer = new esri.layers.FeatureLayer(featureCollection, { mode: esri.layers.FeatureLayer.MODE_SNAPSHOT, outFields: ["*"], opacity: .8 }); //设置渲染方式 return featureLayer; }, checkBoxSelect: function (self) {//选择热力图 var that = this; var heatmapRenderer = null; // // return // 选中 if ($(self).prop('checked') == true) { // if (1) { heatmapRenderer = new HeatmapRenderer({ colorStops: [ { ratio: 0.45, color: "rgba(000,000,255,0)" }, { ratio: 0.55, color: "rgb(000,255,255)" }, { ratio: 0.65, color: "rgb(000,255,000)" }, { ratio: 0.75, color: "rgb(234,126,15)" }, { ratio: 1.00, color: "rgb(255,000,000)" }, ], blurRadius: 42, maxPixelIntensity: 100, minPixelIntensity: 0 }); this.heatmapfeatureLayer.setRenderer(heatmapRenderer); // 取消选中 var point = null; for (var i = 0; i < that.entityData.length; i++) { point = new esri.geometry.Point(this.entityData[i].lgtd, this.entityData[i].lttd, new esri.SpatialReference({ wkid: 4326 })); this.heatmapfeatureLayer.add(new esri.Graphic(point)); } } else { this.heatmapfeatureLayer.clear(); this.heatmapfeatureLayer.setRenderer(); } }, close: function () { }, // 获取当前时间,以及昨天现在的时间 getTime: function getTime() { var timestamp = Date.parse(new Date()); // 当前时间 var currentTime = new Date(timestamp); // 年 var currentY = currentTime.getFullYear(); // 月 var currentM = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1; // 日 var currentD = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate(); // 时 var currentH = currentTime.getHours() < 10 ? '0' + currentTime.getHours() : currentTime.getHours(); // 分 var currentDd = currentTime.getMinutes() < 10 ? '0' + currentTime.getMinutes() : currentTime.getMinutes(); // 明天 var tomorrowTime = new Date(timestamp - 60 * 60 * 24 * 1000); // 年 var tomorrowY = tomorrowTime.getFullYear(); // 月 var tomorrowM = tomorrowTime.getMonth() + 1 < 10 ? '0' + (tomorrowTime.getMonth() + 1) : tomorrowTime.getMonth() + 1; // 日 var tomorrowD = tomorrowTime.getDate() < 10 ? '0' + tomorrowTime.getDate() : tomorrowTime.getDate(); // 时 var tomorrowH = tomorrowTime.getHours() < 10 ? '0' + tomorrowTime.getHours() : tomorrowTime.getHours(); // 分 var tomorrowDd = tomorrowTime.getMinutes() < 10 ? '0' + tomorrowTime.getMinutes() : tomorrowTime.getMinutes(); return { current: currentY + '-' + currentM + '-' + currentD + ' ' + currentH + ':' + currentDd, tomorrow: tomorrowY + '-' + tomorrowM + '-' + tomorrowD + ' ' + tomorrowH + ':' + tomorrowDd, month: currentM + currentD }; }, // 创建实体图层 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) { var symbol = new esri.symbol.PictureMarkerSymbol(img, 33, 48); var pt = new Point(lgtd, lttd, new SpatialReference({ wkid: 4326 })); var graphic = new esri.Graphic(pt, symbol); entitys.add(graphic); }, addPoints: function (entitys, lgtd, lttd, img) { var symbol = new esri.symbol.PictureMarkerSymbol(img, 33, 48); var pt = new Point(lgtd, lttd, new SpatialReference({ wkid: 4326 })); var graphic = new esri.Graphic(pt, symbol); entitys.add(graphic); }, clickHand: function (e) {//top点击事件,导航 // console.log(e); }, //聚合图层事件 flareClusterLayer: function (datas) { //top聚合事件,导航 var that = this; var preClustered = false; var displaySingleFlaresAtCount = 20; 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: 120, clusterAreaDisplay: areaDisplayMode, clusteringBegin: function (e) { // console.log("clustering begin"); }, clusteringComplete: function () { console.log("clustering complete"); } }); //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/jingbaored.png", 33, 48).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, 52, 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); 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 } ] }); //clusterLayer.infoTemplate = template; that._map.infoWindow.titleInBody = false; that._map.addLayer(that.clusterLayer); //var data = DataManager.getData(); that.clusterLayer.addData(datas); }, clearLayer: function () { var that = this; that._map.removeLayer(that.clusterLayer); that.clusterLayer = null; } }); return Widget; });