gridLayer.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. define([
  2. 'html!lgDir/gridLayer',
  3. 'css!lgDir/gridLayer'
  4. ], function(tplLayout) {
  5. // L.ZoomViewer = L.Control.extend({
  6. // onAdd: function(){
  7. // var gauge = L.DomUtil.create('div');
  8. // gauge.style.width = '30px';
  9. // gauge.style.background = 'rgba(255,255,255,1)';
  10. // gauge.style.textAlign = 'center';
  11. // gauge.style.margin = '77px 0 0 12px';
  12. // gauge.style.height = '30px';
  13. // gauge.style.fontSize = '20px';
  14. // gauge.style.lineHeight = '30px';
  15. // map.on('zoomstart zoom zoomend', function(ev){
  16. // gauge.innerHTML = map.getZoom();
  17. // })
  18. // return gauge;
  19. // }
  20. // });
  21. var a = 0,b = 9,z = 0;
  22. function init(){
  23. if($(".tools-layerGrid").hasClass("cur")){
  24. $("#rule").show();
  25. } else{
  26. $("#rule").hide();
  27. if(cl_start){
  28. map2DViewer.map.removeLayer(cl_start);
  29. map2DViewer.map.removeLayer(polygon);
  30. }
  31. }
  32. // $("#rule").show();
  33. }
  34. ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap');
  35. $("body").append(tplLayout);
  36. $("#rule h2").dragmove($("#rule"));
  37. // 全屏
  38. function fullMap(option){
  39. if(option){
  40. $("#rule").hide();
  41. }else{
  42. $("#rule").show();
  43. }
  44. }
  45. L.canvasLayer = L.GridLayer.extend({
  46. createTile: function(coords){
  47. // console.log("createTilea and z:"+z+"a:"+a+"b:"+b);
  48. var tile = L.DomUtil.create('canvas', 'leaflet-tile');
  49. var ctx = tile.getContext('2d');
  50. var size = this.getTileSize()
  51. tile.width = size.x
  52. tile.height = size.y
  53. // 将切片号乘以切片分辨率,默认为256pixel,得到切片左上角的绝对像素坐标
  54. var nwPoint = coords.scaleBy(size);
  55. // 根据绝对像素坐标,以及缩放层级,反投影得到其经纬度
  56. var nw = map2DViewer.map.unproject(nwPoint, z)
  57. // console.log(tile.width);
  58. ctx.lineWidth = 1;
  59. ctx.strokeStyle = 'red';
  60. var lstCoord = Math.pow(2, coords.z) - 1;
  61. if(coords.z - z <= 1 && coords.z - z >= -1){
  62. // console.log("coords.z: "+ coords.z);
  63. // console.log("z: "+ z);
  64. if(coords.z == z){ // 同级时直接绘制
  65. ctx.beginPath();
  66. ctx.moveTo(0, 0);
  67. ctx.lineTo(size.x-1, 0);
  68. ctx.lineTo(size.x-1, size.y-1);
  69. ctx.lineTo(0, size.y-1);
  70. ctx.closePath();
  71. ctx.fillStyle = 'rgba(225,225,225,0.5)';
  72. ctx.fillRect(0, 0, size.x, 70);
  73. ctx.font = "18px Arial";
  74. ctx.fillStyle = 'black';
  75. ctx.textAlign = 'left';
  76. ctx.fillText(a+'-'+b+'-'+z+'-'+coords.x+'-'+coords.y+'.ptp', 40, 20);
  77. ctx.font = "14px Arial";
  78. ctx.textAlign = 'left';
  79. ctx.fillText('lat: ' + nw.lat.toFixed(6), 40, 40); // 纬度
  80. ctx.fillText('lon: ' + nw.lng.toFixed(6), 40, 60); // 经度
  81. }
  82. else{ // 非同级时
  83. var lstCoord = Math.pow(2, coords.z) - 1;
  84. if(coords.z - z < 0 && coords.z - z > -2){
  85. var mul = Math.pow(2, (z-coords.z));
  86. for(var i=0;i<mul;i++){
  87. ctx.moveTo((size.x-1)/mul*i, 0);
  88. ctx.lineTo((size.x-1)/mul*i, size.y-1);
  89. ctx.moveTo(0, (size.y-1)/mul*i);
  90. ctx.lineTo((size.x-1), (size.y-1)/mul*i);
  91. for(var j=0;j<=mul;j++){
  92. ctx.fillStyle = 'rgba(225,225,225,0.5)';
  93. ctx.fillRect(size.x/mul*j, size.y/mul*i, size.x/mul, 70);
  94. ctx.font = "9px Arial";
  95. ctx.fillStyle = 'black';
  96. ctx.fillText(a+'-'+b+'-'+z+'-'+(coords.x*mul+j)+'-'+(coords.y*mul+i)+'.ptp', size.x/mul*j, size.y/mul*i+20);
  97. }
  98. nw = map2DViewer.map.unproject(nwPoint, coords.z);
  99. ctx.fillText('lat: ' + nw.lat.toFixed(6), 0, 40); // 纬度
  100. ctx.fillText('lon: ' + nw.lng.toFixed(6), 0, 60); // 经度
  101. }
  102. }
  103. else{
  104. var bei = coords.z - z;
  105. var mi = Math.pow(2, bei);
  106. if(coords.x % mi == 0 && coords.y % mi == 0){ // 需要记录的坐标
  107. ctx.fillStyle = 'rgba(225,225,225,0.5)';
  108. ctx.fillRect(0, 0, size.x, 70);
  109. ctx.font = "18px Arial";
  110. ctx.fillStyle = 'black';
  111. ctx.textAlign = 'left';
  112. ctx.fillText(a+'-'+b+'-'+z+'-'+coords.x/mi+'-'+coords.y/mi+'.ptp', 40, 20); // 仅适用于放大一级
  113. ctx.font = "14px Arial";
  114. ctx.textAlign = 'left';
  115. nw = map2DViewer.map.unproject(nwPoint, coords.z);
  116. ctx.fillText('lat: ' + nw.lat.toFixed(6), 40, 40); // 纬度
  117. ctx.fillText('lon: ' + nw.lng.toFixed(6), 40, 60); // 经度
  118. }
  119. if(coords.y % mi == 0){
  120. ctx.moveTo(0, 0);
  121. ctx.lineTo(size.x-1,0);
  122. }
  123. if(coords.x % mi == 0){
  124. ctx.moveTo(0, 0);
  125. ctx.lineTo(0,size.y-1);
  126. }
  127. if(coords.y == lstCoord){
  128. ctx.moveTo(0,size.y-1);
  129. ctx.lineTo(size.x-1,size.y-1);
  130. }
  131. }
  132. }
  133. }
  134. ctx.stroke();
  135. return tile;
  136. }
  137. });
  138. L.control.createTilePackage = function(options){
  139. map2DViewer.map.removeLayer(cl_start);
  140. map2DViewer.map.setZoom(z);
  141. // console.log(z);
  142. cl_start = new L.canvasLayer;
  143. cl_start.addTo(map2DViewer.map);
  144. }
  145. // 自定义空间范围
  146. L.control.fitBds = function(crds,z){
  147. // console.log("getz:"+z);
  148. var latlngs = [
  149. [crds[2], crds[0]],
  150. [crds[3], crds[0]],
  151. [crds[3], crds[1]],
  152. [crds[2], crds[1]]
  153. ];
  154. map2DViewer.map.removeLayer(polygon);
  155. polygon = L.polygon(latlngs, {color: 'blue'}).addTo(map2DViewer.map);
  156. // zoom the map to the polygon
  157. map2DViewer.map.fitBounds(polygon.getBounds(),{maxZoom:parseInt(z)}).setZoom(z);
  158. mCrd = [
  159. crds[0],crds[2],crds[1],crds[3]
  160. ];
  161. mz = z;
  162. }
  163. L.control.request = function(fileName, tiles){
  164. var lgPopUp_total = document.querySelector('.lgPopUp_total');
  165. var lgPopUp_none = document.querySelector('.lgPopUp_none');
  166. var blackBoard = document.querySelector('.blackBoard');
  167. var tileType = document.querySelector('.lgPopUp_total .tileType');
  168. var tileSize = document.querySelector('.lgPopUp_total .tileSize');
  169. var loading = document.querySelector('.lgPopUp_total img');
  170. var esc = document.querySelector('.lgPopUp_total .esc');
  171. var qd = document.querySelector('.qd');
  172. // esc.innerHTML = "取消";
  173. // loading.style.display = "block";
  174. console.log(tiles);
  175. console.log(tiles.length);
  176. var xhr1,xhr2;
  177. if(tiles.length == 1){
  178. xhr1 = ajax({
  179. url: config.countServer+"/tileSizeData/"+fileName+"/"+tiles, //请求地址
  180. type: "GET",
  181. dataType: "json",
  182. success: function (response, xml) {
  183. loading.style.display = "none";
  184. esc.innerHTML = "确定";
  185. var str = JSON.parse(response);
  186. console.log(str[0].data[0]);
  187. console.log(str[0].data[0].size);
  188. if(!str[0].data[0].size){
  189. lgPopUp_none.style.display = "block";
  190. lgPopUp_total.style.display = "none";
  191. blackBoard.style.display = "block";
  192. }
  193. else{
  194. lgPopUp_total.style.display = "block";
  195. blackBoard.style.display = "block";
  196. loading.style.display = "none";
  197. tileType.innerHTML = fileName;
  198. tileSize.innerHTML = str[0].data[0].size;
  199. // alert("当前数据包大小为:"+str[0].data[0].size);
  200. }
  201. },
  202. fail: function (status) {
  203. loading.style.display = "none";
  204. console.log("get data err");
  205. }
  206. });
  207. }
  208. if(tiles.length > 1){
  209. xhr2 = ajax({
  210. url: config.countServer+"/tileSizeData/"+fileName+"/", //请求地址
  211. type: "POST",
  212. data: { "ptplist": JSON.stringify(tiles)},
  213. dataType: "json",
  214. success: function (response, xml) {
  215. esc.innerHTML = "确定";
  216. loading.style.display = "none";
  217. var str = JSON.parse(response);
  218. // console.log(str);
  219. // console.log(str.total);
  220. if(str.total == -1){
  221. lgPopUp_none.style.display = "block";
  222. blackBoard.style.display = "block";
  223. lgPopUp_total.style.display = "none";
  224. }
  225. else{
  226. lgPopUp_total.style.display = "block";
  227. blackBoard.style.display = "block";
  228. // alert("当前数据包总大小为:"+str.total);
  229. tileType.innerHTML = fileName;
  230. tileSize.innerHTML = str.total;
  231. }
  232. },
  233. fail: function (status) {
  234. loading.style.display = "none";
  235. console.log("post data err");
  236. }
  237. });
  238. }
  239. esc.onclick = function(){
  240. if(esc.innerHTML == "取消"){
  241. // xhr1.abort();
  242. xhr2.abort();
  243. esc.innerHTML = "确定";
  244. }
  245. if(esc.innerHTML == "确定"){
  246. lgPopUp_total.style.display = "none";
  247. blackBoard.style.display = "none";
  248. }
  249. }
  250. qd.onclick = function(){
  251. lgPopUp_none.style.display = "none";
  252. blackBoard.style.display = "none";
  253. }
  254. }
  255. L.control.showNameList = function(mcrd,mz){
  256. console.log(mcrd)
  257. var merc = new SphericalMercator({
  258. size: 256
  259. });
  260. var minX = merc.xyz(mcrd, mz).minX;
  261. var maxX = merc.xyz(mcrd, mz).maxX;
  262. var minY = merc.xyz(mcrd, mz).minY;
  263. var maxY = merc.xyz(mcrd, mz).maxY;
  264. var nameList = new Array();
  265. var tileList = new Array();
  266. for(var i=minX;i<=maxX;i++){
  267. for(var j=minY;j<=maxY;j++){
  268. nameList.push(a+"-"+b+"-"+z+"-"+i+"-"+j+".ptp");
  269. tileList.push(a+"-"+b+"-"+z+"-"+i+"-"+j);
  270. }
  271. }
  272. var contents = '<h3>包名列表<div class="close">×</div></h3>' +'<div class="list"><p>'+ nameList.join('</p><p>'
  273. ) + '</p></div>';
  274. var options = "<div class='calculation'><label>选择瓦片类型</label><select id='choose'>"+
  275. "<option>r_dtt_dem</option>"+
  276. "<option>r_google_hybrid</option>"+
  277. "<option>r_google_satellite</option>"+
  278. "<option>r_google_street</option>"+
  279. "<option>r_google_terrain</option>"+
  280. "</select><div><button title='计算包总大小'>计算</button></div></div>";
  281. var shuchu = '<button class="output">输出</button>';
  282. // document.querySelector('.lgPopUp').innerHTML = contents+options;
  283. document.querySelector('.lgPopUp').innerHTML = contents+shuchu;
  284. document.querySelector('.lgPopUp').style.display = "block";
  285. document.querySelector('.close').onclick = function(){
  286. document.querySelector('.lgPopUp').style.display = "none";
  287. }
  288. document.querySelector('.lgPopUp .output').addEventListener('click', saveFile);
  289. $(".lgPopUp .close").off("click").on("click",function(){
  290. $(".lgPopUp").html("").hide();
  291. })
  292. // console.log("minX: "+merc.xyz(mcrd, mz).minX);
  293. // console.log("maxX: "+merc.xyz(mcrd, mz).maxX);
  294. // console.log("minY: "+merc.xyz(mcrd, mz).minY);
  295. // console.log("maxY: "+merc.xyz(mcrd, mz).maxY);
  296. // var cal = document.querySelector('.calculation button');
  297. // cal.onclick = function(){
  298. // var myselect=document.getElementById("choose");
  299. // var index=myselect.selectedIndex; // selectedIndex代表的是你所选中项的index
  300. // // myselect.options[index].value;
  301. // var fileName = myselect.options[index].text;
  302. // L.control.request(fileName, tileList);
  303. // var lgPopUp_total = document.querySelector('.lgPopUp_total');
  304. // var blackBoard = document.querySelector('.blackBoard');
  305. // var tileType = document.querySelector('.lgPopUp_total .tileType');
  306. // var tileSize = document.querySelector('.lgPopUp_total .tileSize');
  307. // var loading = document.querySelector('.lgPopUp_total img');
  308. // var esc = document.querySelector('.lgPopUp_total .esc');
  309. // lgPopUp_total.style.display = "block";
  310. // blackBoard.style.display = "block";
  311. // tileType.innerHTML = fileName;
  312. // loading.style.display = "block";
  313. // esc.innerHTML = "取消";
  314. // tileSize.innerHTML = "";
  315. // }
  316. }
  317. // require(['lgDir/gridLayer_obj'],function(){
  318. // console.log("obj");
  319. // bindEvents();
  320. // })
  321. // function bindEvents(){
  322. var cl_start = new L.canvasLayer;
  323. cl_start.addTo(map2DViewer.map);
  324. // polygon
  325. var polygon = L.polygon([
  326. [0, 0],[0, 0],[0, 0],[0, 0]
  327. ], {color: 'trasparent'}).addTo(map2DViewer.map);
  328. var rule = document.querySelector('#rule .rule'); // 分包规则
  329. var levelSelect = document.querySelectorAll('#rule .level select'); // 分包级别(总)
  330. var diyBtn = document.querySelector('#rule .diyRules button'); // 确定自定义规则
  331. var showGridBtn = document.querySelector('#rule .showGrid'); // 显示网格
  332. var showRangeBtn = document.querySelector('#rule .showRange'); // 显示空间范围
  333. var rangeInput = document.querySelectorAll('#rule .range input'); // 显示空间范围
  334. var generateListBtn = document.querySelector('#rule .generateList'); // 生成包名列表
  335. var activeBag = [[0,9,0],[10,14,7],[15,19,11]]; // 旧分包规则
  336. var diyRules,scale,mz; // 自定义规则等
  337. var mCrd = new Array(); // 包名列表参数
  338. $('#rule .closeRule,.leaflet-contextmenu-item:contains("清空地图")').off("click").on("click",function(){
  339. map2DViewer.map.removeLayer(cl_start);
  340. $("#rule").hide();
  341. map2DViewer.map.removeLayer(polygon);
  342. $("#topBar .total-content .tools-layerGrid").removeClass("cur");
  343. })
  344. // $('.leaflet-contextmenu-item:contains("清空地图")').off('click', gridClear).on('click', gridClear)
  345. rule.onchange = function(){
  346. var grade = rule.options[rule.selectedIndex].value; // 当前所选规则
  347. for(var i=0;i<levelSelect.length;i++){
  348. levelSelect[i].classList.remove("active");
  349. }
  350. switch(parseInt(grade)){
  351. case 0:
  352. document.querySelector('.oldLevel').classList.add("active");
  353. document.querySelector('.diyRules').style.display = "none";
  354. document.querySelector('.level').style.display = "block";
  355. activeBag = [[0,9,0],[10,14,7],[15,19,11]]; // 旧分包规则
  356. diyRules = "";
  357. break;
  358. case 1:
  359. document.querySelector('.newLevel').classList.add("active");
  360. document.querySelector('.diyRules').style.display = "none";
  361. document.querySelector('.level').style.display = "block";
  362. activeBag = [[0,7,0],[8,11,3],[12,15,7],[16,19,11],[20,22,15]]; // 新分包规则
  363. diyRules = "";
  364. break;
  365. case 2:
  366. document.querySelector('.diyRules input').value = "";
  367. document.querySelector('.diyRules').style.display = "inline-block";
  368. document.querySelector('.level').style.display = "none";
  369. activeBag = document.querySelector('.diyRules input').value.replace(/[\ |\[|\]]/g,""); // 自定义分包规则
  370. statu = 2;
  371. break;
  372. }
  373. }
  374. diyBtn.onclick = function(){
  375. diyRules = document.querySelector('.diyRules input').value; // 自定义规则
  376. if(diyRules == ""){
  377. alert("请输入自定义规则");
  378. }
  379. else{
  380. var checkStatu = true;
  381. diyRules = diyRules.replace(/[\ |\[|\]]/g,"").split(",");
  382. console.log("diyRules:"+diyRules);
  383. if(diyRules.length % 3 != 0){
  384. alert("自定义规则位数不正确或格式有误,请检查");
  385. checkStatu = false;
  386. }
  387. for(var j=0;j<diyRules.length;j++){
  388. if(isNaN(diyRules[j])){
  389. checkStatu = false;
  390. alert("自定义规则有误,请检查格式");
  391. break;
  392. }
  393. }
  394. for(var m=1;m<diyRules.length-2;m+=3){
  395. if(diyRules[m]-diyRules[m+2] != -1){
  396. checkStatu = false;
  397. alert("自定义规则分包有误,请检查数值");
  398. break;
  399. }
  400. }
  401. if(checkStatu){
  402. document.querySelector('.diyLevel').innerHTML = "";
  403. for(var i=2;i<diyRules.length;i+=3){
  404. var opt = document.createElement('option');
  405. var t = diyRules[i-2]+"-"+diyRules[i-1]+"-"+diyRules[i];
  406. opt.innerHTML = t; // 新级别名称
  407. opt.value = diyRules[i]; // 赋值value方便显示
  408. document.querySelector('.diyLevel').appendChild(opt);
  409. }
  410. document.querySelector('.diyLevel').classList.add("active");
  411. document.querySelector('.level').style.display = "block";
  412. }
  413. }
  414. }
  415. showGridBtn.onclick = function(){
  416. var levelAct = document.querySelector('.level .active');
  417. z = levelAct.options[levelAct.selectedIndex].value; // 所选分包级别
  418. for(var i=0;i<activeBag.length;i++){
  419. if(activeBag[i][2] == z){
  420. a = parseInt(activeBag[i][0]);
  421. b = parseInt(activeBag[i][1]);
  422. }
  423. }
  424. if(diyRules != "" && diyRules != undefined){
  425. console.log(diyRules);
  426. activeBag = diyRules;
  427. if(diyRules == undefined){
  428. alert("请输入分包范围");
  429. }
  430. for(var i=2;i<activeBag.length;i+=3){
  431. if(activeBag[i] == z){
  432. a = parseInt(activeBag[i-2]);
  433. b = parseInt(activeBag[i-1]);
  434. }
  435. }
  436. }
  437. console.log("a:"+a);
  438. console.log("b:"+b);
  439. // console.log("base:"+z);
  440. scale = L.control.createTilePackage(z,a,b);
  441. }
  442. showRangeBtn.onclick = function(){
  443. var levelAct = document.querySelector('.level .active');
  444. var z = levelAct.options[levelAct.selectedIndex].value; // 所选分包级别
  445. var crds = new Array(); // 传入的坐标
  446. var stat = true;
  447. var lng1 = parseFloat(document.querySelector('.lng1').value);
  448. var lng2 = parseFloat(document.querySelector('.lng2').value);
  449. var lat1 = parseFloat(document.querySelector('.lat1').value);
  450. var lat2 = parseFloat(document.querySelector('.lat2').value);
  451. for(var i=0;i<rangeInput.length;i++){
  452. if(rangeInput[i].value == "" || isNaN(rangeInput[i].value)){
  453. alert("请输入完整坐标(数字)");
  454. crds = "";
  455. stat = false;
  456. break;
  457. }
  458. }
  459. if(stat){
  460. if(lng1 > 180 || lng1 < -180 || lng2 > 180 || lng2 < -180){
  461. alert("请输入正确的经度范围,合法取值范围为:经度[-180,180]");
  462. stat = false;
  463. }
  464. else if(lng2 <= lng1){
  465. alert("请输入正确的经度范围,右下角经度须大于左上角经度");
  466. stat = false;
  467. }
  468. else if(lat1 > 90 || lat1 < -90 || lat2 > 90 || lat2 < -90){
  469. alert("请输入正确的纬度范围,合法取值范围为:纬度[-90,90]");
  470. stat = false;
  471. }
  472. else if(lat1 <= lat2){
  473. alert("请输入正确的纬度范围,左上角纬度必须大于右下角纬度");
  474. stat = false;
  475. }
  476. else{
  477. crds.push(lng1,lng2,lat1,lat2);
  478. }
  479. }
  480. if(crds.length == 4){
  481. L.control.fitBds(crds,z);
  482. }
  483. // console.log(crds);
  484. }
  485. generateListBtn.onclick = function(){
  486. if(mCrd == ""){
  487. alert("请先显示空间范围");
  488. }
  489. else{
  490. L.control.showNameList(mCrd,mz);
  491. }
  492. }
  493. function fakeClick(obj) {
  494.   var ev = document.createEvent("MouseEvents");
  495.     ev.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  496.     obj.dispatchEvent(ev);
  497.   }
  498.   function exportRaw(name, data) {
  499.     var urlObject = window.URL || window.webkitURL || window;
  500.     var export_blob = new Blob([data]);
  501.     var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
  502.     save_link.href = urlObject.createObjectURL(export_blob);
  503.     save_link.download = name;
  504.     fakeClick(save_link);
  505.   }
  506.   function saveFile(){
  507.     var pv = document.querySelectorAll('.lgPopUp div.list p');
  508. var mobileCode = '';
  509. for(var i=0;i<pv.length;i++){
  510. mobileCode+=pv[i].innerHTML+",";
  511. }
  512. // console.log(mobileCode);
  513. var v = IEVersion();
  514. if(v == 'ie' || v == 'Edge'){
  515. var fileObj = new Blob([mobileCode],{type:'json/application'});
  516. // ////console.log(fileObj);
  517. window.navigator.msSaveBlob(fileObj,'包名列表.csv');
  518. } else if(v == '-1'){
  519. var file = new File([mobileCode], '包名列表.csv', { type: "text/plain;charset=utf-8" });
  520. saveAs(file);
  521. }
  522. //     exportRaw('包名列表.csv', mobileCode);
  523.   }
  524. //判断是否是IE浏览器,包括Edge浏览器
  525. function IEVersion() {
  526. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  527. var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE浏览器
  528. var isEdge = userAgent.indexOf("Windows NT 6.1; Trident/7.0;") > -1 && !isIE; //判断是否IE的Edge浏览器
  529. if(isIE) {
  530. return "ie";
  531. } else if(isEdge) {
  532. return "Edge";
  533. } else{
  534. return "-1";//非IE
  535. }
  536. }
  537. // }
  538. return ONEMAP.M.GridLayer = {
  539. init: init,
  540. };
  541. })