Reputation: 43832
I'm struggling with turning on the Map Control in Leaflet.
Staring at the example doesn't seem to help. I know I must be making a stupid mistake, but I can't figure it out.
http://leaflet.cloudmade.com/examples/layers-control.html
I've got my map, and it loads, displays ok, but at the addTo(map)
method I get the error:
Uncaught TypeError: Cannot call method 'addTo' of undefined
Any ideas what I'm missing?
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
var street_layer = new L.TileLayer(osmUrl, {minZoom: 8, maxZoom: 18, attribution: osmAttrib});
map = new L.Map('map',{
center: initial_center,
zoom: initial_zoom,
layers: mapLayersList
});
var baseMaps = {"Streets": street_layer};
L.Control.Layers(baseMaps, null).addTo(map);
Upvotes: 0
Views: 6869
Reputation: 2627
L.Control.Layers(baseMaps, null).addTo(map);
is wrong. It is
L.control.layers(baseMaps, null).addTo(map);
You can check out the script's jsfiddle here
Upvotes: 3