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));//右上维度

猜你喜欢

转载自blog.csdn.net/qq_43473279/article/details/89355039