| 
					
				 | 
			
			
				@@ -20,11 +20,13 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <script> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import AMapLoader from '@amap/amap-jsapi-loader'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import {mapMutations, mapGetters} from 'vuex'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   name: "", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   components: {}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   data() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      AMap:null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       map:null, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       lngLat:[106.628201,26.646694], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       zoom:9, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -36,6 +38,49 @@ export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       streetList:[],//街道,乡 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  watch: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    vuexSelectCity: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        handler: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // console.log('vuexSelectCity',this.vuexSelectCity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // console.log('vuexCityList',this.vuexCityList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // this.vuexCityList.forEach(element => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //   if(this.vuexSelectCity==element.value){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     this.mapLevel= element.level 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.mapLevel= 'city'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.adcode = this.vuexSelectCity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.getMap(this.AMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deep: true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    vuexSelectDistrict: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        handler: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          console.log('vuexSelectDistrict',this.vuexSelectDistrict); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(this.vuexSelectDistrict){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.mapLevel= 'district'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.adcode = this.vuexSelectDistrict; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.getMap(this.AMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          }  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deep: true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    vuexSelectStreet: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        handler: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          console.log('vuexSelectStreet',this.vuexSelectStreet); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(this.vuexSelectStreet){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.mapLevel= 'street'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.adcode = this.vuexSelectStreet; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.getMap(this.AMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          }  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        deep: true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  computed: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // 引入getters中的计算属性,需要在 computed 中引入 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ...mapGetters(['vuexCityList','vuexDistrictList','vuexStreetList','vuexSelectCity','vuexSelectDistrict','vuexSelectStreet']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   created() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -46,6 +91,7 @@ export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // }, 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   methods: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ...mapMutations(['changeCityList','changeDistrictList','changeStreetList']), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     initMap() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       window._AMapSecurityConfig = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         securityJsCode: '4a6a8d8ea053d9aa8f4677ee1179fe57',  // 密钥 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -55,6 +101,7 @@ export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             version:"1.4.15",      // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // plugins:['AMap.ToolBar','AMap.DistrictSearch','AMap.Object3DLayer','AMap.Object3D'],       // 需要使用的的插件列表,如比例尺'AMap.Scale'等 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }).then((AMap)=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          this.AMap= AMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.map = new AMap.Map("container",{  //设置地图容器id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 viewMode:"3D",    //是否为3D地图模式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 zoom:this.zoom,           //初始化地图级别 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -94,8 +141,28 @@ export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           switch (that.mapLevel) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             case 'province': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               console.log('province districtList',districtList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              let cityList = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              districtList.forEach(element => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                cityList.push({label:element.name,value:element.adcode,level:element.level}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              that.changeCityList(cityList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case 'city': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              console.log('city districtList',districtList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              let districtLists = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              districtList.forEach(element => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                districtLists.push({label:element.name,value:element.adcode,level:element.level}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              that.changeDistrictList(districtLists); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case 'street': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              console.log('street districtList',districtList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              let streetLists = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              districtList.forEach(element => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                streetLists.push({label:element.name,value:element.adcode,level:element.level}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              that.changeStreetList(districtLists); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-           
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -109,6 +176,7 @@ export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             var bounds = result.districtList[0].boundaries 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             var polygons = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (bounds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              that.map.clearMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               for (var i = 0, l = bounds.length; i < l; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               //生成行政区划polygon 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               var polygon = new AMap.Polygon({ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -151,10 +219,10 @@ export default { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 </script> 
			 |