diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index a35d3a4da8..e40de37d66 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -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