czt
5 天以前 d24dd35d265a0b6bd0620285d226b5bed3d4566e
fzzy-igdss-web/src/main/resources/static/group/gis.js
ÎļþÃû´Ó fzzy-igdss-web/src/main/resources/static/group/gis-index.js ÐÞ¸Ä
@@ -1,8 +1,8 @@
var colors = {};
var map;
var disProvince;//行政区颜色渲染
var deptAreasMap = {};
var allDeptMap = {};
var deptListMap = {};
var allAreaMap = {};
var markers = [];//点标记
var type = "0";
var county = "all";
@@ -10,18 +10,21 @@
//var switch2AreaNode2;
$(function () {
    if (deptAreas) {
        for (var i = 0; i < deptAreas.length; i++) {
            deptAreasMap[deptAreas[i].id] = deptAreas[i];
    //所有库区
    if (deptList) {
        for (var i = 0; i < deptList.length; i++) {
            deptListMap[deptList[i].id] = deptList[i];
        }
    }
    if (allDept) {
        for (var i = 0; i < allDept.length; i++) {
            allDeptMap[allDept[i].id] = allDept[i];
    //所有省市
    if (allArea) {
        for (var i = 0; i < allArea.length; i++) {
            allAreaMap[allArea[i].code] = allArea[i];
        }
    }
    //初始化时间
    //initTime();
    initTime();
    //初始化地图
    initMap();
@@ -37,16 +40,29 @@
    );
    //渲染部门
    //renderDepts();
    renderList();
    //大屏标语
    //initDicSlogan();
    //renderAreas(654000);
    setTimeout(function () {
         renderAreas(654000);
        renderAreas(650000);
    }, 2000);
    $('.sup-menu-title').click(function(){
        var kai = $(this).parent(".sup-menu-group")
        if (kai.hasClass('menu-group')) {
            kai.removeClass('menu-group')
        } else{
            kai.addClass('menu-group')
        }
    });
    $('.sup-menu-h').click(function(){
        var kai2 = $(this).parents(".sup-menu-ul")
        if (kai2.hasClass('menu-h')) {
            kai2.removeClass('menu-h')
        } else{
            kai2.addClass('menu-h')
        }
    });
});
// åˆ·æ–°æ—¶é—´
@@ -60,8 +76,8 @@
function initMap() {
    map = new AMap.Map('map_container', {
        center: [81.323691, 43.917106],
        zoom: 9,
        center: [83.721646, 40.627714],
        zoom: 5.6,
        mapStyle: 'amap://styles/41f8248740d3659ddc65dc363078592c',
        // rotateEnable:true,
        // pitchEnable:true,
@@ -74,7 +90,7 @@
    new AMap.DistrictSearch({
        extensions: 'all',
        subdistrict: 0
    }).search('伊犁哈萨克自治州', function (status, result) {
    }).search('新疆维吾尔自治区', function (status, result) {
        // å¤–多边形坐标数组和内多边形坐标数组
        var outer = [
            new AMap.LngLat(-360, 90, true),
@@ -105,52 +121,34 @@
    //默认行政区域编码
    renderColor(defaultAreaCode);
}
//socket信息返回處理
function socketOnMessage(pocket) {
    if (pocket.userId == "slogan") {
        var data = pocket.data;
        dicSlogan = data;
        initDicSlogan();
    }
    // renderColor(defaultAreaCode);
}
/**
 * åˆå§‹æ ‡è¯­æ•°æ®
 * èŽ·å–å¸‚å·žä¸‹åº“åŒºä¿¡æ¯
 */
function initDicSlogan() {
    if (dicSlogan) {
        if (dicSlogan.color == "red") {
            $("#sloganText").css({
                color: "#DE2910"
            });
        } else {
            $("#sloganText").css({
                color: "#7ddfff"
            });
        }
        $("#sloganText").text(dicSlogan.content);
    }
}
/**
 * æ ¹æ®åŒºåŽ¿èŽ·å–åº“åŒº
 */
function getDeptArea(city, county) {
function getDeptArea(province, county) {
    var list = [];
    if (deptAreas) {
        for (var i = 0; i < deptAreas.length; i++) {
            if (city == deptAreas[i].deptCity) {
                list.push(deptAreas[i]);
    if (deptList) {
        if (province && province.length > 0) {
            var str1 = province.substring(0, 2);
            for (var i = 0; i < deptList.length; i++){
                if(deptList[i].xzqhdm.startsWith(str1)){
                    list.push(deptList[i]);
                }
            }
            if (county == deptAreas[i].deptCounty) {
                list.push(deptAreas[i]);
        }
        if (county && county.length > 0) {
            var str2 = county.substring(0, 4);
            for (var i = 0; i < deptList.length; i++) {
                if(deptList[i].xzqhdm.startsWith(str2)){
                    list.push(deptList[i]);
                }
            }
        }
    }
    return list;
}
@@ -158,7 +156,7 @@
 * ç”¨æˆ·ç‚¹å‡»åŸŽå¸‚或者县级区级渲染库区点位
 */
function renderAreas(deptId) {
    var d = allDeptMap[deptId];
    var d = allAreaMap[deptId];
    if (d) {
        closeInfoWindow();
        removeColor();
@@ -166,10 +164,10 @@
        //map.setCity(deptId);
        renderColor(deptId);
        var a = [];
        if ("10" == d.type) {
        if ("1" == d.type) {
            a = getDeptArea(deptId, "")
        }
        if ("11" == d.type) {
        if ("2" == d.type) {
            a = getDeptArea("", deptId)
        }
        if (a && a.length > 0) {
@@ -179,12 +177,10 @@
        }
        //刷新数据
        county = deptId;
       // ajaxFoodNum();
        // ajaxFoodNum();
    } else {
        console.log("没有获取到该行政区划:" + deptId);
    }
    //陕西
}
/**
@@ -192,7 +188,7 @@
 * @param deptAreaId
 */
function showAreaInfo(deptAreaId) {
    var d = deptAreasMap[deptAreaId];
    var d = deptListMap[deptAreaId];
    if (d) {
        closeInfoWindow();
        removeColor();
@@ -209,40 +205,40 @@
/**
 * æ¸²æŸ“库区列表
 */
function renderDepts() {
    if (depts) {
function renderList() {
    if (areaList) {
        var html = "";
        var childs = [];
        var areas = [];
        for (var i = 0; i < depts.length; i++) {
        for (var i = 0; i < areaList.length; i++) {
            html += "<div style=\"width: 305px; overflow: hidden\">" +
                "<div class=\"sup-menu-group menu-group\">" +
                "<div class=\"sup-menu-title\">" +
                "<i class=\"i-icon fl\"><img src=\"/static/images/visual/icon-sj.png\"/></i>" +
                "<a href=\"###\" onclick=\"renderAreas('" + depts[i].id + "')\">" +
                "<span class=\"i-icon32 fl\"><img src=\"/static/images/visual/c-i2.png\"/></span>" +
                (depts[i].name ? depts[i].name : "") +
                "<i class=\"i-icon fl\"><img src=\"/img/web/group/icon-sj.png\"/></i>" +
                "<a href=\"###\" onclick=\"renderAreas('" + areaList[i].code + "')\">" +
                "<span class=\"i-icon32 fl\"><img src=\"/img/web/group/c-i2.png\"/></span>" +
                (areaList[i].name ? areaList[i].name : "") +
                "</a>" +
                "</div>";
            if (depts[i].children && depts[i].children.length > 0) {
                childs = depts[i].children;
            if (areaList[i].children && areaList[i].children.length > 0) {
                childs = areaList[i].children;
                for (var j = 0; j < childs.length; j++) {
                    html += "<ul class=\"sup-menu-ul  menu-h\">" +
                        "<li>" +
                        "<div class=\"sup-menu-h\">" +
                        "<i class=\"i-icon fl\"><img src=\"/static/images/visual/icon-sj.png\"/></i>" +
                        "<a href=\"###\" onclick=\"renderAreas('" + childs[j].id + "')\">" +
                        "<span class=\"i-icon32 fl\"><img src=\"/static/images/visual/c-i2.png\"/></span>" +
                        "<i class=\"i-icon fl\"><img src=\"/img/web/group/icon-sj.png\"/></i>" +
                        "<a href=\"###\" onclick=\"renderAreas('" + childs[j].code + "')\">" +
                        "<span class=\"i-icon32 fl\"><img src=\"/img/web/group/c-i2.png\"/></span>" +
                        (childs[j].name ? childs[j].name : "") +
                        "</a>" +
                        "</div>";
                    areas = getDeptArea("", childs[j].id);
                    areas = getDeptArea("", childs[j].code);
                    if (areas && areas.length > 0) {
                        for (var k = 0; k < areas.length; k++) {
                            html += "<div class=\"sup-menu-box\">" +
                                "<p>" +
                                "<span class=\"i-icon32 fl\"><img src=\"/static/images/visual/icon-kuqu.png\"/></span>" +
                                "<a href=\"#\" onclick=\"showAreaInfo('" + areas[k].id + "')\">" + areas[k].name + "</a>" +
                                "<span class=\"i-icon32 fl\"><img src=\"/img/web/group/icon-kuqu.png\"/></span>" +
                                "<a href=\"#\" onclick=\"showAreaInfo('" + areas[k].id + "')\">" + areas[k].kqmc + "</a>" +
                                "</p>" +
                                "</div>";
                        }
@@ -252,15 +248,15 @@
                }
            } else {
                //没有子节点,直接就是区级别
                areas = getDeptArea("", depts[i].id);
                areas = getDeptArea("", areaList[i].code);
                if (areas && areas.length > 0) {
                    for (var k = 0; k < areas.length; k++) {
                        html += "<ul class=\"sup-menu-ul\">" +
                            "<li>" +
                            "<div class=\"sup-menu-h\">" +
                            "<i class=\"i-icon fl\"><img src=\"/static/images/visual/icon-sj.png\"/></i>" +
                            "<a href=\"###\" onclick=\"renderAreas('" + areas[k].id + "')\">" +
                            "<span class=\"i-icon32 fl\"><img src=\"/static/images/visual/icon-kuqu.png\"/></span>" +
                            "<i class=\"i-icon fl\"><img src=\"/img/web/group/icon-sj.png\"/></i>" +
                            "<a href=\"###\" onclick=\"renderAreas('" + areas[k].code + "')\">" +
                            "<span class=\"i-icon32 fl\"><img src=\"/img/web/group/icon-kuqu.png\"/></span>" +
                            (areas[k].name ? areas[k].name : "") +
                            "</a>" +
                            "</div>";
@@ -305,7 +301,7 @@
            // "                        <p>天府新区</p>" +
            "                        <span class=\"map-round\"></span>" +
            "                    </div>";
        var position = [deptArea.lon, deptArea.lat];
        var position = [deptArea.jd, deptArea.wd];
        var marker = new AMap.Marker({
            position: position,
            // å°† html ä¼ ç»™ content
@@ -375,54 +371,54 @@
        "<div class=\"BMap_bubble_center\" style=\"z-index: 3; position: relative; height: 324px; width: 376px;\">" +
        "<div class=\"BMap_bubble_content\" style=\"font-size: 14px; line-height: 24px; position: absolute; top: 2px; color: rgb(85, 85, 85); width: 364px; height: 324px; overflow: auto;\">" +
        '<div style=\"height:100%;box-sizing:border-box;\">' +
        '<div style="height: 34px;">'+
        '<div style="height: 34px;">' +
        '<div style="width: 320px;float: left;">';
    if (deptArea.name.length>17) {
        content += '<h3 style="margin:0 0 10px 0;line-height:24px;font-size:14px;color:#fff;">' + (deptArea.name ? deptArea.name : "没有获取到库区信息") + '</h3>' ;
    }else{
        content +=  '<h3 style="margin:0 0 10px 0;line-height:24px;font-size:18px;color:#fff;">' + (deptArea.name ? deptArea.name : "没有获取到库区信息") + '</h3>' ;
    if (deptArea.kqmc.length > 17) {
        content += '<h3 style="margin:0 0 10px 0;line-height:24px;font-size:14px;color:#fff;">' + (deptArea.kqmc ? deptArea.kqmc : "没有获取到库区信息") + '</h3>';
    } else {
        content += '<h3 style="margin:0 0 10px 0;line-height:24px;font-size:18px;color:#fff;">' + (deptArea.kqmc ? deptArea.kqmc : "没有获取到库区信息") + '</h3>';
    }
    content += '</div>'+
    content += '</div>' +
        '<div style="width: 40px;float: left;">' +
        '<img style="height: 20px;" src="../../static/images/visual/icon_close.png" onclick="closeInfoWindow()"></img>' +
        '</div>'+
        '</div>'+
        '<img style="height: 20px;" src="/img/web/group/icon_close.png" onclick="closeInfoWindow()"></img>' +
        '</div>' +
        '</div>' +
        '<p style="line-height:24px;font-size:12px;color:#fff;margin-right: 15px;"><img src="../../static/images/visual/icon-address.png" alt="" style="float:left;width: 16px;height: 16px;margin-right:3px;margin-top: 5px;"/>' + (deptArea.address ? deptArea.address + "(" + deptArea.lon + "," + deptArea.lat + ")" : "没有获取到库区信息") + '</P>' +
        '<p style="line-height:24px;font-size:12px;color:#fff;margin-right: 15px;"><img src="/img/web/group/icon-address.png" alt="" style="float:left;width: 16px;height: 16px;margin-right:3px;margin-top: 5px;"/>' + (deptArea.kqdz ? deptArea.kqdz + "(" + deptArea.jd + "," + deptArea.wd + ")" : "没有获取到库区信息") + '</P>' +
        '<div class="right-topInfo-kd " style="height: 80px;width: 270px;margin: 5px auto 10px auto;">' +
        '<div class="right-topInfo-kd-item">' +
        '<h3>粮仓个数(个)</h3>' +
        '<p>' + (deptArea.depotNum ? deptArea.depotNum : 0) + '</p>' +
        '<p>' + (deptArea.cfs ? deptArea.cfs : 0) + '</p>' +
        '</div>' +
        '<div class="right-topInfo-kd-item">' +
        '<h3>油罐个数(个)</h3>' +
        '<p>' + (deptArea.depotOilNum ? deptArea.depotOilNum : 0) + '</p>' +
        '<p>' + (deptArea.cfs ? deptArea.cfs : 0) + '</p>' +
        '</div>' +
        '</div>' +
        '<ul class="right-topInfo-kd-list right-topInfo-jg sup-topInfo-list">' +
        '<li>';
    if (deptArea.storage && (deptArea.storage + "").length > 4) {
        content += '<p style="font-size: 22px">' + (deptArea.storage ? deptArea.storage.toFixed(3) : 0) + '</p>';
    if (deptArea.cfs && (deptArea.cfs + "").length > 4) {
        content += '<p style="font-size: 22px">' + (deptArea.cfs ? deptArea.cfs.toFixed(3) : 0) + '</p>';
    } else {
        content += '<p style="font-size: 22px">' + (deptArea.storage ? deptArea.storage.toFixed(3) : 0) + '</p>';
        content += '<p style="font-size: 22px">' + (deptArea.cfs ? deptArea.cfs.toFixed(3) : 0) + '</p>';
    }
    content += '<h3>粮食储量(吨)</h3>'+
    content += '<h3>粮食储量(吨)</h3>' +
        '</li>' +
        '<li>';
    if (deptArea.storage && (deptArea.oilStorage + "").length > 4) {
        content += '<p style="font-size: 22px">' + (deptArea.oilStorage ? deptArea.oilStorage.toFixed(3) : 0) + '</p>';
    if (deptArea.cfs && (deptArea.cfs + "").length > 4) {
        content += '<p style="font-size: 22px">' + (deptArea.cfs ? deptArea.cfs.toFixed(3) : 0) + '</p>';
    } else {
        content += '<p style="font-size: 22px">' + (deptArea.oilStorage ? deptArea.oilStorage.toFixed(3) : 0) + '</p>';
        content += '<p style="font-size: 22px">' + (deptArea.cfs ? deptArea.cfs.toFixed(3) : 0) + '</p>';
    }
    content += '<h3>植物油储量(吨)</h3>' +
        '</li>' +
        '<li>' +
        '<p style="font-size: 22px" >' + (deptArea.area ? deptArea.area : 0) + '</p>' +
        '<p style="font-size: 22px" >' + (deptArea.zdmj ? deptArea.zdmj : 0) + '</p>' +
        '<h3>占地面积(㎡)</h3>' +
        '</li>' +
        '</ul>' +
        '<a href="javaScript:;" onclick="toHomeDetail(\'' + deptAreaId + '\')"  class="sup-deatil-link"><img src="../../static/images/visual/spu-detail-btn.png" alt="" style="width:100%;height:100%;"/></a>' +
        '<a href="javaScript:;" onclick="toHomeDetail(\'' + deptAreaId + '\')"  class="sup-deatil-link"><img src="/img/web/group/spu-detail-btn.png" alt="" style="width:100%;height:100%;"/></a>' +
        '</div>' +
        "</div></div><div class=\"BMap_bubble_bottom\" style=\"display: block; z-index: 2; position: absolute; width: 376px;\">" +
        "</div><img style=\"z-index: 1; position: absolute; width: 58px; height: 31px; left: 159px; bottom: -30px; top: 356px;\" src=\"http://webmap0.bdimg.com/image/api/iw_tail.png\"></div>";
@@ -435,7 +431,7 @@
 * @param id
 */
function toHomeDetail(id) {
    var url = "../home?t=grain&deptAreaId=" + id;
    var url = "/index?deptId=" + id;
    window.parent.open(url, "_self");
};
@@ -444,23 +440,6 @@
 * @param adcode
 */
function renderColor(adcode) {
    // disProvince = new AMap.DistrictLayer.Province({
    //     zIndex: 12,
    //     adcode: adcode,
    //     depth: 2,
    //     opacity: 0.6,
    //     styles: {
    //         'fill': function (properties) {
    //             var adcode = properties.adcode;
    //             return getColorByAdcode(adcode);
    //         },
    //         'province-stroke': 'cornflowerblue',
    //         'city-stroke': 'white',//中国地级市边界
    //         'county-stroke': 'rgba(255,255,255,0.5)'//中国区县边界
    //     }
    // });
    // disProvince.setMap(map);
    //window.switch2AreaNode2(adcode);
    switch2AreaNode(adcode);
}