diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 349e3ca1a9..afbf5f80d4 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -295,14 +295,16 @@ /** * @typedef {Object} ol.parser.KMLOptions + * @property {number|undefined} dimension Create geometries with `dimension` + * dimensions. Default is 3. * @property {boolean|undefined} extractAttributes Should we extract attributes * from the KML? Default is `true´. * @property {boolean|undefined} extractStyles Should we extract styles from the * KML? Default is `false`. - * @property {number|undefined} dimension Create geometries with `dimension` - * dimensions. Default is 3. * @property {number|undefined} maxDepth Maximum depth to follow network links. * Default is 0, which means we don't follow network links at all. + * @property {Array.|undefined} trackAttributes Track attributes to + * parse. */ /** diff --git a/src/ol/parser/kml.js b/src/ol/parser/kml.js index 3de797d27f..8be3b5f61a 100644 --- a/src/ol/parser/kml.js +++ b/src/ol/parser/kml.js @@ -45,22 +45,18 @@ goog.require('ol.style.PolygonLiteral'); * @extends {ol.parser.XML} */ ol.parser.KML = function(opt_options) { - if (goog.isDef(opt_options)) { - goog.object.extend(this, opt_options); - } - if (!goog.isDef(this.extractAttributes)) { - this.extractAttributes = true; - } - if (!goog.isDef(this.extractStyles)) { - this.extractStyles = false; - } + var options = /** @type {ol.parser.KMLOptions} */ + (goog.isDef(opt_options) ? opt_options : {}); + this.extractAttributes = goog.isDef(options.extractAttributes) ? + options.extractAttributes : true; + this.extractStyles = goog.isDef(options.extractStyles) ? + options.extractStyles : false; // TODO re-evaluate once shared structures support 3D - if (!goog.isDef(this.dimension)) { - this.dimension = 3; - } - if (!goog.isDef(this.maxDepth)) { - this.maxDepth = 0; - } + this.dimension = goog.isDef(options.dimension) ? options.dimension : 3; + this.maxDepth = goog.isDef(options.maxDepth) ? options.maxDepth : 0; + this.trackAttributes = goog.isDef(options.trackAttributes) ? + options.trackAttributes : null; + this.defaultNamespaceURI = 'http://www.opengis.net/kml/2.2'; this.readers = { 'http://www.opengis.net/kml/2.2': {