我正在查看扩展传单文档以添加自定义控件。
它包含以下代码片段,作为添加简单水印控件的示例:
L.Control.Watermark = L.Control.extend({
onAdd: function(map) {
var img = L.DomUtil.create('img');
img.src = '../../docs/images/logo.png';
img.style.width = '200px';
return img;
},
onRemove: function(map) {
// Nothing to do here
}
});
L.control.watermark = function(opts) {
return new L.Control.Watermark(opts);
}
L.control.watermark({ position: 'bottomleft' }).addTo(map);
Run Code Online (Sandbox Code Playgroud)
为什么将控件同时分配给大写(L.Control.Watermark)和小写L.control.watermark变量?扩展JavaScript库时,这是通用约定吗?