add an ol.layer.xyz factory

This commit is contained in:
Éric Lemoine
2012-06-20 18:08:51 +02:00
parent 958e291545
commit 7413770a46
4 changed files with 48 additions and 0 deletions

29
src/api/layer/xyz.js Normal file
View File

@@ -0,0 +1,29 @@
goog.provide('ol.layer.xyz');
/**
* @export
* @param {Object} opt_arg Config object.
* @return {ol.layer.XYZ}
*/
ol.layer.xyz = function(opt_arg) {
if (opt_arg instanceof ol.layer.XYZ) {
return opt_arg;
}
/** @type {string} */
var url;
var usage = 'ol.layer.xyz accepts an object with a "url" property';
if (goog.isObject(opt_arg)) {
url = opt_arg['url'];
} else {
throw new Error(usage);
}
if (!goog.isDef(url)) {
throw new Error(usage);
}
return new ol.layer.XYZ(url);
};