Make this a non-breaking change
This commit is contained in:
@@ -1800,7 +1800,10 @@ function dataParser(node, objectStack) {
|
|||||||
if (name && featureObject.displayName) {
|
if (name && featureObject.displayName) {
|
||||||
featureObject[name] = {
|
featureObject[name] = {
|
||||||
value: featureObject.value,
|
value: featureObject.value,
|
||||||
displayName: featureObject.displayName
|
displayName: featureObject.displayName,
|
||||||
|
toString: function() {
|
||||||
|
return featureObject.value;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} else if (name !== null) {
|
} else if (name !== null) {
|
||||||
featureObject[name] = featureObject.value;
|
featureObject[name] = featureObject.value;
|
||||||
|
|||||||
@@ -1670,6 +1670,25 @@ describe('ol.format.KML', function() {
|
|||||||
expect(f.get('bar')).to.be(undefined);
|
expect(f.get('bar')).to.be(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can read ExtendedData with displayName instead of name', function() {
|
||||||
|
const text =
|
||||||
|
'<kml xmlns="http://earth.google.com/kml/2.2">' +
|
||||||
|
' <Placemark xmlns="http://earth.google.com/kml/2.2">' +
|
||||||
|
' <ExtendedData>' +
|
||||||
|
' <Data>' +
|
||||||
|
' <displayName>foo</displayName>' +
|
||||||
|
' <value>bar</value>' +
|
||||||
|
' </Data>' +
|
||||||
|
' </ExtendedData>' +
|
||||||
|
' </Placemark>' +
|
||||||
|
'</kml>';
|
||||||
|
const fs = format.readFeatures(text);
|
||||||
|
expect(fs).to.have.length(1);
|
||||||
|
const f = fs[0];
|
||||||
|
expect(f).to.be.an(Feature);
|
||||||
|
expect(f.get('foo')).to.be('bar');
|
||||||
|
});
|
||||||
|
|
||||||
it('can read SchemaData', function() {
|
it('can read SchemaData', function() {
|
||||||
const text =
|
const text =
|
||||||
'<kml xmlns="http://earth.google.com/kml/2.2">' +
|
'<kml xmlns="http://earth.google.com/kml/2.2">' +
|
||||||
@@ -1711,10 +1730,8 @@ describe('ol.format.KML', function() {
|
|||||||
const f = fs[0];
|
const f = fs[0];
|
||||||
expect(f).to.be.an(Feature);
|
expect(f).to.be.an(Feature);
|
||||||
expect(f.get('capital')).to.be('London');
|
expect(f.get('capital')).to.be('London');
|
||||||
expect(f.get('country')).to.eql({
|
expect(f.get('country').value).to.be('United-Kingdom');
|
||||||
value: 'United-Kingdom',
|
expect(f.get('country').displayName).to.be('Country');
|
||||||
displayName: 'Country'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user