Last active
August 29, 2015 14:24
-
-
Save tristen/1914fd00b59523aac1e0 to your computer and use it in GitHub Desktop.
layer group from array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var layers = [ | |
{ | |
label: 'foo', | |
url: 'foo' | |
}, | |
{ | |
label: 'bar', | |
url: 'bar' | |
} | |
].reduce(function(memo, layer) { | |
memo[layer.label] = L.tileLayer(layer.url, {id: layer.label} | |
return memo; | |
}, {}); | |
var map = L.map('map'); | |
L.control.layers(layers).addTo(map); |
Author
tristen
commented
Jul 8, 2015
@tristen what am i doing wrong here
var options = require('./src/lrm_options');
var mapLayer = options.layer;
mapLayer = mapLayer.map(function(layer) {
layer = L.tileLayer(layer.tileLayer, {id: layer.label}
return layer;
});
var map = L.map('map', {
layers: mapLayer
});
Looks like you're missing a parens after L.tileLayer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment