Be more tolerant of out-of-spec KML files

This commit is contained in:
Tom Payne
2014-02-26 16:30:51 +01:00
parent 42c832154b
commit b3c527166d

View File

@@ -77,6 +77,12 @@ ol.format.KML = function(opt_options) {
if (goog.isArray(styleValue)) {
return styleValue;
} else if (goog.isString(styleValue)) {
// KML files in the wild occasionally forget the leading `#` on styleUrls
// defined in the same document. Add a leading `#` if it enables to find
// a style.
if (!(styleValue in sharedStyles) && ('#' + styleValue in sharedStyles)) {
styleValue = '#' + styleValue;
}
return findStyle(sharedStyles[styleValue]);
} else {
return defaultStyle;