|  | @@ -27,6 +27,7 @@ window.map = {}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  export default {
 | 
	
		
			
				|  |  |    components: {},
 | 
	
		
			
				|  |  | +  props: [`baseList`],
 | 
	
		
			
				|  |  |    data() {
 | 
	
		
			
				|  |  |      return {
 | 
	
		
			
				|  |  |        infoBoxData: undefined,
 | 
	
	
		
			
				|  | @@ -46,13 +47,14 @@ export default {
 | 
	
		
			
				|  |  |        let infoWindow
 | 
	
		
			
				|  |  |        // 在指定位置打开信息窗体
 | 
	
		
			
				|  |  |        function openInfo() {
 | 
	
		
			
				|  |  | -        const item = vm.infoBoxData
 | 
	
		
			
				|  |  | -        const { center } = item.properties
 | 
	
		
			
				|  |  | +        const data = vm.infoBoxData
 | 
	
		
			
				|  |  | +        const { center } = data.properties
 | 
	
		
			
				|  |  | +        const center2 = data.baseItem.area[0] || undefined
 | 
	
		
			
				|  |  |          infoWindow = new AMap.InfoWindow({
 | 
	
		
			
				|  |  |            content: vm.$refs.infoBox,
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        infoWindow.open(map, center || map.getCenter())
 | 
	
		
			
				|  |  | +        infoWindow.open(window.map, center2 || window.map.getCenter())
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        window._AMapSecurityConfig = {
 | 
	
		
			
				|  |  |          securityJsCode: `a2017cdc059be6c03b430a3185098003`,
 | 
	
	
		
			
				|  | @@ -64,38 +66,51 @@ export default {
 | 
	
		
			
				|  |  |        })
 | 
	
		
			
				|  |  |          .then(async (AMap) => {
 | 
	
		
			
				|  |  |            function addPolygon(data) {
 | 
	
		
			
				|  |  | -            const path = data.geometry.coordinates
 | 
	
		
			
				|  |  | +            // const path = data.geometry.coordinates
 | 
	
		
			
				|  |  | +            const path = data.baseItem.area
 | 
	
		
			
				|  |  | +            console.log(
 | 
	
		
			
				|  |  | +              `datadata`,
 | 
	
		
			
				|  |  | +              path,
 | 
	
		
			
				|  |  | +              data.baseItem.area,
 | 
	
		
			
				|  |  | +              data.geometry.coordinates
 | 
	
		
			
				|  |  | +            )
 | 
	
		
			
				|  |  |              let polygon = new AMap.Polygon({
 | 
	
		
			
				|  |  |                path: path,
 | 
	
		
			
				|  |  | -              fillColor: `#ccebc5`,
 | 
	
		
			
				|  |  | -              strokeOpacity: 1,
 | 
	
		
			
				|  |  | -              fillOpacity: 0,
 | 
	
		
			
				|  |  | -              strokeColor: `#2b8cbe`,
 | 
	
		
			
				|  |  | -              strokeWeight: 4,
 | 
	
		
			
				|  |  | -              // strokeStyle: `dashed`,
 | 
	
		
			
				|  |  | -              strokeDasharray: [5, 5],
 | 
	
		
			
				|  |  | -              lineJoin: `round`,
 | 
	
		
			
				|  |  | -              lineCap: `round`,
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +              strokeColor: `red`,
 | 
	
		
			
				|  |  | +              strokeWeight: 6,
 | 
	
		
			
				|  |  | +              strokeOpacity: 0.2,
 | 
	
		
			
				|  |  | +              fillOpacity: 0.4,
 | 
	
		
			
				|  |  | +              fillColor: `#00f`,
 | 
	
		
			
				|  |  | +              zIndex: 50,
 | 
	
		
			
				|  |  | +              bubble: true,
 | 
	
		
			
				|  |  | +              // fillColor: `#ccebc5`,
 | 
	
		
			
				|  |  | +              // strokeOpacity: 1,
 | 
	
		
			
				|  |  | +              // fillOpacity: 0,
 | 
	
		
			
				|  |  | +              // strokeColor: `#2b8cbe`,
 | 
	
		
			
				|  |  | +              // strokeWeight: 4,
 | 
	
		
			
				|  |  | +              // // strokeStyle: `dashed`,
 | 
	
		
			
				|  |  | +              // strokeDasharray: [5, 5],
 | 
	
		
			
				|  |  | +              // lineJoin: `round`,
 | 
	
		
			
				|  |  | +              // lineCap: `round`,
 | 
	
		
			
				|  |  |              })
 | 
	
		
			
				|  |  |              polygon.on(`mouseover`, (e) => {
 | 
	
		
			
				|  |  | -              // 如果缩放过大还变色, 万一人家是想看放大后的详细地点, 变色后反而不方便
 | 
	
		
			
				|  |  | -              if (window.map.getZoom() <= 11) {
 | 
	
		
			
				|  |  | -                vm.infoBoxData = data
 | 
	
		
			
				|  |  | -                openInfo()
 | 
	
		
			
				|  |  | -                polygon.setOptions({
 | 
	
		
			
				|  |  | -                  fillOpacity: 0.7,
 | 
	
		
			
				|  |  | -                  fillColor: `#7bccc4`,
 | 
	
		
			
				|  |  | -                })
 | 
	
		
			
				|  |  | -              }
 | 
	
		
			
				|  |  | +              console.log(`datadatadata`, data)
 | 
	
		
			
				|  |  | +              vm.infoBoxData = data
 | 
	
		
			
				|  |  | +              openInfo()
 | 
	
		
			
				|  |  | +              // polygon.setOptions({
 | 
	
		
			
				|  |  | +              //   fillOpacity: 0.7,
 | 
	
		
			
				|  |  | +              //   fillColor: `#7bccc4`,
 | 
	
		
			
				|  |  | +              // })
 | 
	
		
			
				|  |  |              })
 | 
	
		
			
				|  |  |              polygon.on(`click`, (e) => {
 | 
	
		
			
				|  |  |                console.log(`点击了`, data.properties)
 | 
	
		
			
				|  |  |              })
 | 
	
		
			
				|  |  |              polygon.on(`mouseout`, () => {
 | 
	
		
			
				|  |  | -              polygon.setOptions({
 | 
	
		
			
				|  |  | -                fillOpacity: 0,
 | 
	
		
			
				|  |  | -                fillColor: `#ccebc5`,
 | 
	
		
			
				|  |  | -              })
 | 
	
		
			
				|  |  | +              // polygon.setOptions({
 | 
	
		
			
				|  |  | +              //   fillOpacity: 0,
 | 
	
		
			
				|  |  | +              //   fillColor: `#ccebc5`,
 | 
	
		
			
				|  |  | +              // })
 | 
	
		
			
				|  |  |              })
 | 
	
		
			
				|  |  |              window.map.add(polygon)
 | 
	
		
			
				|  |  |            }
 | 
	
	
		
			
				|  | @@ -107,6 +122,7 @@ export default {
 | 
	
		
			
				|  |  |              viewMode: `3D`, // 是否为3D地图模式
 | 
	
		
			
				|  |  |              // zoom: 7, // 初始化地图级别
 | 
	
		
			
				|  |  |              zoom: 9.22, // 初始化地图级别
 | 
	
		
			
				|  |  | +            // zoom: 14, // 初始化地图级别
 | 
	
		
			
				|  |  |              // center: [107.943579, 30.131735], // 初始化地图中心点位置
 | 
	
		
			
				|  |  |              center: [108.597461, 28.047503], // 初始化地图中心点位置
 | 
	
		
			
				|  |  |              resizeEnable: true,
 | 
	
	
		
			
				|  | @@ -126,20 +142,20 @@ export default {
 | 
	
		
			
				|  |  |                //   zoom: 17,
 | 
	
		
			
				|  |  |                // }),
 | 
	
		
			
				|  |  |                // 天地图
 | 
	
		
			
				|  |  | -              // new AMap.TileLayer({
 | 
	
		
			
				|  |  | -              //   getTileUrl: `//t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=[z]&TILEROW=[y]&TILECOL=[x]&tk=d7fcf6db577fd86e0cc48e9169065727`,
 | 
	
		
			
				|  |  | -              //   zIndex: 20,
 | 
	
		
			
				|  |  | -              //   zoom: 17,
 | 
	
		
			
				|  |  | -              // }),
 | 
	
		
			
				|  |  | -              // new AMap.TileLayer({
 | 
	
		
			
				|  |  | -              //   getTileUrl: `//t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=[z]&TILEROW=[y]&TILECOL=[x]&tk=d7fcf6db577fd86e0cc48e9169065727`,
 | 
	
		
			
				|  |  | -              //   zIndex: 20,
 | 
	
		
			
				|  |  | -              //   zoom: 17,
 | 
	
		
			
				|  |  | -              // }),
 | 
	
		
			
				|  |  | +              new AMap.TileLayer({
 | 
	
		
			
				|  |  | +                getTileUrl: `//t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=[z]&TILEROW=[y]&TILECOL=[x]&tk=d7fcf6db577fd86e0cc48e9169065727`,
 | 
	
		
			
				|  |  | +                zIndex: 20,
 | 
	
		
			
				|  |  | +                zoom: 17,
 | 
	
		
			
				|  |  | +              }),
 | 
	
		
			
				|  |  | +              new AMap.TileLayer({
 | 
	
		
			
				|  |  | +                getTileUrl: `//t{0,1,2,3,4,5,6,7}.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX=[z]&TILEROW=[y]&TILECOL=[x]&tk=d7fcf6db577fd86e0cc48e9169065727`,
 | 
	
		
			
				|  |  | +                zIndex: 20,
 | 
	
		
			
				|  |  | +                zoom: 17,
 | 
	
		
			
				|  |  | +              }),
 | 
	
		
			
				|  |  |              ],
 | 
	
		
			
				|  |  |              // zooms: [16, 20],
 | 
	
		
			
				|  |  |            })
 | 
	
		
			
				|  |  | -          window.map.setFeatures([`point`]) // 单一种类要素显示
 | 
	
		
			
				|  |  | +          window.map.setFitView()
 | 
	
		
			
				|  |  |            const baseList = await this.$http.get(`/api/base`)
 | 
	
		
			
				|  |  |            let list = mapOfTongren.features.map((item) => {
 | 
	
		
			
				|  |  |              const baseItem =
 |