瀏覽代碼

测量工具

彭宇 2 年之前
父節點
當前提交
fed73ef322
共有 1 個文件被更改,包括 4 次插入18 次删除
  1. 4 18
      src/components/supermap.vue

+ 4 - 18
src/components/supermap.vue

@@ -165,8 +165,6 @@
             this.drawControl = new window.L.Control.Draw(options);
             this.map.addControl(this.drawControl);
             this.map.on(window.L.Draw.Event.DRAWSTART, function (e) {
-              debugger
-              let sourceTarget = e.sourceTarget;
               let layerType = e.layerType;
               if(layerType === "marker"){
                 let icon = new window.L.Icon({
@@ -176,7 +174,9 @@
                   popupAnchor: [-3, -40],
                   shadowSize: [41, 41],
                 })
-                sourceTarget.options.icon=icon;
+                 let latLngGroup = window.L.layerGroup(null)
+                e.layer=latLngGroup
+                e.layer.options.icon=icon;
               }
             });
             this.map.on(window.L.Draw.Event.CREATED, function (e) {
@@ -198,7 +198,7 @@
                     let end = latlng[i + 1];
                     dis += window.L.latLng([start.lat, start.lng]).distanceTo([end.lat, end.lng]);//计算两个点之间的距离,并累加
                   }
-                  //结果得到的也是number类型,单位是
+                  //结果得到的也是number类型,单位是KM
                   modal.msg((dis / 10e2).toFixed(2) + "km");
                 }
               })
@@ -586,20 +586,6 @@
       controlLevel: function (level) {//控制地图缩放级别
         this.map.setZoom(level)
       },
-      // handleMapEvent(div, map) {
-      //   debugger
-      //   if (!div || !map) {
-      //     return
-      //   }
-      //   div.addEventListener('mouseover', function() {
-      //     this.map.scrollWheelZoom.disable()
-      //     this.map.doubleClickZoom.disable()
-      //   })
-      //   div.addEventListener('mouseout', function() {
-      //     this.map.scrollWheelZoom.enable()
-      //     this.map.doubleClickZoom.enable()
-      //   })
-      // }
     }
   }
 </script>