Options are almost always optional (wow) and passed as an object. Behold:
var map = L.map("map", {
option1: false,
option2: true
});
Syntax sugar
new L.Map("map") = L.map("map"); // because of class factories
Passing options
Always peep into the docs before reinventing the wheel
Fluent interface
map.setZoom(5)
.setView([10, 10])
.addLayer(layer); // very addictive
var options = {
center: [0, 0],
zoom: 5
// other properties (see the docs!)
};
var map = L.map(document.getElementById("map"), options); // produces the same as
var map = L.map("map", options);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map);
Vector layers inherit from abstract L.path class
and implement ILayer interface
They all share methods and properties defined by L.path!
Thanks to the ILayer interface you add them the same way like raster layers