北京经济技术开发区经开区虚拟城市项目-【前端】-移动端Web
11
少年
2024-02-07 9736514b2aa57051e934341b23a2f6b123cc06a9
src/utils/map2.js
@@ -751,7 +751,9 @@
                            lon: lon,
                            lat: lat,
                        }
                    } else if (propertyNames.includes("id")) {
                    }
                    else if (propertyNames.includes("id")) {
                        objdata = {
                            POITYPE: "POINT",
                            name: properties["_name"]._value,
@@ -2213,7 +2215,7 @@
    });
    if (window.pointArr && window.pointArr.length > 0) {
        window.pointArr.forEach(item => {
            window.map.removeLayer(item)
            window.mapapi.removeLayer(item)
        })
        window.pointArr = []
    }
@@ -2243,7 +2245,7 @@
//openlayer 地图点击事件
export function setClick(state) {
    function handleClick(e) {
        console.log(e.coordinate);
        store.setLayerPanelShow(false);
        // 土地管理
        if (store.tdglInfo.flag) {
            axios
@@ -2257,7 +2259,7 @@
                ).then(response => {
                    let center = { lon: 0, lat: 0 };
                    if (window.tdglLine) {
                        window.map.removeLayer(window.tdglLine);
                        window.mapapi.removeLayer(window.tdglLine);
                        window.tdglLine = null;
                    }
                    var format = new ol.format.WKT(); // 创建一个 WKT 解析器
@@ -2269,7 +2271,7 @@
                            features: [feature] // 将要素对象加入到图层源中
                        })
                    });
                    window.map.addLayer(window.tdglLine)
                    window.mapapi.addLayer(window.tdglLine)
                    axios
@@ -2362,19 +2364,94 @@
            return;
        }
        window.map.forEachFeatureAtPixel(e.pixel, function (feature) {
        window.mapapi.forEachFeatureAtPixel(e.pixel, function (feature) {
            let properties = feature.getProperties().features[0].values_;
            console.log(properties, 'aaa');
            console.log(properties.values_, 'bbb');
            for (const propertyNames in properties) {
                if (propertyNames.indexOf("监控名") !== -1) {
                    // objdata = {
                    //     POITYPE: "SPJK",
                    //     name: properties["JK名称"]._value,
                    //     type: properties["JK类型"]._value,
                    //     function: properties["功能"]._value,
                    //     area: properties["所在区"]._value,
                    //     number: properties["JK编号"]._value,
                    //     code: properties["JK内码"]._value,
                    //     lon: lon,
                    //     lat: lat,
                    // }
                    Message({
                        message: '连接状态查询中',
                        type: 'info',
                        offset: 60,
                        center: true,
                        duration: 1000,
                    });
                    layerOpen(properties["JK名称"]._value, {
                        width: "100%",
                        height: "40%",
                        // offset: [offsetTop + "px", "380px"],
                        url: "../../static/video/video.html?code=" + properties["JK内码"]._value,
                        fn: {
                            success: (layero, index) => {
                                SmartEarthPopupData.layerContainer = layero;
                            },
                            end: () => {
                            },
                            cancel: () => {
                            },
                        },
                    });
                    return
                } else if (propertyNames.indexOf("部件名称") !== -1) {
                    objdata = {
                        // 点位类型(中英文配置表poiKeys.js)
                        POITYPE: "CSBJ",
                        // 展示字段
                        name: properties["部件名称"],
                        address: properties["安装地址"],
                        code: properties["部件编码"],
                        type: properties["部件类型"],
                        // 弹框经纬度
                        lon: properties["Longtitude"],
                        lat: properties["Latitude"],
                    }
                } else if (propertyNames.indexOf("井编号") !== -1) {
                    objdata = {
                        POITYPE: "YINJ",
                        name: properties["井名称"],
                        depth: properties["井深"],
                        type: properties["井类型"],
                        location: properties["位置"],
                        code: properties["井编号"],
                        lon: properties["Longtitude"],
                        lat: properties["Latitude"],
                    }
                } else if (propertyNames.indexOf("QYMC") !== -1) {
                    objdata = {
                        POITYPE: "QY",
                        QYMC: properties["QYMC"],
                        XYDM: properties["XYDM"],
                        BZDZ: properties["BZDZ"],
                        DZ: properties["DZ"],
                        lon: properties["Longtitude"],
                        lat: properties["Latitude"],
                    }
                }
            }
            if (feature && feature.values_.desc) {
                let obj = feature.values_.desc
                objdata = {
                    POITYPE: "POINT",
                    name: obj.name,
                    address: obj.address,
                    lon: obj.lng,
                    lat: obj.lat
                }
                overlay.setPosition(e.coordinate);
                store.setPoplayerShowAction(true);
                store.setPoplayerListAction(objdata);
                // if (window.instance) {
                //     window.instance.$destroy();
                // }
@@ -2385,10 +2462,15 @@
                // });
                // window.instance.$mount();
            }
            store.setTdglShow(false);
            store.setTdlgInfo({});
            store.setdwShow(true);
            store.setdwInfo(objdata);
        });
    }
    if (state) {
        clickEvent = window.map.on('click', handleClick);
        clickEvent = window.mapapi.on('click', handleClick);
    } else {
        ol.Observable.unByKey(clickEvent)
        clickEvent = null
@@ -2397,7 +2479,7 @@
export function flyToPoint(posisitons) {
    window.map.getView().animate({
    window.mapapi.getView().animate({
        center: posisitons,
        zoom: 15,
        duration: 1500