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());

      
    })

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章