add a ol.layer.wms factory
This commit is contained in:
41
src/api/layer/wms.js
Normal file
41
src/api/layer/wms.js
Normal file
@@ -0,0 +1,41 @@
|
||||
goog.provide('ol.layer.wms');
|
||||
|
||||
goog.require('ol.layer.WMS');
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @param {Object} opt_arg Config object.
|
||||
* @return {ol.layer.WMS}
|
||||
*/
|
||||
ol.layer.wms = function(opt_arg) {
|
||||
if (opt_arg instanceof ol.layer.WMS) {
|
||||
return opt_arg;
|
||||
}
|
||||
|
||||
/** @type {string} */
|
||||
var url;
|
||||
/** @type {Array.<string>} */
|
||||
var layers;
|
||||
/** @type {string} */
|
||||
var format;
|
||||
|
||||
if (goog.isObject(opt_arg)) {
|
||||
ol.base.checkKeys(opt_arg, ['url', 'layers', 'format']);
|
||||
url = opt_arg['url'];
|
||||
layers = opt_arg['layers'];
|
||||
format = opt_arg['format'];
|
||||
}
|
||||
|
||||
var msg;
|
||||
if (!goog.isDef(url)) {
|
||||
msg = 'Cannot create WMS layer; option "url" is missing';
|
||||
ol.error(msg);
|
||||
}
|
||||
if (!goog.isArray(layers)) {
|
||||
msg = 'Cannot create WMS layer; option "layers" is missing, ' +
|
||||
'or is not an array';
|
||||
ol.error(msg);
|
||||
}
|
||||
|
||||
return new ol.layer.WMS(url, layers, format);
|
||||
};
|
||||
@@ -48,6 +48,10 @@ goog.exportSymbol('ol.layer.XYZ', ol.layer.XYZ);
|
||||
goog.exportSymbol('ol.layer.osm', ol.layer.osm);
|
||||
goog.exportSymbol('ol.layer.OSM', ol.layer.OSM);
|
||||
|
||||
// ol.layer.wms
|
||||
goog.exportSymbol('ol.layer.wms', ol.layer.wms);
|
||||
goog.exportSymbol('ol.layer.WMS', ol.layer.WMS);
|
||||
|
||||
// ol.feature
|
||||
goog.exportSymbol('ol.feature', ol.feature);
|
||||
goog.exportSymbol('ol.Feature', ol.Feature);
|
||||
|
||||
Reference in New Issue
Block a user