From dda7d12ed9520176a43edc64651b8d220e470f93 Mon Sep 17 00:00:00 2001
From: ZhangXianQiang <1135831638@qq.com>
Date: 星期二, 05 三月 2024 17:01:41 +0800
Subject: [PATCH] feat:修改高德地图区域

---
 src/views/daoAnOffice/center/map.vue |   51 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/src/views/daoAnOffice/center/map.vue b/src/views/daoAnOffice/center/map.vue
index 0a4df18..133bad3 100644
--- a/src/views/daoAnOffice/center/map.vue
+++ b/src/views/daoAnOffice/center/map.vue
@@ -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杩涘埗棰滆壊浠g爜璧嬪�笺�傞粯璁ゅ�间负#006600
+            strokeColor: "rgb(20,164,173)",
+            strokeWeight: 4,
+            //杞粨绾块�忔槑搴︼紝鍙栧�艰寖鍥碵0,1]锛�0琛ㄧず瀹屽叏閫忔槑锛�1琛ㄧず涓嶉�忔槑銆傞粯璁や负0.9
+            strokeOpacity: 0.5,
+            //澶氳竟褰㈠~鍏呴鑹诧紝浣跨敤16杩涘埗棰滆壊浠g爜璧嬪�硷紝濡傦細#FFAA00
+            fillColor: "rgba(0,0,0)",
+            //澶氳竟褰㈠~鍏呴�忔槑搴︼紝鍙栧�艰寖鍥碵0,1]锛�0琛ㄧず瀹屽叏閫忔槑锛�1琛ㄧず涓嶉�忔槑銆傞粯璁や负0.9
+            fillOpacity: 1,
+            //杞粨绾挎牱寮忥紝瀹炵嚎:solid锛岃櫄绾�:dashed
+            strokeStyle: "solid",
+            /*鍕惧嫆褰㈢姸杞粨鐨勮櫄绾垮拰闂撮殭鐨勬牱寮忥紝姝ゅ睘鎬у湪strokeStyle 涓篸ashed 鏃舵湁鏁堬紝 姝ゅ睘鎬у湪    
+            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);

--
Gitblit v1.8.0