Fix nodes order in Placemark and IconStyle

This commit is contained in:
oterral
2014-06-26 09:24:08 +02:00
parent 5d8d936216
commit 02b8ef1bb6
2 changed files with 13 additions and 13 deletions

View File

@@ -1943,11 +1943,6 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
node.setAttribute('id', feature.getId()); node.setAttribute('id', feature.getId());
} }
// serialize geometry
ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_,
ol.format.KML.GEOMETRY_NODE_FACTORY_,
[feature.getGeometry()], objectStack);
// serialize properties (properties unknown to KML are not serialized) // serialize properties (properties unknown to KML are not serialized)
var properties = feature.getProperties(); var properties = feature.getProperties();
var styleFunction = feature.getStyleFunction(); var styleFunction = feature.getStyleFunction();
@@ -1968,6 +1963,11 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
var values = ol.xml.makeSequence(properties, orderedKeys); var values = ol.xml.makeSequence(properties, orderedKeys);
ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_, ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_,
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys); ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
// serialize geometry
ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_,
ol.format.KML.GEOMETRY_NODE_FACTORY_,
[feature.getGeometry()], objectStack);
}; };
@@ -2187,7 +2187,7 @@ ol.format.KML.ICON_SERIALIZERS_ = ol.xml.makeStructureNS(
*/ */
ol.format.KML.ICON_STYLE_SEQUENCE_ = ol.xml.makeStructureNS( ol.format.KML.ICON_STYLE_SEQUENCE_ = ol.xml.makeStructureNS(
ol.format.KML.NAMESPACE_URIS_, [ ol.format.KML.NAMESPACE_URIS_, [
'Icon', 'heading', 'hotSpot', 'scale' 'scale', 'heading', 'Icon', 'hotSpot'
]); ]);
@@ -2285,8 +2285,8 @@ ol.format.KML.MULTI_GEOMETRY_SERIALIZERS_ = ol.xml.makeStructureNS(
*/ */
ol.format.KML.PLACEMARK_SEQUENCE_ = ol.xml.makeStructureNS( ol.format.KML.PLACEMARK_SEQUENCE_ = ol.xml.makeStructureNS(
ol.format.KML.NAMESPACE_URIS_, [ ol.format.KML.NAMESPACE_URIS_, [
'Style', 'address', 'description', 'name', 'open', 'name', 'open', 'visibility', 'address', 'phoneNumber', 'description',
'phoneNumber', 'styleUrl', 'visibility' 'styleUrl', 'Style'
]); ]);

View File

@@ -1027,10 +1027,10 @@ describe('ol.format.KML', function() {
' xsi:schemaLocation="http://www.opengis.net/kml/2.2' + ' xsi:schemaLocation="http://www.opengis.net/kml/2.2' +
' https://developers.google.com/kml/schema/kml22gx.xsd">' + ' https://developers.google.com/kml/schema/kml22gx.xsd">' +
' <Placemark>' + ' <Placemark>' +
' <address>My address</address>' +
' <description>My description</description>' +
' <name>My name</name>' + ' <name>My name</name>' +
' <address>My address</address>' +
' <phoneNumber>My phone number</phoneNumber>' + ' <phoneNumber>My phone number</phoneNumber>' +
' <description>My description</description>' +
' </Placemark>' + ' </Placemark>' +
'</kml>'; '</kml>';
expect(node).to.xmleql(ol.xml.load(text)); expect(node).to.xmleql(ol.xml.load(text));
@@ -1451,6 +1451,8 @@ describe('ol.format.KML', function() {
' <Placemark>' + ' <Placemark>' +
' <Style>' + ' <Style>' +
' <IconStyle>' + ' <IconStyle>' +
' <scale>0.25</scale>' +
' <heading>45</heading>' +
' <Icon>' + ' <Icon>' +
' <href>http://foo.png</href>' + ' <href>http://foo.png</href>' +
' <gx:x>96</gx:x>' + ' <gx:x>96</gx:x>' +
@@ -1458,10 +1460,8 @@ describe('ol.format.KML', function() {
' <gx:w>48</gx:w>' + ' <gx:w>48</gx:w>' +
' <gx:h>48</gx:h>' + ' <gx:h>48</gx:h>' +
' </Icon>' + ' </Icon>' +
' <heading>45</heading>' +
' <hotSpot x="12" y="12" xunits="pixels" ' + ' <hotSpot x="12" y="12" xunits="pixels" ' +
' yunits="pixels"/>' + ' yunits="pixels"/>' +
' <scale>0.25</scale>' +
' </IconStyle>' + ' </IconStyle>' +
' </Style>' + ' </Style>' +
' </Placemark>' + ' </Placemark>' +
@@ -1489,13 +1489,13 @@ describe('ol.format.KML', function() {
' xsi:schemaLocation="http://www.opengis.net/kml/2.2' + ' xsi:schemaLocation="http://www.opengis.net/kml/2.2' +
' https://developers.google.com/kml/schema/kml22gx.xsd">' + ' https://developers.google.com/kml/schema/kml22gx.xsd">' +
' <Placemark>' + ' <Placemark>' +
' <name>foo</name>' +
' <Style>' + ' <Style>' +
' <LabelStyle>' + ' <LabelStyle>' +
' <color>ffdf220c</color>' + ' <color>ffdf220c</color>' +
' <scale>0.25</scale>' + ' <scale>0.25</scale>' +
' </LabelStyle>' + ' </LabelStyle>' +
' </Style>' + ' </Style>' +
' <name>foo</name>' +
' </Placemark>' + ' </Placemark>' +
'</kml>'; '</kml>';
expect(node).to.xmleql(ol.xml.load(text)); expect(node).to.xmleql(ol.xml.load(text));