地图上画线!

燕飞文
2023-12-01
  function aa() {
       var path1 = [
           // new AMap.LngLat(121.680184,31.301315),
           [121.680184,31.301315],
           [121.681617,31.300823],
           [121.681689,31.300773],
           [121.681726,31.300697],
           [121.681717,31.300592],
           [121.681667,31.300534],
           [121.681483,31.300439],

           // new AMap.LngLat(121.681617,31.300823),
           // new AMap.LngLat(121.681689,31.300773),
           // new AMap.LngLat(121.681726,31.300697),
           //
           // new AMap.LngLat(121.681717,31.300592),
           // new AMap.LngLat(121.681667,31.300534),
           // new AMap.LngLat(121.681483,31.300439)
       ];
       console.log("11212")
       var polyline = new AMap.Polyline({
           path: path1,
           isOutline: true,
           outlineColor: '#00B6DA',
           borderWeight: 3,
           strokeColor: "#00B6DA",
           strokeOpacity: 1,
           strokeWeight: 6,
           // 折线样式还支持 'dashed'
           strokeStyle: "solid",
           // strokeStyle是dashed时有效
           strokeDasharray: [10, 5],
           lineJoin: 'round',
           lineCap: 'round',
           zIndex: 50,
       })
       map.add(polyline);
   }

封装直接用

 类似资料: