Add more getters to ol.source.Vector

This commit is contained in:
Bart van den Eijnden
2016-03-17 15:26:25 +01:00
parent a81150508d
commit 908d4051cd

View File

@@ -93,13 +93,25 @@ ol.source.Vector = function(opt_options) {
*/
this.loader_ = ol.nullFunction;
/**
* @private
* @type {ol.format.Feature|undefined}
*/
this.format_ = options.format;
/**
* @private
* @type {string|ol.FeatureUrlFunction|undefined}
*/
this.url_ = options.url;
if (options.loader !== undefined) {
this.loader_ = options.loader;
} else if (options.url !== undefined) {
goog.asserts.assert(options.format !== undefined,
} else if (this.url_ !== undefined) {
goog.asserts.assert(this.format_ !== undefined,
'format must be set when url is set');
// create a XHR feature loader for "url" and "format"
this.loader_ = ol.featureloader.xhr(options.url, options.format);
this.loader_ = ol.featureloader.xhr(this.url_, this.format_);
}
/**
@@ -678,6 +690,28 @@ ol.source.Vector.prototype.getFeatureById = function(id) {
};
/**
* Get the format associated with this source.
*
* @return {ol.format.Feature|undefined} The feature format.
* @api
*/
ol.source.Vector.prototype.getFormat = function() {
return this.format_;
};
/**
* Get the url associated with this source.
*
* @return {string|ol.FeatureUrlFunction|undefined} The url.
* @api
*/
ol.source.Vector.prototype.getUrl = function() {
return this.url_;
};
/**
* @param {ol.events.Event} event Event.
* @private