Skip to content

Instantly share code, notes, and snippets.

@unicolet
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unicolet/8854552 to your computer and use it in GitHub Desktop.
Save unicolet/8854552 to your computer and use it in GitHub Desktop.
function assembleLayer(conf) {
var constructorr=window, path=conf.provider.split(".");
// get a reference to the constructor, by walking the provider path
for(var i=0,l=path.length;i<l;i++) { constructorr=constructorr[path[i]]; }
// following constructor code from: http://stackoverflow.com/a/1608546/887883
// now invoke it
function F() {
return constructorr.apply(this, conf.args);
}
F.prototype = constructorr.prototype;
return new F();
}
for(var i=0,l=layers.length;i<l;i++) {
map.addLayer(assembleLayer(layers[i]));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment