ZhangXianQiang
2024-03-07 47fa84717d17477b69bcb8c2a6794bd8189e1bf3
src/views/daoAnOffice/center/map.vue
@@ -2,7 +2,7 @@
  <div class="map-container">
    <div class="map-content" id="map" ref="map"></div>
    <div class="shadow"></div>
    <!-- 图标菜单 -->
    <div class="info-box">
      <!--      right菜单-->
@@ -35,15 +35,15 @@
import { require } from '@/utils/require.js';
import icon1 from '@/assets/img/sgyfd.png';
import icon2 from '@/assets/img/zdlytd.png';
import icon3 from '@/assets/img/djyjq.png';
import icon4 from '@/assets/img/jlpb.png';
import icon5 from '@/assets/img/dwsg.png';
import icon6 from '@/assets/img/jtysqy.png';
import icon7 from '@/assets/img/zdlytd.png';
import icon8 from '@/assets/img/gjxl.png';
import icon9 from '@/assets/img/aqyh.png';
import icon1 from '@/assets/img/icon/icon1.png';
import icon2 from '@/assets/img/icon/icon2.png';
import icon3 from '@/assets/img/icon/icon3.png';
import icon4 from '@/assets/img/icon/icon4.png';
import icon5 from '@/assets/img/icon/icon5.png';
import icon6 from '@/assets/img/icon/icon6.png';
import icon7 from '@/assets/img/icon/icon7.png';
import icon8 from '@/assets/img/icon/icon8.png';
import icon9 from '@/assets/img/icon/icon9.png';
const map = ref(null);
@@ -177,9 +177,9 @@
// 创建图标
const createIcon = (img) => {
  return new AMap.Icon({
    size: new AMap.Size(34, 41),    // 图标尺寸
    // size: new AMap.Size(43.8, 49.2),    // 图标尺寸
    image: img,  // Icon的图像
    imageSize: new AMap.Size(34, 41)   // 根据所设置的大小拉伸或压缩图片
    imageSize: new AMap.Size(43.8, 49.2)   // 根据所设置的大小拉伸或压缩图片
  });
}
@@ -243,9 +243,54 @@
      trafficLayer.setMap(mapInstance);
      // test();
      // console.log(markers.value[0]);
      // mapInstance.add(markers.value[0].markerList);
      const options = {
        subdistrict: 0,
        extensions: "all",
        level: "district",
      };
      // 限制一个区域轮廓
      AMap.plugin("AMap.DistrictSearch", function () {
        //在回调函数中实例化插件,并使用插件功能
        const district = new AMap.DistrictSearch(options);
        district.search("都江堰市", (status, result) => {
          const outer = [
            new AMap.LngLat(-360, 90, true),
            new AMap.LngLat(-360, -90, true),
            new AMap.LngLat(360, -90, true),
            new AMap.LngLat(360, 90, true),
          ];
          const holes = result.districtList[0].boundaries;
          const pathArray = [outer];
          pathArray.push.apply(pathArray, holes);
          const polygon = new AMap.Polygon({
            pathL: pathArray,
            //线条颜色,使用16进制颜色代码赋值。默认值为#006600
            strokeColor: "rgb(20,164,173)",
            strokeWeight: 4,
            //轮廓线透明度,取值范围[0,1],0表示完全透明,1表示不透明。默认为0.9
            strokeOpacity: 0.5,
            //多边形填充颜色,使用16进制颜色代码赋值,如:#FFAA00
            fillColor: "rgba(0,0,0)",
            //多边形填充透明度,取值范围[0,1],0表示完全透明,1表示不透明。默认为0.9
            fillOpacity: 1,
            //轮廓线样式,实线:solid,虚线:dashed
            strokeStyle: "solid",
            /*勾勒形状轮廓的虚线和间隙的样式,此属性在strokeStyle 为dashed 时有效, 此属性在
            ie9+浏览器有效 取值:
            实线:[0,0,0]
            虚线:[10,10] ,[10,10] 表示10个像素的实线和10个像素的空白(如此反复)组成的虚线
            点画线:[10,2,10], [10,2,10] 表示10个像素的实线和2个像素的空白 + 10个像素的实
            线和10个像素的空白 (如此反复)组成的虚线*/
            strokeDasharray: [10, 2, 10],
          });
          polygon.setPath(pathArray);
          mapInstance.add(polygon);
        });
      });
    })
    .catch((e) => {
      console.log(e);
@@ -259,6 +304,7 @@
  height: 100%;
  position: absolute;
  z-index: 0;
  box-shadow: inset 0px 0px 100px 18px #081729;
  .map-content {
    width: 100%;
@@ -282,7 +328,8 @@
  .item-tb-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    margin-right: 5px;
  }
  .info-div-p {
@@ -320,18 +367,37 @@
.road {
  position: absolute;
  bottom: 202px;
  bottom: 180px;
  left: 2434px;
  z-index: 999;
  width: 65px;
  cursor: pointer;
  .item-tb-p {
    font-family: PingFang SC;
    font-family: 'PingFang SC';
    font-weight: 400;
    font-size: 16px;
    color: #FFFFFF;
    line-height: 42px;
  }
}
.shadow {
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  position: absolute;
  box-shadow: inset 0px 0px 100px 120px #081729;
  pointer-events: none;
}
:deep(.amap-logo) {
  display: none !important;
}
:deep(.amap-copyright) {
  visibility: hidden !important;
}
</style>