浏览代码

小班边界查询样地

wangcc 2 年之前
父节点
当前提交
e5de27ec1b
共有 1 个文件被更改,包括 29 次插入17 次删除
  1. 29 17
      src/components/amap.vue

+ 29 - 17
src/components/amap.vue

@@ -363,7 +363,7 @@ export default {
             _this.loadMapData(DistrictExplorer, $);
           }
         );
-        
+
         var wms = new AMap.TileLayer.WMTS({
           url: 'http://t4.tianditu.gov.cn/img_w/wmts',
           blend: false,
@@ -375,7 +375,7 @@ export default {
             // TileMatrixSet: 'EPSG:3857',
             TileMatrixSet: 'w',
             STYLE: 'default',
-            tk: '064688075f565aa463866b915c378e00'
+            tk: '0864c66cc5f141fc17511169957aad51'
           }
         });
         wms.setMap(_this.map);
@@ -731,7 +731,7 @@ export default {
         smallClassMapArr.forEach((item) => {
           let polyData = JSON.parse(item.mapInfo);
           for (let elementLs in polyData.features) {
-            that.smallClassPolygon = new AMap.Polygon({
+           let smallClassPolygon = new AMap.Polygon({
               map: that.map,
               path: polyData.features[elementLs].geometry.coordinates,
               strokeOpacity: 1,
@@ -742,9 +742,8 @@ export default {
               cursor: 'pointer'
             });
             var lanLatArr = [];
-
-            that.smallClassPolygon.on('mouseover', () => {
-              console.log(item);
+            smallClassPolygon.on('click', (e) => {
+              console.log(e.lnglat.lng, e.lnglat.lat);
               lanLatArr = [item.longitude, item.latitude];
               let smallLabel =
                 "<div class='info-small'>" +
@@ -780,7 +779,7 @@ export default {
                 position: lanLatArr,
                 icon: require('@/assets/img/small-marker.png'),
                 anchor: 'bottom-center',
-                offset: new AMap.Pixel(0, 0)
+                offset: new AMap.Pixel(-5, -6)
               });
               that.smallMarker.setLabel({
                 direction: 'right',
@@ -788,17 +787,17 @@ export default {
                 content: smallLabel //设置文本标注内容
               });
               that.smallMarker.setMap(that.map);
-              that.smallClassPolygon.setOptions({
+              smallClassPolygon.setOptions({
                 fillOpacity: 0.7,
                 fillColor: 'yellow'
               });
             });
-            that.smallClassPolygon.on('mouseout', () => {
+            smallClassPolygon.on('mouseout', () => {
               if (that.smallMarker) {
                 that.smallMarker.setMap(null);
                 that.smallMarker = null;
               }
-              that.smallClassPolygon.setOptions({
+              smallClassPolygon.setOptions({
                 fillOpacity: 0,
                 fillColor: '#ccebc5'
               });
@@ -843,7 +842,7 @@ export default {
             position: lngLat,
             icon: sampleIcon,
             anchor: 'bottom-center',
-            offset: new AMap.Pixel(0, 0)
+            offset: new AMap.Pixel(0, -18)
           });
           if (page === 'forest') {
             this.forestMarker.setLabel({
@@ -894,7 +893,7 @@ export default {
           } else if (page === 'treeSpecies') {
             this.forestMarker.setLabel({
               direction: 'top',
-              offset: new AMap.Pixel(0, 13), //设置文本标注偏移量
+              offset: new AMap.Pixel(0, 8), //设置文本标注偏移量
               content: `<div class="label-treecomp">${item.treeComp}<span class="smallH">${item.smallNumber}</span></div>` //设置文本标注内容
             });
           }
@@ -908,6 +907,17 @@ export default {
       that.smallClassMapArr.forEach((item) => {
         let polyData = JSON.parse(item.mapInfo);
         for (let elementLs in polyData.features) {
+          console.log(item.superTree);
+          if (item.eventType == 1) {
+            item.eventContLabel = '火灾';
+            baseIcon = fireIcon;
+          } else if (item.eventType == 2) {
+            item.eventContLabel = '砍伐';
+            baseIcon = cutTreeIcon;
+          } else if (item.eventType == 3) {
+            item.eventContLabel = '病虫害';
+            baseIcon = insectpestIcon;
+          }
           let polygon = new AMap.Polygon({
             map: that.map,
             path: polyData.features[elementLs].geometry.coordinates,
@@ -918,8 +928,10 @@ export default {
             zIndex: 999,
             cursor: 'pointer'
           });
+          
           var lanLatArr = [];
-          polygon.on('mouseover', (e) => {
+          polygon.on('click', (e) => {
+            
             lanLatArr = [item.longitude, item.latitude];
             let treeSmallLabel =
               "<div class='info-small'>" +
@@ -1279,7 +1291,7 @@ export default {
         });
         that.townPolygons.push(this.boundaryPolygon);
         // that.map.add(that.townPolygons);
-       
+
         this.boundaryPolygon.on('click', (e) => {
           this.smallClassMapArr = [];
           let centerLanLatArr = [e.lnglat.lng, e.lnglat.lat];
@@ -1333,9 +1345,9 @@ export default {
           //   townId: this.$store.state.addr.selectStreet.areaId
           // });
           // that.map.setBounds(townPolygon.getBounds(), null, null, true);
-          townPolygon.on('click',(e) =>{
-            console.log(e.lnglat.lng,e.lnglat.lat,);
-          })
+          townPolygon.on('click', (e) => {
+            console.log(e.lnglat.lng, e.lnglat.lat);
+          });
           console.log(this.leftPage);
           if (this.leftPage === 'forest') {
             this.addForestPolygon(this.smallClassMapArr);