weather_old.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. import { containsCoordinate } from 'ol/extent';
  2. import { OLMap } from "@/assets/map/OLMap";
  3. import '@/assets/map/popup.css'
  4. import { gradientColors, markerZoomSize, labelZoomSize, colorRGBtoHex, jqAjax } from "@/assets/map/maptool";
  5. import $ from "@/assets/map/jquery.min";
  6. OLMap.prototype.eventViewChange = function (func) { //根据地图缩放级别控制popup弹窗的显隐
  7. var view = this.map.getView();
  8. var map = this.map;
  9. view.on('change:resolution', function (event) {
  10. let z = view.getZoom();
  11. let r = view.getResolution();
  12. var region = view.calculateExtent(map.getSize());
  13. //console.log('extent: '+region);
  14. var overlays = map.getOverlays().getArray();
  15. var popups = []; //记录popup
  16. //查找marker和label
  17. for (var k in overlays) {
  18. let oid = overlays[k].getId();
  19. if (oid.indexOf('marker') >= 0) {
  20. let ediv = overlays[k].get('element');
  21. let params = JSON.parse(ediv.getAttribute("desc"));
  22. let level = params.level;
  23. if (level == 1) {
  24. if (z < 5.3) {
  25. var wh = markerZoomSize(5, z);
  26. ediv.style.setProperty('width', wh + 'px');
  27. ediv.style.setProperty('height', wh + 'px');
  28. } else if (z >= 5.3 && z < 6.3) {
  29. var wh = markerZoomSize(4, z);
  30. ediv.style.setProperty('width', wh + 'px');
  31. ediv.style.setProperty('height', wh + 'px');
  32. } else {
  33. var wh = markerZoomSize(3, z);
  34. ediv.style.setProperty('width', (wh * 1.5) + 'px');
  35. ediv.style.setProperty('height', wh + 'px');
  36. }
  37. }
  38. if (level == 2) {
  39. if (z < 7.2) {
  40. var wh = markerZoomSize(6, z);
  41. ediv.style.setProperty('width', wh + 'px');
  42. ediv.style.setProperty('height', wh + 'px');
  43. } else if (z >= 7.2 && z < 7.6) {
  44. var wh = markerZoomSize(5, z);
  45. ediv.style.setProperty('width', wh + 'px');
  46. ediv.style.setProperty('height', wh + 'px');
  47. } else if (z >= 7.6 && z < 8) {
  48. var wh = markerZoomSize(4, z);
  49. ediv.style.setProperty('width', wh + 'px');
  50. ediv.style.setProperty('height', wh + 'px');
  51. } else {
  52. var wh = markerZoomSize(3, z);
  53. ediv.style.setProperty('width', (wh * 1.5) + 'px');
  54. ediv.style.setProperty('height', wh + 'px');
  55. }
  56. }
  57. if (level == 3) {
  58. if (z < 8.5) {
  59. var wh = markerZoomSize(7, z);
  60. ediv.style.setProperty('width', wh + 'px');
  61. ediv.style.setProperty('height', wh + 'px');
  62. } else if (z >= 8.5 && z < 9) {
  63. var wh = markerZoomSize(5, z);
  64. ediv.style.setProperty('width', wh + 'px');
  65. ediv.style.setProperty('height', wh + 'px');
  66. } else {
  67. var wh = markerZoomSize(3, z);
  68. ediv.style.setProperty('width', (wh * 1.5) + 'px');
  69. ediv.style.setProperty('height', wh + 'px');
  70. }
  71. }
  72. }
  73. if (oid.indexOf("label") >= 0) {
  74. // 重新设置标注的尺寸
  75. let ea = overlays[k].get('element');
  76. let params = JSON.parse(ea.getAttribute("desc"));
  77. let level = params.level;
  78. if (level == 1) {
  79. var fz = labelZoomSize(6.3, z);
  80. if (z >= 6.3) {
  81. fz = fz > 8 ? fz : 8;
  82. }
  83. ea.style.setProperty('font-size', fz + "px");
  84. }
  85. if (level == 2) {
  86. var fz = labelZoomSize(8, z);
  87. if (z >= 8) {
  88. fz = fz > 8 ? fz : 8;
  89. }
  90. ea.style.setProperty('font-size', fz + "px");
  91. }
  92. if (level == 3) {
  93. var fz = labelZoomSize(9, z);
  94. if (z >= 9) {
  95. fz = fz > 8 ? fz : 8;
  96. }
  97. ea.style.setProperty('font-size', fz + "px");
  98. }
  99. }
  100. //console.log("zoom: "+z+", "+event.target.get(event.key));
  101. // 记录位于当前视图的popup
  102. if (oid.indexOf("popup") >= 0) {
  103. let ep = overlays[k].get('element');
  104. let pos = ep.getElementsByTagName('input')[0].value;
  105. pos = pos.split(',');
  106. let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
  107. //console.log('pos'+"_"+pt);
  108. if (containsCoordinate(region, pt)) {
  109. popups.push(overlays[k]);
  110. }
  111. }
  112. }
  113. //获取当前视图下的Overlay要素
  114. //console.log('zoom: '+z+'_'+popups.length)
  115. if (popups.length <= 8) {
  116. for (var p in popups) {
  117. if (popups[p].getPosition() != undefined) {
  118. continue;
  119. }
  120. let ep = popups[p].get('element');
  121. let pos = ep.getElementsByTagName('input')[0].value;
  122. pos = pos.split(',');
  123. let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
  124. //popups[p].setPosition(pt); //设置为当前站点位置
  125. let id=popups[p].getId().split("popup_")[1];
  126. func(id,popups[p],pt);
  127. }
  128. }
  129. });
  130. view.on('change:center', function (event) {
  131. let z = view.getZoom();
  132. let r = view.getResolution();
  133. var region = view.calculateExtent(map.getSize());
  134. //console.log('chang-extent: '+region);
  135. var overlays = map.getOverlays().getArray();
  136. var popups = []; //记录popup
  137. for (var k in overlays) {
  138. let oid = overlays[k].getId();
  139. // 记录位于当前视图的popup
  140. if (oid.indexOf("popup") >= 0) {
  141. let ep = overlays[k].get('element');
  142. let pos = ep.getElementsByTagName('input')[0].value;
  143. pos = pos.split(',');
  144. let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
  145. //console.log('pos'+"_"+pt);
  146. if (containsCoordinate(region, pt)) {
  147. popups.push(overlays[k]);
  148. }
  149. }
  150. }
  151. //获取当前视图下的Overlay要素
  152. //console.log('zoom: '+z.toFixed(1)+'_popups: '+popups.length)
  153. if (popups.length <= 8) {
  154. for (var p in popups) {
  155. if (popups[p].getPosition() != undefined) {
  156. continue;
  157. }
  158. let ep = popups[p].get('element');
  159. let pos = ep.getElementsByTagName('input')[0].value;
  160. pos = pos.split(',');
  161. let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
  162. //popups[p].setPosition(pt); //设置为当前站点位置
  163. let id=popups[p].getId().split("popup_")[1];
  164. func(id,popups[p],pt);
  165. }
  166. }
  167. });
  168. }
  169. OLMap.prototype.eventOverlayClose = function () {//关闭所有弹窗
  170. this.map.on('click', function (evt) {
  171. //console.log("事件源:"+evt.target.tagName+", 类型:"+evt.type+",是否冒泡事件:"+evt.bubbles);
  172. //去除所有Popup
  173. var overlays = this.getOverlays().getArray();
  174. //console.log(overlays.length);
  175. for (var k in overlays) {
  176. let oid = overlays[k].getId();
  177. if (oid.indexOf('marker') >= 0) {
  178. let e = overlays[k].get('element');
  179. let c = e.style['background-color'];
  180. c = colorRGBtoHex(c);
  181. //console.log('c='+c);
  182. e.style.setProperty('border', '1px solid' + c);
  183. }
  184. if (oid.indexOf("popup") >= 0) {
  185. overlays[k].setPosition(undefined); //隐藏所有POPUP
  186. }
  187. }
  188. });
  189. }
  190. export function updatePopupTitle(map, switch_flag) {
  191. var types = ['popup']
  192. var layers = map.getOverlays().getArray();
  193. for (let i = 0; i < layers.length; i++) {
  194. const layer = layers[i];
  195. let oid = layer.getId();
  196. let ediv = layer.get('element');
  197. let params = JSON.parse(ediv.getAttribute("desc"));
  198. let id = params.id;
  199. let name = params.name;
  200. for (let i in types) {
  201. if (oid.indexOf(types[i]) >= 0) {
  202. //更改popup的标题
  203. let x = $(ediv).find("#flag_switch");
  204. let sname = switch_flag ? strOmit(name, 8) : id; //显示站名、站号
  205. x.html(sname);
  206. }
  207. }
  208. }
  209. }
  210. export function rmOverlaysByLevel(map, levels = [3], types = ['marker', 'label', 'popup']) {//清除指定Level的Marker和Popup
  211. var layers = map.getOverlays().getArray();
  212. //console.log('删除前图层数: '+layers.length);
  213. var overlays = []
  214. for (let i = 0; i < layers.length; i++) {
  215. const layer = layers[i];
  216. let oid = layer.getId();
  217. let ediv = layer.get('element');
  218. let params = JSON.parse(ediv.getAttribute("desc"));
  219. let level = params.level;
  220. for (let i in types) {
  221. for (let j in levels) {
  222. if (oid.indexOf(types[i]) >= 0 && level == levels[j]) {
  223. overlays.push(layer);
  224. }
  225. }
  226. }
  227. }
  228. for (let i in overlays) {
  229. map.removeOverlay(overlays[i]);
  230. }
  231. //layers = map.getOverlays().getArray();
  232. //console.log('删除后图层数: '+layers.length);
  233. }
  234. export function hiddenOverlaysByLevel(map, hidden = true, levels = [3], types = ['marker', 'label', 'popup']) {//关闭指定Level的Marker和Popup
  235. var layers = map.getOverlays().getArray();
  236. var overlays = []
  237. for (let i = 0; i < layers.length; i++) {
  238. const layer = layers[i];
  239. let oid = layer.getId();
  240. let ediv = layer.get('element');
  241. let params = JSON.parse(ediv.getAttribute("desc"));
  242. let level = params.level;
  243. for (let i in types) {
  244. for (let j in levels) {
  245. if (oid.indexOf(types[i]) >= 0 && level == levels[j]) {
  246. if (hidden) {
  247. ediv.classList.add("hidden");
  248. } else {
  249. ediv.classList.remove("hidden");
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. export function updateMarkerAndLabel(map, data, dataFactor) {
  257. if (String(data.msg).toLowerCase() == "ok") {
  258. //获取数据列表
  259. var feas = data.datas.list;
  260. var statis = null;
  261. //console.log("气象因子: "+dataFactor);
  262. switch (dataFactor) {
  263. case 'wd':
  264. statis = data.global_air_temp;
  265. break;
  266. case 'qy':
  267. statis = data.global_apressure;
  268. break;
  269. default:
  270. statis = data.global_air_temp;
  271. }
  272. if (statis == null) {
  273. throw ("统计参数为空!");
  274. }
  275. var max = parseFloat(statis.max) + 1; //防止色带数溢出,最大值需加1
  276. var min = parseFloat(statis.min) - 1; //防止色带数溢出,最小值需减1
  277. var color = gradientColors("#0000FF", "#FF0000", parseInt(max - min));
  278. //console.log("要素长度:" + feas.length);
  279. //查找markers和labels
  280. var overlays = map.getOverlays().getArray();
  281. //查找markers
  282. for (var k in overlays) {
  283. let oid = overlays[k].getId();
  284. for (var i = 0; i < feas.length; i++) {
  285. var fea = feas[i];
  286. var fid = fea.id;
  287. var fname = fea.name;
  288. var wd = '温度'
  289. var sd = '湿度';
  290. var qy = '气压';
  291. var fx = '风向';
  292. var yun = '云量';
  293. var yl = '雨量';
  294. var fs = '风速';
  295. var jd = '能见度';
  296. var tq = '天气';
  297. var time = null;
  298. var label = '';
  299. var cv = 0;
  300. var fd = null;
  301. switch (dataFactor) {
  302. case 'wd':
  303. fd = fea.AIR_TEMP; //fd: feature data
  304. time = fd.time.slice(-8, -3); //截取“时:分”
  305. wd = parseFloat(fd.value).toFixed(1);
  306. label = wd + "°C";
  307. cv = wd;
  308. break;
  309. case 'qy':
  310. fd = fea.APRESSURE;
  311. time = fd.time.slice(-8, -3); //截取“时:分”
  312. qy = parseFloat(fd.value).toFixed(0);
  313. label = qy + "kPa";
  314. cv = qy;
  315. break;
  316. default:
  317. fd = fea.AIR_TEMP;
  318. time = fd.time.slice(-8, -3); //截取“时:分”
  319. wd = parseFloat(fd.value).toFixed(1);
  320. label = wd + "°C";
  321. cv = wd;
  322. }
  323. // 符号化
  324. //cv = cv > max ? max : cv;
  325. //cv = cv < min ? min : cv;
  326. var color_idx = Math.floor((cv - min), 0);
  327. var fcolor = color[color_idx];
  328. //console.log("Color: "+fcolor+", "+color_idx+", "+cv);
  329. //更新marker样式
  330. if (oid.split('marker_')[1] == fid) {
  331. let ediv = overlays[k].get('element');
  332. ediv.style.setProperty('background-color', fcolor);
  333. ediv.style.setProperty('border', '1px solid' + fcolor);
  334. }
  335. //更新label文本
  336. if (oid.split('label_')[1] == fid) {
  337. let ediv = overlays[k].get('element');
  338. ediv.innerHTML = label; //设置文本
  339. }
  340. }
  341. }
  342. }
  343. }
  344. export function getSiteStatus(map) {
  345. var overlays = map.getOverlays().getArray();
  346. //查找markers
  347. var nTotal = 0;
  348. var nNormal = 0;
  349. var nAbnormal = 0;
  350. var nCease = 0;
  351. var nOther = 0;
  352. for (var k in overlays) {
  353. let oid = overlays[k].getId();
  354. if (oid.indexOf('marker') >= 0) {
  355. let ediv = overlays[k].get('element');
  356. let sdesc = ediv.getAttribute("desc");
  357. let params = JSON.parse(sdesc);
  358. let status = params.status;
  359. switch (status) {
  360. case "正常": nNormal++; break;
  361. case "故障": nAbnormal++; break;
  362. case "停用": nCease++; break;
  363. default: nOther++;
  364. }
  365. nTotal++;
  366. }
  367. }
  368. return { total: nTotal, normal: nNormal, abnormal: nAbnormal, cease: nCease, other: nOther };
  369. }
  370. export function getTableStyle(flag) {
  371. var styleList = [["正常", "popup_normal_border", "popup_normal_tdborder", "popup_normal_bg", "popup_normal_triangle"],
  372. ["故障", "popup_abnormal_border", "popup_abnormal_tdborder", "popup_abnormal_bg", "popup_abnormal_triangle"],
  373. ["停用", "popup_cease_border", "popup_cease_tdborder", "popup_cease_bg", "popup_cease_triangle"],
  374. ["未知", "popup_unknown_border", "popup_unknown_tdborder", "popup_unknown_bg", "popup_unknown_triangle"]];
  375. var arr;
  376. for (var i in styleList) {
  377. arr = styleList[i];
  378. if (arr[0] == flag) {
  379. return arr.slice(1, 5);
  380. }
  381. }
  382. return arr.slice(1, 5);
  383. }
  384. export function getALLMarkersId(map) {
  385. var overlays = map.getOverlays().getArray();
  386. var ids = [];
  387. for (var k in overlays) {
  388. let oid = overlays[k].getId();
  389. if (oid.indexOf('marker') >= 0) {
  390. ids.push(oid.split('marker_')[1]);
  391. }
  392. }
  393. return ids;
  394. }
  395. function strOmit(str, N = 8) { //字符串截留,超过长度n的字符串将被截断
  396. var n = str.length; //字的长度
  397. if (n > N) {
  398. return str.slice(0, N);
  399. }
  400. return str;
  401. }
  402. function showPopup(id, popup, cpoint) {
  403. //获取弹窗中的表格元素
  404. let div = popup.getElement();
  405. let trs = $(div).find("table tr");
  406. let tr1 = $(trs[1]).find("td");
  407. let tr2 = $(trs[2]).find("td");
  408. let tr3 = $(trs[3]).find("td");
  409. //向后台发送id,查询九宫格数据
  410. let url = 'http://debug.api.9poc.com/map/zhandian';
  411. let p = {
  412. "ID": id,
  413. "TOKEN": "SW6Q7Q74YX2V97JZSW6Q7Q74YX2V97JZ"
  414. }
  415. let params = {
  416. ACT: "GIRD9_DATA",
  417. PARAMETERS: JSON.stringify(p),
  418. }
  419. jqAjax(url, params, 'POST', function (data) {
  420. if(data.code==0){
  421. let grid = data.msg.grid;
  422. let wd = grid[0].value + "°C";;
  423. let sd = grid[1].value + grid[1].unit;
  424. let qy = grid[2].value + "kPa";
  425. let fx = grid[3].value + grid[3].unit;
  426. let yun = grid[4].value + grid[4].unit;
  427. let yl = grid[5].value + grid[5].unit;
  428. let fs = grid[6].value + grid[6].unit;
  429. let jd = grid[7].value + grid[7].unit;
  430. let tq = grid[8].value;
  431. let time = null;
  432. //向九宫格中赋新值
  433. tr1[0].innerHTML = wd;
  434. tr1[1].innerHTML = sd;
  435. tr1[2].innerHTML = qy;
  436. tr2[0].innerHTML = fx;
  437. tr2[1].innerHTML = yun;
  438. tr2[2].innerHTML = yl;
  439. tr3[0].innerHTML = fs;
  440. tr3[1].innerHTML = jd;
  441. tr3[2].innerHTML = tq;
  442. }
  443. popup.setPosition(cpoint); //设置为当前站点位置
  444. });
  445. }
  446. export function load_data(mapDiv, data, dataFactor, sitelevel, switch_flag, leftClick, rightClick) {
  447. if (String(data.msg).toLowerCase() == "ok") {
  448. var feas = data.datas.list;
  449. var statis = null;
  450. //console.log("气象因子: "+dataFactor);
  451. switch (dataFactor) {
  452. case 'wd':
  453. statis = data.global_air_temp;
  454. break;
  455. case 'qy':
  456. statis = data.global_apressure;
  457. break;
  458. default:
  459. statis = data.global_air_temp;
  460. }
  461. if (statis == null) {
  462. throw ("统计参数为空!");
  463. }
  464. var max = parseFloat(statis.max) + 1; //防止色带数溢出,最大值需加1
  465. var min = parseFloat(statis.min) - 1; //防止色带数溢出,最小值需减1
  466. var color = gradientColors("#0000FF", "#FF0000", parseInt(max - min));
  467. //console.log("要素长度:" + feas.length);
  468. //添加点位
  469. for (var i = 0; i < feas.length; i++) {
  470. var fea = feas[i];
  471. var fid = fea.id;
  472. var fname = fea.name;
  473. var lon = fea.longitude;
  474. var lat = fea.latitude;
  475. var zt = fea.status.text; //站点状态码:正常、故障、停用、未知
  476. var style = getTableStyle(zt);
  477. var sname = switch_flag ? strOmit(fname, 8) : fid; //显示站名、站号
  478. var stitle = "站名:" + fname + ",站号:" + fid
  479. var params = { level: sitelevel, status: zt, name: fname, id: fid };
  480. var wd = '温度'
  481. var sd = '湿度';
  482. var qy = '气压';
  483. var fx = '风向';
  484. var yun = '云量';
  485. var yl = '雨量';
  486. var fs = '风速';
  487. var jd = '能见度';
  488. var tq = '天气';
  489. var time = null;
  490. var label = '';
  491. var cv = 0;
  492. var fd = null;
  493. switch (dataFactor) {
  494. case 'wd':
  495. fd = fea.AIR_TEMP; //fd: feature data
  496. time = fd.time.slice(-8, -3); //截取“时:分”
  497. wd = parseFloat(fd.value).toFixed(1);
  498. label = wd + "°C";
  499. cv = wd;
  500. break;
  501. case 'qy':
  502. fd = fea.APRESSURE;
  503. time = fd.time.slice(-8, -3); //截取“时:分”
  504. qy = parseFloat(fd.value).toFixed(0);
  505. label = qy + "kPa";
  506. cv = qy;
  507. break;
  508. default:
  509. fd = fea.AIR_TEMP;
  510. time = fd.time.slice(-8, -3); //截取“时:分”
  511. wd = parseFloat(fd.value).toFixed(1);
  512. label = wd + "°C";
  513. cv = wd;
  514. }
  515. //这里使用模板字符串便于将DOM转换为JS对象
  516. let styleh = 'popup';
  517. let style0 = style[0];
  518. let style1 = style[1];
  519. let style2 = style[2];
  520. let style3 = style[3];
  521. let div = `<div class='${styleh}'>`;
  522. let table = `<table class='${style0}' title='鼠标【左/右键】点击九宫格查看【详细信息/快捷菜单】'>`
  523. + `<tr class='${style2}' style='color:#FFF' title='点击[x]或弹窗外任意区域关闭弹窗'>`
  524. + `<td colspan=2><span id='flag_switch' style='margin-left:18px; font-size:12px; font-weight:bold' title='${stitle}'>${sname}</span></td>`
  525. + `<td style='text-align:center; font-size:12px'>${time}</td>`
  526. + `</tr>`
  527. + `<tr>`
  528. + `<td class='${style1}'>${wd}</td>`
  529. + `<td class='${style1}'>${sd}</td>`
  530. + `<td class='${style1}'>${qy}</td>`
  531. + `</tr>`
  532. + `<tr>`
  533. + `<td class='${style1}'>${fx}</td>`
  534. + `<td class='${style1}'>${yun}</td>`
  535. + `<td class='${style1}'>${yl}</td>`
  536. + `</tr>`
  537. + `<tr>`
  538. + `<td class='${style1}'>${fs}</td>`
  539. + `<td class='${style1}'>${jd}</td>`
  540. + `<td class='${style1}'>${tq}</td>`
  541. + `</tr>`
  542. + `</table>`;
  543. let info = div + table + `<div class='${style3}'></div></div>`;
  544. /*
  545. //将模板字符串DOM转为JS对象
  546. let t = document.createElement('template');
  547. t.innerHTML=info;
  548. let _div=t.content.firstElementChild;
  549. let _tab=_div.firstElementChild;
  550. console.log("NodeName: "+_tab.nodeName);
  551. */
  552. document.oncontextmenu = function (e) {
  553. //去掉默认的contextmenu事件,否则会和右键事件同时出现。
  554. e.preventDefault();
  555. };
  556. // 符号化
  557. //cv = cv > max ? max : cv;
  558. //cv = cv < min ? min : cv;
  559. var color_idx = Math.floor((cv - min), 0);
  560. //console.log(cv, max, min);
  561. //console.log(sname+"_"+color_idx+"_"+color[color_idx]+"_"+min+"_"+max);
  562. //点位去重检查
  563. let m = mapDiv.markerIsExist([lon, lat]);
  564. //let m = mapDiv.markerIsExistById(fid);
  565. //console.log("站点是否存在:"+fid+", "+m);
  566. if (!m) {
  567. mapDiv.addPopup([lon, lat], 0, fid, info, leftClick, rightClick, params); //添加POPUP弹窗
  568. if (sitelevel != 3) {
  569. mapDiv.addMarkerAndLabel([lon, lat], fid, label, color[color_idx], 0.8,
  570. params, { width: '8px', height: '8px' }, showPopup); //添加marker和label
  571. } else {
  572. mapDiv.addMarkerAndLabel([lon, lat], fid, label, color[color_idx], 0.8,
  573. params, { width: '12px', height: '12px' }, showPopup); //添加marker和label
  574. }
  575. }
  576. }
  577. mapDiv.eventOverlayClose();
  578. mapDiv.eventViewChange(showPopup);
  579. } else {
  580. throw ("加载数据失败,数据标识:" + data.msg);
  581. }
  582. }