zoukankan      html  css  js  c++  java
  • 百度地图动态添加数据及条件查询

    效果图:

    function initMapData(){
    		
    			 var points = [];  // 添加海量点数据
    			 map.clearOverlays();
    			// map1.clearOverlays();
    			 var year =document.getElementById("year").value;
    			 var provinceid =document.getElementById("sheng").value;
    			 var quota_1 =document.getElementById("quota_1").value;
    			 var quota_2 =document.getElementById("quota_2").value;
    			 var quota_3 =document.getElementById("quota_3").value;
    			 var quota_4 =document.getElementById("quota_4").value;
    			
    			 var index = "";
    			 if(quota_1 != ""){index = quota_1};
    			 if(quota_2 != ""){index = quota_2};
    			 if(quota_3 != ""){index = quota_3};
    			 if(quota_4 != ""){index = quota_4};
    			 $.ajax({url:"./EnterpriseAnalysisFetcher.do?action=envmap",
    					type:"POST",dataType:"JSON",async:false,
                //传过去year,pronvinceid,index:指标 success到x,y的坐标 data:{"provinceid":provinceid,"year":year,"index":index}, success: function(datas){ $.each(datas,function(i,n){ if(n.lng!=null){
                  //遍历查询到的值,put到points里面 points.push(new BMap.Point(parseFloat(n.lng), parseFloat(n.lat))); } });
    public CompanyPosition[] getCompanyEnvData(int year, int provinceid,
    			String index,DBSession session) throws JException {
    		
    		List<CompanyPosition> list = new ArrayList<CompanyPosition>();
    		if (session == null) {
    			session = Context.getDBSession();
    
    		}
    		IResultSet rs = null;
    		try {
    			Object[] paramObjects = new Object[]{};
    			int[] paramTypes = new int[]{};
    			String sql = "select b.cp_lng,cp_lat from env_pollutiondata a,env_company b where a.pd_company_ID=b.ID and "+index+">0 ";
    			if(year>0){
    				sql = sql + " and a.pd_year =?";
    			}
    			if(provinceid>0){
    				sql = sql + " and a.pd_Province_ID =?";
    			}
    			if(year>0&&provinceid>0){
    				paramObjects = new Object[]{year,provinceid};
    				paramTypes = new int[]{year,provinceid};
    			}else if(year>0){
    				paramObjects = new Object[]{year};
    				paramTypes = new int[]{year};
    			}else if(provinceid>0){
    				paramObjects = new Object[]{provinceid};
    				paramTypes = new int[]{provinceid};
    			}
    			sql = sql+" GROUP BY a.pd_company_ID ";
    			//sql = "SELECT * FROM env_pollutiondata WHERE ID = 1";
    			
    			//rs = session.executeQuery(sql, new Object[]{paramObjects}, new int[]{Types.DECIMAL});
    			rs = session.executeQuery(sql, paramObjects, paramTypes);
    			System.out.println(sql);
    			while (rs.next()) {
    
    				CompanyPosition position = new CompanyPosition();
    				position.setLat(rs.getFloat("cp_lat"));
    				position.setLng(rs.getFloat("cp_lng"));
    				float po = rs.getFloat("cp_lat");
    				float pl = rs.getFloat("cp_lng");
    				list.add(position);
    			}
    		} catch (Exception e) {
    			Logger.getProjLogger().error(e.getMessage(), e);
    			return null;
    		} finally {
    			ResourceMgr.closeQuietly(rs);
    			ResourceMgr.closeQuietly(session);
    		}
    		return list.toArray(new CompanyPosition[0]);
    

      

    var options = { size: BMAP_POINT_SIZE_BIGGER, shape: BMAP_POINT_SHAPE_WATERDROP, color: '#d340c3' } var pointCollection = new BMap.PointCollection(points, options); // 初始化PointCollection pointCollection.addEventListener('click', function (e) { var opts = { width : 250, // 信息窗口宽度 height: 100, // 信息窗口高度 title : "企业信息" , // 信息窗口标题 enableMessage:false//设置允许信息窗发送短息 }; var point = new BMap.Point(e.point.lng, e.point.lat); $.ajax({ type: "POST", url: "../env/data/EnvDataSubmit.do?action=getCompanyDataByPosition&position="+e.point.lng+e.point.lat, dataType:"json", async: true, success: function(msg){ var content=[]; if(msg){ content.push(msg[0].company); content.push("<br />"); $.each(msg,function(i,n){ content.push("    <a target="_blank" href="EnvDataListView.do?id="+n.id+"" >"+n.year+"</a>    "); }); var infoWindow = new BMap.InfoWindow(content.join(""),opts); // 创建信息窗口对象 map.openInfoWindow(infoWindow,point); //开启信息窗口 map1.openInfoWindow(infoWindow,point); //开启信息窗口 } } }); }); map.addOverlay(pointCollection); // 添加Overlay // map1.addOverlay(pointCollection); // 添加Overlay points = []; }, error:function (XMLHttpRequest, textStatus, errorThrown) { alert("error"); alert(textStatus); } }); }

      

  • 相关阅读:
    分享一个流程实例运行时出现异常的恢复方案
    为什么要从事BPM开发
    分享两个BPM配置小技巧
    说说BPM数据表和日志表中几个状态字段的详细解释
    流程表单中js如何清空SheetUser控件数据?
    如何解决流程开发中SheetRadioButtonList页面取值问题
    把一个syn报文给rst掉
    linux io的cfq代码理解一
    xfs 的一些工具使用
    你知道这段代码为什么会段错误么?
  • 原文地址:https://www.cnblogs.com/xiaoxiao5ya/p/4770364.html
Copyright © 2011-2022 走看看