leaflet 添加矩形,可放大缩小,可移动,可旋转(transform)

效果如下图所示:

 

代码如下图所示 

var rectangle = new L.Rectangle(L.latLngBounds(this.polygonPosition), {
      weight: 2,
      draggable: true,
      transform: true,
      fillColor: "transport",
      fillOpacity: 0
    }).addTo(this.leafletService.map);

    this.rectangle.transform.enable({ rotation: false, scaling: true, uniformScaling:true });


    var that = this;

    //旋转完执行,一般是为了放中间的图标,所以才要获取位置信息
    this.rectangle.on("rotateend", function (e) {
      console.log(e.target.getBounds());

      
    })

    //放大缩小执行,一般是为了放中间的图标,所以才要获取位置信息
    this.rectangle.on("scaleend ", function (e) {
      console.log(e.target.getBounds());


    })


    //拖动完执行,一般是为了放中间的图标,所以才要获取位置信息
    this.rectangle.on("dragend ", function (e) {
      console.log(e.target.getBounds());

      
    })

 

你可能感兴趣的:(leaflet相关问题,angular4,前端问题)