visualization.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. var baseRootPath = getBaseRootPath();
  2. var prefix = baseRootPath + ctx + "ksh";
  3. $(document).ready(function () {
  4. var navList = $(".nav-a");
  5. for (var i = 0; i < navList.length; i++) {
  6. if (jdId == $(navList[i]).attr("deptId")) {
  7. onNavClick(jdId);//街道登录初始化导航
  8. }
  9. }
  10. // 导航选中
  11. $(".nav-con a").on('click', function() {
  12. isNavChange = true;
  13. $(this).addClass('onthis');
  14. $(this).siblings().removeClass('onthis');
  15. });
  16. // 矢量图 影像图 选中
  17. $(".s1 span").on('click', function() {
  18. $(this).addClass('on');
  19. $(this).siblings().removeClass('on');
  20. });
  21. // 人房户 事件 选中
  22. $(".s2 span").on('click', function() {
  23. //$(this).toggleClass('on')
  24. $(this).addClass('on');
  25. $(this).siblings().removeClass('on');
  26. });
  27. // 后台管理
  28. $('#goHtgl').on('click', function () {
  29. location.href = ctx;
  30. });
  31. // 可视化
  32. $('#goKsh').on('click', function () {
  33. location.href = ctx + "ksh"
  34. });
  35. // 辅助决策
  36. $('#goFzjc').on('click', function () {
  37. location.href = ctx + "fzjc"
  38. });
  39. // 街道信息
  40. /*$('#kshJd').on('click', function () {
  41. location.href = prefix + "/kshJd"
  42. });*/
  43. // // 事件信息
  44. // $('#goEventDetail').on('click', function () {
  45. // $.modal.open("事件信息", prefix + "/eventDetail", 1200 , 630);
  46. // });
  47. // // 人房户单选
  48. // $('#rfhSingle').on('click', function () {
  49. // $.modal.open("人房户单选", prefix + "/rfhSingle",1200, 750);
  50. // });
  51. // // 人房户多选前
  52. // $('#rfhMultiBefore').on('click', function () {
  53. // $.modal.open("人房户多选前", prefix + "/rfhMultiBefore/n/n",1400, 720);
  54. // });
  55. // // 人房户多选后
  56. // $('#rfhMultiAfter').on('click', function () {
  57. // $.modal.open("人房户多选后", prefix + "/rfhMultiAfter",1400, 720);
  58. // });
  59. })
  60. //全屏
  61. function fullScreen() {
  62. var year = $("#year").val();
  63. var jdId = $("#jdId").val();
  64. var sqId = $("#sqId").val();
  65. var url = prefix + "/fullScreen/" + year + "/" + jdId + "/" + sqId + "/" + isYxt + "/" + isRfh;
  66. $.modal.openDetailFull("汽开区智慧社区数据孪生平台", url, 1200);
  67. }
  68. //全区、街道、社区切换
  69. function map_quanqu() {
  70. isYxt = true;
  71. // 点击全区后切换影像图 人房户、事件不切换 事件打点
  72. $("#yxt").addClass('on');
  73. $("#slt").removeClass('on');
  74. if(perFlag=="jd"){
  75. //$('#sqId').val(-1);
  76. //reloadData();
  77. onNavClick($('#jdId').val());
  78. // $.modal.alertWarning("仅限查看本街道数据");
  79. return;
  80. }
  81. // $('#jdId').val(-1);
  82. onNavClick(-1);
  83. /*jieDaoChangeBefore();
  84. if(!isRfh){
  85. $.eventPoint.init({
  86. deptId: 0,
  87. year:$("#year").val()
  88. });
  89. }*/
  90. }
  91. //点击下拉框
  92. function map_jiedao_click() {
  93. if(perFlag=="jd"){
  94. $('#jdId').val(jdId);
  95. $.modal.alertWarning("仅限查看本街道数据");
  96. return;
  97. }
  98. }
  99. function jieDaoChangeBefore() {//下拉切换街道
  100. if(perFlag=="jd" && false){
  101. $.modal.alertWarning("仅限查看本街道数据");
  102. return;
  103. }
  104. isJdChange = true;
  105. var jdId = $('#jdId').val();
  106. onNavClick(jdId);
  107. }
  108. function jieDaoChangeByFullScreen() {//下拉切换街道
  109. isJdChange = true;
  110. var jdId = $('#jdId').val();
  111. onNavClick(jdId);
  112. }
  113. var isNavChange = false;
  114. var isJdChange = false;
  115. var isSqChange = false;
  116. function jieDaoChange() {
  117. var obj = new Object();
  118. obj.jdIds = "" + $('#jdId').val()==-1?"":$('#jdId').val();
  119. if($('#jdId').val()==-1){
  120. $("#sqId").html("<option value='-1'>所有社区</option>");
  121. $('#jdIds').val($('#jdId').val()==-1?"":$('#jdId').val());
  122. $('#sqIds').val($('#sqId').val()==-1?"":$('#sqId').val());
  123. }
  124. $.ajax({
  125. url : ctx + "zhcx/zhcx" + "/getSheQuList",
  126. method : 'get',
  127. data : obj,
  128. success : function (e) {
  129. $("#sqId").html("<option value='-1'>所有社区</option>");
  130. if($('#jdId').val()!=-1){
  131. for(var i=0; i<e.sheQuList.length; i++){
  132. var option = $("<option></option>").text(e.sheQuList[i].deptName);
  133. option.attr("value",e.sheQuList[i].deptId);
  134. option.attr("class","sqId");
  135. $("#sqId").append(option);
  136. }
  137. }
  138. $('#jdIds').val($('#jdId').val()==-1?"":$('#jdId').val());
  139. $('#sqIds').val($('#sqId').val()==-1?"":$('#sqId').val());
  140. map_jiedao();
  141. if(!isRfh){//有轮廓图的是人房户不打点
  142. $.eventPoint.init({
  143. deptId: $('#sqId').val()==-1?$('#jdId').val()==-1?0:$('#jdId').val():$('#sqId').val(),
  144. year:$("#year").val()
  145. });
  146. }
  147. }
  148. });
  149. }
  150. function sheQuChange() {
  151. if(isJdChange == false){
  152. isSqChange = true;
  153. }
  154. $('#sqIds').val($('#sqId').val()==-1?"":$('#sqId').val());
  155. map_shequ();
  156. if(isJdChange || isNavChange){//切换街道、导航栏联动社区
  157. }else {//单独切换社区
  158. if(!isRfh){//有轮廓图的是人房户不打点
  159. $.eventPoint.init({
  160. deptId: $('#sqId').val()==-1?$('#jdId').val()==-1?0:$('#jdId').val():$('#sqId').val(),
  161. year:$("#year").val()
  162. });
  163. }
  164. }
  165. }
  166. var map_jiedaoList;
  167. function map_jiedao() {
  168. var obj = new Object();
  169. if($('#jdId').val()==-1){//全区查询有
  170. var jdIds = [];
  171. var jieDaoList = $(".jdId");
  172. for(var i = 0; i < jieDaoList.length; i++){
  173. jdIds.push($(jieDaoList[i]).val());
  174. }
  175. obj.deptIds = jdIds+"";
  176. }else {
  177. obj.deptIds = $('#jdIds').val();
  178. }
  179. $.ajax({
  180. url : prefix + "/map_info",
  181. method : 'post',
  182. data : obj,
  183. success : function (e) {
  184. map_jiedaoList = e.map_info;
  185. sheQuChange();
  186. }
  187. });
  188. }
  189. var map_shequList;
  190. function map_shequ() {
  191. var obj = new Object();
  192. if($('#sqId').val()==-1){//全区查询有
  193. var sqIds = [];
  194. var sheQuList = $(".sqId");
  195. for(var i = 0; i < sheQuList.length; i++){
  196. sqIds.push($(sheQuList[i]).val());
  197. }
  198. obj.deptIds = sqIds+"";
  199. }else {
  200. obj.deptIds = $('#sqIds').val();
  201. }
  202. $.ajax({
  203. url : prefix + "/map_info",
  204. method : 'post',
  205. data : obj,
  206. success : function (e) {
  207. map_shequList = e.map_info;
  208. map_reload();
  209. }
  210. });
  211. }
  212. var datasource_datasetNames;//加载数据源和数据集
  213. function map_reload() {
  214. if ($("#jdId").val() == "-1") {
  215. map.remove();
  216. layersList = [];
  217. initAllMap();
  218. } else {
  219. datasource_datasetNames = [];
  220. map.remove();//移除地图对象,
  221. var jdsqmap_layersList = [];//配置需要加载的图层
  222. jdsqmap_layersList.push(map_jilinShiLiang);
  223. if(isYxt){//加载影像图、轮廓
  224. jdsqmap_layersList.push(map_qikaiYingXiang);
  225. for (var i = 0; i < map_jiedaoList.length; i++) {
  226. jdsqmap_layersList.push(L.supermap.tiledMapLayer(workspace_jdsq + '/' + map_jiedaoList[i].layerId, {noWrap: true}));//加载本街道范围轮廓图
  227. }
  228. for (var i = 0; i < map_shequList.length; i++) {//选择具体街道时加载街道下所有社区数据
  229. if (map_shequList[i].layerId != null && map_shequList[i].layerId != "") {
  230. if(isRfh){//加载建筑物
  231. jdsqmap_layersList.push(L.supermap.tiledMapLayer(workspace_jdsq + '/' + map_shequList[i].layerId, {noWrap: true}));//加载本街道下所有社区建筑图
  232. datasource_datasetNames.push(map_shequList[i].datasourceName + ":" + map_shequList[i].datasetName);//["building:东风创业","building:东风创业","building:东风创业"],
  233. }
  234. }
  235. }
  236. }
  237. console.log(datasource_datasetNames)
  238. var jdsqmap_mapPoint;
  239. var jdsqmap_zoom;
  240. if (isSqChange && map_shequList[0].centerpointLat != null && map_shequList[0].centerpointLat != "" && map_shequList[0].centerpointLon != null && map_shequList[0].centerpointLon != "") {
  241. jdsqmap_zoom = 16;
  242. jdsqmap_mapPoint = getSuperMapCenterPoint(map_shequList[0].centerpointLat + "," + map_shequList[0].centerpointLon);//本社区中心点
  243. } else {
  244. jdsqmap_zoom = 14;
  245. jdsqmap_mapPoint = getSuperMapCenterPoint(map_jiedaoList[0].centerpointLat + "," + map_jiedaoList[0].centerpointLon);//本街道中心点
  246. /*if($('#sqId').val()==-1){
  247. for(var i=0;i<map_shequList.length;i++){//未选择具体街道时加载所有社区数据
  248. if(map_shequList[i].layerId !=null && map_shequList[i].layerId!=""){
  249. //jdsqmap_layersList.push(L.supermap.tiledMapLayer( workspace_jdsq+'/'+map_shequList[i].layerId, { noWrap: true }));//加载本街道下所有社区建筑图
  250. datasource_datasetNames.push(map_shequList[i].datasourceName + ":" + map_shequList[i].datasetName);//["building:东风创业","building:东风创业","building:东风创业"],
  251. }
  252. }
  253. }*/
  254. }
  255. isNavChange = false;
  256. isJdChange = false;
  257. isSqChange = false;
  258. mapPoint = jdsqmap_mapPoint;
  259. layersList = jdsqmap_layersList;
  260. initMap(jdsqmap_mapPoint, jdsqmap_layersList, jdsqmap_zoom);//重新初始化地图对象
  261. }
  262. }
  263. function map_reload() {
  264. reloadData();
  265. isNavChange = false;
  266. isJdChange = false;
  267. isSqChange = false;
  268. }
  269. /**
  270. * 人房户矢量图 只有矢量图 没有影像、轮廓、建筑、事件落点
  271. * 人房户影像图 只有矢量图、影像、轮廓、建筑 没有事件落点
  272. * 事件矢量图 只有矢量图、事件落点 没有影像、轮廓、建筑
  273. * 事件影像图 有矢量图、影像、轮廓、建筑、事件落点
  274. */
  275. function reloadData() {
  276. map.remove();//移除地图对象,
  277. layersList=[];
  278. datasource_datasetNames=[];
  279. /**
  280. * 矢量图
  281. */
  282. layersList.push(map_jilinShiLiang);//吉林矢量
  283. /**
  284. * 影像图
  285. */
  286. if(isYxt){//影像图
  287. layersList.push(map_qikaiYingXiang);//汽开影像
  288. }
  289. /**
  290. * 轮廓图
  291. */
  292. if(isYxt){
  293. if($("#jdId").val() == -1){//汽开全区轮廓图
  294. layersList.push(L.supermap.tiledMapLayer( workspace_jdsq+'/qikaiquanqu', { noWrap: true }));//汽开全区
  295. }else {//选中具体街道、社区轮廓图
  296. for (var i = 0; i < map_jiedaoList.length; i++) {
  297. layersList.push(L.supermap.tiledMapLayer(workspace_jdsq + '/' + map_jiedaoList[i].layerId, {noWrap: true}));//加载本街道范围轮廓图
  298. }
  299. }
  300. }
  301. /**
  302. * 建筑物
  303. */
  304. if(isYxt && isRfh && $("#jdId").val() != -1){
  305. for (var i = 0; i < map_shequList.length; i++) {//选择具体街道时加载街道下所有社区数据
  306. if (map_shequList[i].layerId != null && map_shequList[i].layerId != "") {
  307. layersList.push(L.supermap.tiledMapLayer(workspace_jdsq + '/' + map_shequList[i].layerId, {noWrap: true}));//加载本街道下所有社区建筑图
  308. datasource_datasetNames.push(map_shequList[i].datasourceName + ":" + map_shequList[i].datasetName);//["building:东风创业","building:东风创业","building:东风创业"],
  309. }
  310. }
  311. }
  312. /**
  313. * 事件落点
  314. */
  315. if(!isRfh){
  316. $.eventPoint.init({
  317. deptId: $('#sqId').val()==-1?$('#jdId').val()==-1?0:$('#jdId').val():$('#sqId').val(),
  318. year:$("#year").val()
  319. });
  320. }
  321. /**
  322. * 中心点、zoom
  323. */
  324. if($("#jdId").val() == -1 && $("#sqId").val() == -1){
  325. zoom=12;
  326. mapPoint=iServerqiKaiQuMapCenterPoint;//全区中心点
  327. }else if ($("#jdId").val() != -1 && $("#sqId").val() == -1 && map_jiedaoList[0].centerpointLat != null && map_jiedaoList[0].centerpointLat != "" && map_jiedaoList[0].centerpointLon != null && map_jiedaoList[0].centerpointLon != "") {
  328. zoom = 14;
  329. mapPoint = getSuperMapCenterPoint(map_jiedaoList[0].centerpointLat + "," + map_jiedaoList[0].centerpointLon);//本街道中心点
  330. } else if($("#sqId").val() != -1 && $("#sqId").val() != -1&& map_shequList[0].centerpointLat != null && map_shequList[0].centerpointLat != "" && map_shequList[0].centerpointLon != null && map_shequList[0].centerpointLon != ""){
  331. zoom = 16;
  332. mapPoint = getSuperMapCenterPoint(map_shequList[0].centerpointLat + "," + map_shequList[0].centerpointLon);//本社区中心点
  333. }else {
  334. zoom=12;
  335. mapPoint=iServerqiKaiQuMapCenterPoint;//全区中心点
  336. }
  337. initMap(mapPoint,layersList,zoom);//重新初始化地图对象
  338. }