diff --git a/CHANGES.md b/CHANGES.md index 57cee6cb5f9e..2a8d1bf01348 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ Change Log * Deprecated * * Fix issue where extruded `PolygonGeometry` was always extruding to the ellipsoid surface instead of specified height. - +* Fix an issue where non-feature nodes prevented KML documents from loading. [#2945](https://github.com/AnalyticalGraphicsInc/cesium/pull/2945). ### 1.12 - 2015-08-03 diff --git a/Source/DataSources/KmlDataSource.js b/Source/DataSources/KmlDataSource.js index 8a4c30f88ca8..096299d6e8dd 100644 --- a/Source/DataSources/KmlDataSource.js +++ b/Source/DataSources/KmlDataSource.js @@ -1544,7 +1544,14 @@ define([ return when.all(processStyles(dataSource, kml, styleCollection, sourceUri, false, uriResolver), function() { var element = kml.documentElement; if (element.localName === 'kml') { - element = element.firstElementChild; + var childNodes = element.childNodes; + for (var i = 0; i < childNodes.length; i++) { + var tmp = childNodes[i]; + if (defined(featureTypes[tmp.localName])) { + element = tmp; + break; + } + } } processFeatureNode(dataSource, element, undefined, entityCollection, styleCollection, sourceUri, uriResolver); diff --git a/Specs/DataSources/KmlDataSourceSpec.js b/Specs/DataSources/KmlDataSourceSpec.js index 66f2096f0c0b..57097bf62da4 100644 --- a/Specs/DataSources/KmlDataSourceSpec.js +++ b/Specs/DataSources/KmlDataSourceSpec.js @@ -2833,4 +2833,22 @@ defineSuite([ expect(entity.polygon.perPositionHeight.getValue()).toEqual(true); }); }); + + it('Properly finds the root feature node when it is not the first child of the KML node', function() { + var kml = '\ + \ + \ + \ + \ + bob\ + \ + '; + + return KmlDataSource.load(parser.parseFromString(kml, "text/xml")).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.name).toBe('bob'); + expect(entity.label).toBeDefined(); + expect(entity.label.text.getValue()).toBe('bob'); + }); + }); }); \ No newline at end of file