| | |
| | | var mapType = getUrlParam("mapType"); |
| | | var mapOption = {}; |
| | | if(!!mapType && !!eval(mapType)) { |
| | | mapOption["mapType"] = jieval(mapType); |
| | | mapOption["mapType"] = eval(mapType); |
| | | } |
| | | var showZoom = getUrlParam("showZoom"); |
| | | //通过地区名称加载地图 |
| | | moralMap.mapInit(params["regionName"],mapOption); |
| | | moralMap.mapInit(params["regionName"],mapOption,showZoom); |
| | | //列表对象 |
| | | var listView =moralMap.initListView({id: "#equ_list",pageSize:12}); |
| | | window["listView"] = listView; |
| | |
| | | paramMap["Le"]= bounds.southwestLng;//西北角经度坐标,小一点 |
| | | loadLazy("getMonitorpointList",paramMap,addOverMpoints); |
| | | startRefreshPage(); |
| | | showGrid(); |
| | | }); |
| | | //地图加载完成后 加载监控点,速度慢 |
| | | moralMap.addEventListener("tilesloaded", function(type, target) { |
| | | showGrid(); |
| | | }); |
| | | |
| | | //map为地图对象 |
| | | // TODO 临时 |
| | | function bs() { |
| | | var bs = moralMap.getBounds(); //获取当前地图范围的经纬度 |
| | | // var bssw = bs.getSouthWest(); //获取西南角的经纬度(左下端点) |
| | | // var bsne = bs.getNorthEast(); //获取东北角的经纬度(右上端点) |
| | | return { 'x1': bs.southwestLng, 'y1': bs.southwestLat, 'x2': bs.northeastLng, 'y2': bs.northeastLat }; |
| | | } |
| | | /** |
| | | * 显示网格 |
| | | */ |
| | | // TODO 临时 |
| | | function showGrid(){ |
| | | var isShowGrid = getUrlParam("isShowGrid"); |
| | | if(!!isShowGrid){ |
| | | $(".tools_box").hide(); |
| | | } |
| | | // if(!isShowGrid||moralMap.getZoom()<14){ |
| | | if(!isShowGrid||moralMap.getZoom()<14){ |
| | | return; |
| | | } |
| | | var XY = bs(); |
| | | var polygons = []; |
| | | console.log(XY); |
| | | for (var i = XY.x1; i < XY.x2; i = i + 0.0063) { |
| | | for (var j = XY.y2; j > XY.y1; j = j - 0.0048) { |
| | | //此类表示绘制一个多边形覆盖物(注意:一定要下面的Point列表为多变形的顶点,描线顺序为从上到下,从左到右,顺序乱了,绘制出来的多边形也会乱,如图二所示,图二是将顶点的顺序给错了(网格左上端点,网格左下端点,网格右上端点,网格右下端点)) |
| | | var polygon = new BMap.Polygon([ |
| | | new BMap.Point(i, j), //网格左上端点 |
| | | new BMap.Point(i, j-0.0048), //网格左下端点 |
| | | new BMap.Point(i+0.0063, j-0.0048), //网格右下端点 |
| | | new BMap.Point(i+0.0063, j) //网格右上端点 |
| | | ], {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5, fillOpacity:0.1}); |
| | | // polygon .addEventListener("click",function clickFunction(){ |
| | | // alert("你居然敢点我"); |
| | | // }); |
| | | // moralMap.addOverlay(polygon); |
| | | polygons.push(polygon); |
| | | } |
| | | } |
| | | moralMap.addOverlays(polygons); |
| | | if(!!showGrid.polygons){ |
| | | moralMap.removeOverlays(showGrid.polygons); |
| | | } |
| | | showGrid.polygons = polygons; |
| | | } |
| | | // 点击事件关闭 弹窗列表 |
| | | moralMap.addEventListener("click", function(type, target) { |
| | | moralMap.closePopupbox("#popup_box"); |
| | |
| | | //地图放大缩小事件时,关闭弹窗 |
| | | moralMap.addEventListener('zoomend', function(type) { |
| | | var endZoom = this.getZoom(); |
| | | if(endZoom>=moralMap.getZooMConfine()){//超过界限加载设备 |
| | | if(endZoom>=moralMap.getZoomConfine()){//超过界限加载设备 |
| | | loadOverlays("get-devices",addOverEquipments); |
| | | }else{ |
| | | loadOverlays("get-monitorpoints",addOverMpoints); |
| | |
| | | }); |
| | | moralMap.addEventListener('moveend', function(type) { |
| | | var endZoom = this.getZoom(); |
| | | if(endZoom>=moralMap.getZooMConfine()){//超过界限加载设备 |
| | | if(endZoom>=moralMap.getZoomConfine()){//超过界限加载设备 |
| | | loadOverlays("get-devices",addOverEquipments); |
| | | }else{ |
| | | loadOverlays("get-monitorpoints",addOverMpoints); |