Skip to content

Commit

Permalink
Create valid KML documents
Browse files Browse the repository at this point in the history
Thanks @bartvde.
  • Loading branch information
elemoine committed Jun 25, 2014
1 parent 05970c9 commit 384f2a0
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 39 deletions.
22 changes: 19 additions & 3 deletions src/ol/format/kmlformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ ol.format.KML.NAMESPACE_URIS_ = [
];


/**
* @const
* @type {Array.<string>}
* @private
*/
ol.format.KML.XSD_URIS_ = [
'http://www.opengis.net/kml/2.2',
'https://developers.google.com/kml/schema/kml22gx.xsd'
];


/**
* @const
* @type {ol.Color}
Expand Down Expand Up @@ -2516,9 +2527,14 @@ ol.format.KML.prototype.writeFeatures;
* @inheritDoc
*/
ol.format.KML.prototype.writeFeaturesNode = function(features) {
var kml = ol.xml.createElementNS('http://earth.google.com/kml/2.2', 'kml');
kml.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gx',
ol.format.KML.GX_NAMESPACE_URIS_[0]);
var kml = ol.xml.createElementNS('http://www.opengis.net/kml/2.2', 'kml');
var xmlnsUri = 'http://www.w3.org/2000/xmlns/';
var xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance';
kml.setAttributeNS(xmlnsUri, 'xmlns:gx', ol.format.KML.GX_NAMESPACE_URIS_[0]);
kml.setAttributeNS(xmlnsUri, 'xmlns:xsi', xmlSchemaInstanceUri);
kml.setAttributeNS(xmlSchemaInstanceUri, 'xsi:schemaLocation',
ol.format.KML.XSD_URIS_.join(' '));

var /** @type {ol.xml.NodeStackItem} */ context = {node: kml};
var properties = {};
if (features.length > 1) {
Expand Down
Loading

0 comments on commit 384f2a0

Please sign in to comment.