whychdw
2020-08-31 0b346ad97f5e66b89db992a11ce740cad5f82521
地图面板提交
1个文件已修改
45 ■■■■ 已修改文件
src/pages/index.vue 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue
@@ -182,9 +182,16 @@
          async callback(node) {
            //获取站点名
            const addSetdian = await addMapSetdian();
            const addSetmap = JSON.parse(addSetdian.data.result).data;
            console.log("addSetdian", addSetdian);
            console.log("addSetmap", addSetmap);
            const addSetmap = JSON.parse(addSetdian.data.result).data.map(item=>{
              item.label = item.StationName1+'-'+item.StationName2+'-'+item.StationName5+'-'+item.StationName3;
              return item;
            });
            // console.log("addSetdian", addSetdian);
            // console.log("addSetmap", addSetmap);
            const point = new BMapGL.Point(that.lng, that.lat);
            const marke = new BMapGL.Marker(point);
            that.map.addOverlay(marke);
            /* 设置站点窗口 */
            var opts = {
              width: 'auto', // 信息窗口宽度
@@ -192,26 +199,18 @@
              title:'<p style="font-size: 16px;color: black;margin:2px;margin-bottom: 10px;">设置站点位置  </p>', // 信息窗口标题
              message: "地址信息"
            };
            this.infoWindow = new BMapGL.InfoWindow(
              `<p style="font-size: 16px;color: black;margin:2px;margin-top: 5px; ">地址:${
                that.cityName
              }<br> 经度:${that.lng}
              <br> 维度: ${
                that.lat
              }  <br> 设置站点名:<select style="border: 1px solid #ccc; width: 180px" ><option value="${
                addSetmap[21].StationName1
              }-${addSetmap[21].StationName2}-${addSetmap[21].StationName5}-${
                addSetmap[21].StationName3
              }">${addSetmap[5].StationName1}-${addSetmap[5].StationName2}-${
                addSetmap[5].StationName5
              }-${addSetmap[5].StationName3}</option>
              <option value="湖北省-鄂州市-鄂城区-司徒">湖北省-鄂州市-鄂城区-司徒</option>
              </select> <br><br><button style="background-color: pink"   >确定</button> </p>`,
              opts
            );
            const point = new BMapGL.Point(that.lng, that.lat);
            const marke = new BMapGL.Marker(point);
            that.map.addOverlay(marke);
            var geoc = new BMapGL.Geocoder();
            showInfoWindowTest.homeList = addSetmap;
            // 逆地址解析,通过经纬度获取地址信息
            geoc.getLocation(marke.getPosition(), function(rs) {
              showInfoWindowTest.address = rs.address;
              showInfoWindowTest.point = marke.getPosition();
            });
            // 设置面板
            this.infoWindow = new BMapGL.InfoWindow(showInfoWindowTest.$el, opts);
            that.map.openInfoWindow(this.infoWindow, point);
            marke.addEventListener("click", e => {
              //左击标注