diff --git a/src/ol/parser/kml.js b/src/ol/parser/kml.js index 243f5de310..1133f75d39 100644 --- a/src/ol/parser/kml.js +++ b/src/ol/parser/kml.js @@ -51,6 +51,8 @@ ol.parser.KML = function(opt_options) { options.extractAttributes : true; this.extractStyles = goog.isDef(options.extractStyles) ? options.extractStyles : false; + this.schemaLocation = 'http://www.opengis.net/kml/2.2 ' + + 'http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd'; // TODO re-evaluate once shared structures support 3D this.dimension = goog.isDef(options.dimension) ? options.dimension : 3; this.maxDepth = goog.isDef(options.maxDepth) ? options.maxDepth : 0; @@ -557,7 +559,6 @@ ol.parser.KML = function(opt_options) { 'http://www.opengis.net/kml/2.2': { 'kml': function(options) { var node = this.createElementNS('kml'); - node.setAttribute('xmlns', this.defaultNamespaceURI); this.writeNode('Document', options, null, node); return node; }, @@ -1046,5 +1047,8 @@ ol.parser.KML.prototype.createGeometry_ = function(container, */ ol.parser.KML.prototype.write = function(obj) { var root = this.writeNode('kml', obj); - return goog.dom.xml.serialize(root); + this.setAttributeNS( + root, 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation', this.schemaLocation); + return this.serialize(root); }; diff --git a/test/spec/ol/parser/kml.test.js b/test/spec/ol/parser/kml.test.js index 0c0f997547..0cf36ffec5 100644 --- a/test/spec/ol/parser/kml.test.js +++ b/test/spec/ol/parser/kml.test.js @@ -156,7 +156,10 @@ describe('ol.parser.kml', function() { expect(obj.features[0].get('name')).to.eql('Pezinok'); }); it('Test line style', function() { - var test_style = ' ' + + var test_style = ' ' + ' ' + ' -112,36 -113,37 ' + @@ -173,7 +176,7 @@ describe('ol.parser.kml', function() { expect(symbolizer.strokeWidth).to.eql(10); }); it('Test style fill', function() { - var test_style_fill = ' ' + + var test_style_fill = '' + ' ' + '' + @@ -188,7 +191,10 @@ describe('ol.parser.kml', function() { '49.630662409673505 8.397385910100951,48.45172350357396 ' + '5.001370157823406,49.26855713824488' + ''; - var style_fill_write = ' ' + + var style_fill_write = ' ' + ' ' + '' + diff --git a/test/spec/ol/parser/kml/depth.kml b/test/spec/ol/parser/kml/depth.kml index f1b30ad95c..182b1d1b13 100644 --- a/test/spec/ol/parser/kml/depth.kml +++ b/test/spec/ol/parser/kml/depth.kml @@ -1,5 +1,5 @@ - + spec/ol/parser/kml/polygon.kml diff --git a/test/spec/ol/parser/kml/extended_data.kml b/test/spec/ol/parser/kml/extended_data.kml index 6f23151b7f..fb3a6d38a9 100644 --- a/test/spec/ol/parser/kml/extended_data.kml +++ b/test/spec/ol/parser/kml/extended_data.kml @@ -1,5 +1,5 @@ - + Extended data placemark Attached to the ground. Intelligently places itself diff --git a/test/spec/ol/parser/kml/extended_data2.kml b/test/spec/ol/parser/kml/extended_data2.kml index a5e1d4d49f..52b18b61ae 100644 --- a/test/spec/ol/parser/kml/extended_data2.kml +++ b/test/spec/ol/parser/kml/extended_data2.kml @@ -1,4 +1,5 @@ - + + Easy trail diff --git a/test/spec/ol/parser/kml/iconstyle.kml b/test/spec/ol/parser/kml/iconstyle.kml index 6f507e7615..ce2d0ed916 100644 --- a/test/spec/ol/parser/kml/iconstyle.kml +++ b/test/spec/ol/parser/kml/iconstyle.kml @@ -1,4 +1,5 @@ - + +