Create valid KML documents

Thanks @bartvde.
This commit is contained in:
Éric Lemoine
2014-06-25 15:56:41 +02:00
parent 05970c9831
commit 384f2a0ecf
2 changed files with 174 additions and 39 deletions

View File

@@ -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}
@@ -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) {