/* * 加载区域统计 */ function loadAreaStatistics(fun) { // var crowdId = null, crowdIdTo = null; TD.Util.ajax({ url: '/areafence/listArea', data: { type: type, calendarstart: calendarstart, calendarend: calendarend, starttime: starttime, endtime: endtime, crowdId: crowdId, crowdIdTo: crowdIdTo == null ? "" : crowdIdTo }, type: 'get', success: function (data) { if (data.code == 200) { //清楚多余返回的数据 if (crowdIdTo == null) { data.data.length = 1; } clearData(penData1); if (penData2) { clearData(penData2); } mapOverlayMain.setPoints([]); if (mapOverlay1) { mapOverlay1.setPoints([]); } if (mapOverlay2) { mapOverlay2.setPoints([]); } getBoundary("宝山区", "#fff"); getBoundary("嘉定区", "#fff"); getBoundary("闵行区", "#fff"); getBoundary("松江区", "#fff"); getBoundary("青浦区", "#fff"); getBoundary("奉贤区", "#fff"); getBoundary("金山区", "#fff"); getBoundary("黄浦区", "#fff"); getBoundary("静安区", "#fff"); getBoundary("徐汇区", "#fff"); getBoundary("长宁区", "#fff"); getBoundary("杨浦区", "#fff"); getBoundary("虹口区", "#fff"); getBoundary("普陀区", "#fff"); getBoundary("浦东新区", "#fff"); if (typeof console == "undefined") { window.console = { log: function () {} } } var map = new BMap.Map("passengerRegion-main"); var point = new BMap.Point(121.5241838920, 31.2338442624); map.centerAndZoom(point, 11); var stdMapCtrl = new BMap.NavigationControl({ type: BMAP_NAVIGATION_CONTROL_SMALL }); map.addControl(stdMapCtrl); map.enableScrollWheelZoom(); map.enableContinuousZoom(); function markText(point, pointName) { var marker = new BMap.Marker(point); map.addOverlay(marker); var label = new BMap.Label(pointName, { offset: new BMap.Size(-20, -10) }); marker.setLabel(label) }; function getBoundary(name, color) { var bdary = new BMap.Boundary(); bdary.get(name, function (rs) { var bounds; var maxNum = -1, maxPly; var count = rs.boundaries.length; for (var i = 0; i < count; i++) { var ply = new BMap.Polygon(rs.boundaries[i], { strokeWeight: 1, strokeColor: "#2747e8", FillOpacity: 0 }); ply.setFillColor(color); ply.setFillOpacity("0.8"); map.addOverlay(ply) } if (maxPly) { map.setViewport(maxPly.getPoints()) } }) }; var arr = []; function markText(point, pointName, pointRate) { var marker = new BMap.Marker(point); map.addOverlay(marker); var label = new BMap.Label(pointName + '-' + pointRate, { offset: new BMap.Size(-20, -10) }); marker.setLabel(label) } for (var i = 0; i < data.data.length; i++) { if (data.data[i]) { debugger; for (var j = 0; j < data.data[i].length; j++) { if (data.data[i][j].point !== null) { var pointLng = data.data[i][j].point.lng; var pointLat = data.data[i][j].point.lat; var pointName = data.data[i][j].name; var pointRate = data.data[i][j].rate; markText(new BMap.Point(pointLng, pointLat), pointName, pointRate) } } var temp = null; if (type == "1") { debugger; temp = JSON.parse(JSON.stringify(penData1)); } else if (type == "2") { temp = JSON.parse(JSON.stringify(penData2)); } setData(temp, data.data[i]); temp.sort(function (a, b) { return parseFloat(b.rate) - parseFloat(a.rate); }); arr.push(temp); if (data.data.length == 1) { mapOverlayMain.setPoints(temp); } else { if (i == 0) { mapOverlay1.setPoints(temp); } else if (i == 1) { if (mapOverlay2) { mapOverlay2.setPoints(temp); } } } } } showList(arr); // fun(arr); } else { clear(); } }, error: function (data) {} })}
百度地图api--加覆盖物
最新推荐文章于 2024-03-29 14:35:25 发布