From 59af55dc3e72f8f2655ae06af9d1b6f766bac423 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 20 三月 2026 16:02:19 +0800
Subject: [PATCH] 2026.3.20

---
 src/utils/map/districtsearch.js |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/src/utils/map/districtsearch.js b/src/utils/map/districtsearch.js
index a145b87..b41968b 100644
--- a/src/utils/map/districtsearch.js
+++ b/src/utils/map/districtsearch.js
@@ -6,7 +6,7 @@
 var activeDistrict = undefined
 export default {
   // 缁樺埗鍖哄幙杈圭晫
-  drawDistrict(districtName, isNew) {
+  drawDistrictMask(districtName, isNew) {
     if (!districtName) return
     onMapMounted(() => {
       if (!isNew && districtPolygonMap.has(districtName)) {
@@ -49,6 +49,43 @@
       }
     })
   },
+  // 缁樺埗鍖哄幙杈圭晫
+  drawDistrict(districtName, isNew) {
+    if (!districtName) return
+    onMapMounted(() => {
+      if (!isNew && districtPolygonMap.has(districtName)) {
+        const districtPolygon = districtPolygonMap.get(districtName)
+        map.add(districtPolygon)
+        map.setFitView(districtPolygon)
+        activeDistrict = districtPolygon
+      } else {
+        var district = new AMap.DistrictSearch({
+          extensions: 'all', //杩斿洖琛屾斂鍖鸿竟鐣屽潗鏍囩瓑鍏蜂綋淇℃伅
+          level: 'district', //璁剧疆鏌ヨ琛屾斂鍖虹骇鍒负鍖�
+        })
+        district.search(districtName, function (status, result) {
+          var bounds = result.districtList[0].boundaries //鑾峰彇杈圭晫淇℃伅
+          if (bounds) {
+            for (var i = 0; i < bounds.length; i++) {
+              //鐢熸垚琛屾斂鍖哄垝 polygon
+              const districtPolygon = new AMap.Polygon({
+                map: map, //鏄剧ず璇ヨ鐩栫墿鐨勫湴鍥惧璞�
+                strokeWeight: 1, //杞粨绾垮搴�
+                path: bounds[i], //澶氳竟褰㈣疆寤撶嚎鐨勮妭鐐瑰潗鏍囨暟缁�
+                fillOpacity: 0.4, //澶氳竟褰㈠~鍏呴�忔槑搴�
+                fillColor: '#0077ff',
+                strokeColor: '#CC66CC', //绾挎潯棰滆壊
+              })
+
+              districtPolygonMap.set(districtName, districtPolygon)
+              activeDistrict = districtPolygon
+              map.setFitView(districtPolygon, true)
+            }
+          }
+        })
+      }
+    })
+  },
   removeDistrict() {
     onMapMounted(() => {
       if (activeDistrict) {

--
Gitblit v1.9.3