leaflet.js學習錯誤總結

1.右擊菜單出錯
*出錯內容:創建一個右擊事件,彈不出來右擊菜單
*解決辦法:需要在marker中綁定classname

markOptions.icon.options.className = '右擊類名'

2.怎麼通過右上角和左下角的經緯度來畫矩形
解決辦法:用L.rectangle來畫矩形

  var bounds = [[berthObj.upper_Left_Latitude/600000, berthObj.upper_Left_Longitude/600000],//左上角
                 [berthObj.lower_Right_Latitude/600000, berthObj.lower_Right_Longitude/600000]];//右下角
                var Lpolygon = L.rectangle(bounds, {
                    color: "#ff7800",
                     weight: 5
               }).addTo(this.berthLayerGroup)//添加到圖層上 因爲你的stop方法中寫的是關閉圖層 而不是地圖

3.在非點擊事件中,如何給後端傳遞參數
*在右鍵點擊的方法中定義當前點擊的對象
*在用接口的方法中,獲取當前點擊對象的數據,從而獲取傳遞的參數值

var curtPort  = this.ictmap.portlayer.curtPort.options.data;
data.id=curtPort.id

4.移動地圖時如何獲取四個角的經緯度

       var bounds = this.ictmap.getBounds(),
            southwest = bounds.getSouthWest(),
            northeast = bounds.getNorthEast();
            data.loleft = parseFloat(southwest.lng.toFixed(6));//左下經度
            data.laleft = parseFloat(southwest.lat.toFixed(6));//左下維度
            data.loright= parseFloat(northeast.lng.toFixed(6));//右上經度
            data.laright = parseFloat(northeast.lat.toFixed(6));//右上維度
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章