zengh
2021-07-20 eb6374fd3670ac6fec2725e5f3ccb708ea76f22c
src/components/map/main.vue
@@ -81,16 +81,16 @@
                    zIndex: 4,
                    title: '影像',
                    source: new XYZ({
                        url: 'http://t3.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0' // 行政区划
              url: 'https://webmap-tile.sf-express.com/MapTileService/rt?fetchtype=static&x={x}&y={y}&z={z}&project=sfmap&pic_size=256&pic_type=png8&data_name=361100&data_format=merged-dat&data_type=normal' // 行政区划
                    })
                }),
                new OlLayerTile({
                    zIndex: 5,
                    title: '道路+中文注记',
                    source: new XYZ({
                        url: 'http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0' // 注记
                    })
                })
          // new OlLayerTile({
          //   zIndex: 5,
          //   title: '道路+中文注记',
          //   source: new XYZ({
          //     url: 'http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0' // 注记
          //   })
          // })
            ],
            // 注意地图控件的写法
@@ -112,9 +112,9 @@
        var view = ol2d.getView()
        view.setCenter([115.85883507433789, 28.708432053474827])
        view.setZoom(13)
      // view.setCenter([115.85883507433789, 28.708432053474827])
      //
      // view.setZoom(13)
        const ol3d = new OLCesium({ map: window.ol2d })
        window.ol3d = ol3d
@@ -123,7 +123,7 @@
        ol2d.addLayer(this.peopleAddlayer)
        ol2d.addLayer(this.carAddlayer)
        ol2d.addLayer(this.peopleLineAddlayer)
        this.addLines()
      // this.addLines()
    },
    methods: {
        init3D (val) {
@@ -167,18 +167,38 @@
            this[type].getSource().addFeature(iconFeature)
        },
        addLines () {
      addLines(ringId) {
        var that = this;
        if (ringId != null && ringId != "") {
          $.ajax({
            url: "api/routeIn/routein/selectList",
            type: "post",
            data: {
              "id": ringId
            },
            dataType: 'JSON',
            success: function (data) {
              that.peopleLineAddlayer.getSource().clear()
              var entityData = '';
              var entityArr = [];
              entityData = data.data[0].routeInfo.match(/\(([^)]*)\)/);
            // 点坐标
            var lineCoords = [
              [115.87471898408013, 28.720924466928977],
              [115.87471898408013, 28.724163802651635],
              [115.87401037939081, 28.72456871961697],
              [115.87147964835748, 28.7246699488583],
              [115.86925260504815, 28.7246699488583],
              [115.86621572780817, 28.7246699488583],
              [115.8635837675335, 28.72578347051296]
              ];// 线里点的集合
              // 此时result=["(dsfasjfj3124123)", "dsfasjfj3124123"];
              if (entityData && entityData != '') {
                entityData = entityData[1].split(',');
                for (var j = 0; j < entityData.length; j++) {
                  entityArr.push([Number(entityData[j].split(' ')[0]), Number(entityData[j].split(' ')[1])]);
                }
              }
              var lineCoords = entityArr;// 线里点的集合
              var view = ol2d.getView()
              view.setCenter([lineCoords[Math.ceil(entityArr.length / 2 )][0], lineCoords[Math.ceil(entityArr.length / 2 )][1]])
              view.setZoom(14.5)
            // 要素
            // var lineCoords = [[featureInfo.lineString[0][0],featureInfo.lineString[0][0]],[featureInfo.lineString(0),featureInfo.lineString(0)]];
@@ -198,9 +218,15 @@
                    width: 5
                })
            }))
              that.peopleLineAddlayer.getSource().addFeature(feature_LineString)
            },
            error: function (data) {
              // 请求失败函数
              console.log(data);
            }
          });
        }
            this.peopleLineAddlayer.getSource().addFeature(feature_LineString)
        }
    }