I am looking at the Extending Leaflet documentation for adding custom controls.
It contains this code snippet as an example of adding a simple watermark control:
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);
Why is the control assigned to both uppercase (L.Control.Watermark
) and lowercase L.control.watermark
variables? Is this a common convention when extending JavaScript libraries?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…