Last active
August 29, 2015 13:56
-
-
Save unicolet/8854552 to your computer and use it in GitHub Desktop.
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
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(); | |
} | |
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
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