suerprisePlus
2024-10-15 afd3fe35aeaae4f3984c94ca29d57b5a3a52107f
src/components/mapOl/index.vue
@@ -61,31 +61,31 @@
        initOlMap() {
            const baseLayer = mapData.baseLayer;
            const vecUrl = baseLayer.sUrl + baseLayer.vecLayer + baseLayer.lUrl
            const geo= config.geoServer;
            // var vectorLayer = new TileLayer({
            //     source: new XYZ({
            //         url: vecUrl + config.tdToken,
            //     }),
            // });
            // const cvaUrl = baseLayer.sUrl + baseLayer.cvaLayer + baseLayer.lUrl
            // var vectorLayer1 = new TileLayer({
            //     source: new XYZ({
            //         url: cvaUrl + config.tdToken,
            //     }),
            // });
            var layer2 = new Image({
                name: "Wms_Layer",
                source: new ImageWMS({
                    crossOrigin: "anonymous",
                    url: geo.url + geo.wms,
                    params: {
                        FORMAT: "image/png",
                        VERSION: "1.1.1",
                        LAYERS: geo.layers[0],
                    },
            const geo = config.geoServer;
            var vectorLayer = new TileLayer({
                source: new XYZ({
                    url: vecUrl + config.tdToken,
                }),
            });
            this.mapol.addLayer(layer2);
            const cvaUrl = baseLayer.sUrl + baseLayer.cvaLayer + baseLayer.lUrl
            var vectorLayer1 = new TileLayer({
                source: new XYZ({
                    url: cvaUrl + config.tdToken,
                }),
            });
            // var layer2 = new Image({
            //     name: "Wms_Layer",
            //     source: new ImageWMS({
            //         crossOrigin: "anonymous",
            //         url: geo.url + geo.wms,
            //         params: {
            //             FORMAT: "image/png",
            //             VERSION: "1.1.1",
            //             LAYERS: geo.layers[0],
            //         },
            //     }),
            // });
            // this.mapol.addLayer(layer2);
            this.mapol = new Map({
                target: 'mapView',
                layers: [vectorLayer, vectorLayer1],
@@ -113,12 +113,17 @@
            if (this.parentData) {
                if (this.parentData.indexOf('type') > -1) {
                    const data = JSON.parse(this.parentData)[0];
                    console.log(data);
                    this.isShow = data.isShow
                    if (data.type == 'point') {
                        const obj = mapConfig.getWKTParse(data.val.point)
                        const obj = data.val.point.split(" ");
                        console.log(obj);
                        this.formInline = {
                            lon: obj.coordinates[0],
                            lat: obj.coordinates[1],
                            lon: obj[0],
                            lat: obj[1],
                        }
                        this.addPointData(obj);
                    } else if (data.type == 'line') {
@@ -176,12 +181,12 @@
            this.mapol.addLayer(vectorLayer);
            this.mapol.getView().fit(extent, {
                size: this.mapol.getSize(),
                padding: [100, 100,200,100], // 四个方向的边距,可选
                padding: [100, 100, 200, 100], // 四个方向的边距,可选
                constrainResolution: false, // 是否限制分辨率,可选
            });
        },
        addPointData(res) {
            const coord = res.coordinates;
            const coord = res;
            const urlImg = config.sdkImg + 'Workers/image/mark.png';
            var geom = transform(