效果如下圖所示:
代碼如下圖所示
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());
})