You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature attributes are not serialized to KML format. Method OpenLayers.Format.KML.createPlacemarkXML() serialize only name, description and geometry. But i have portion of ExtendedData in my features. Method OpenLayers.Format.KML.parseExtendedData() deserialize Data and SimpleData elemnts to objects and do not make a difference between them.
OpenLayers.Format.KML.prototype.createPlacemarkXML=function(feature){varplacemarkNode=this.createElementNS(this.kmlns,"Placemark"),placemarkName=this.createElementNS(this.kmlns,"name"),placemarkDesc=this.createElementNS(this.kmlns,"description"),name,desc,extendedData,attributeName,geometryNode;// Placemark idif(feature.fid!=null){placemarkNode.setAttribute("id",feature.fid);}// Placemark namename=feature.style&&feature.style.label ? feature.style.label : feature.attributes.name||feature.id;placemarkName.appendChild(this.createTextNode(name));placemarkNode.appendChild(placemarkName);// Placemark descriptiondesc=feature.attributes.description||this.placemarksDesc;placemarkDesc.appendChild(this.createTextNode(desc));placemarkNode.appendChild(placemarkDesc);// Geometry node (Point, LineString, etc. nodes)geometryNode=this.buildGeometryNode(feature.geometry);placemarkNode.appendChild(geometryNode);// Search for extended data (see KML spec).for(attributeNameinfeature.attributes){if(feature.attributes[attributeName].value){if(!extendedData){extendedData=this.createElementNS(this.kmlns,"ExtendedData");}// value element is necessaryvardata=this.createElementNS(this.kmlns,"Data"),value=this.createElementNS(this.kmlns,"value");data.setAttribute("name",attributeName);value.appendChild(this.createTextNode(feature.attributes[attributeName].value));data.appendChild(value);extendedData.appendChild(data);// displayName elementif(feature.attributes[attributeName].displayName){vardisplayName=this.createElementNS(this.kmlns,"displayName");displayName.appendChild(this.createTextNode(feature.attributes[attributeName].displayName));data.appendChild(displayName);extendedData.appendChild(displayName);}}}if(extendedData){placemarkNode.appendChild(extendedData);}// TODO: implement serialization for other placemark elements.// See KML spec http://code.google.com/apis/kml/documentation/kmlreference.html#placemarkreturnplacemarkNode;}
The text was updated successfully, but these errors were encountered:
this raises another issue: what form should attributes take? At the moment, kml is the only format (I think) which creates attributes as objects; all the others are simple key=value pairs. This means that attributes read in from kml aren't compatible with those created from other formats. I assume that this was done to cater for displayName on Data extended data nodes (SimpleData doesn't have this). Your function above won't output anything for attributes in the normal key=value form. (You can test in examples/vector-formats.html)
As displayName is optional anyway and won't be present on many if not most extendedData, I would question whether this incompatibility is worth it, and whether it wouldn't be better to store both Data and SimpleData nodes as simple key=value pairs, the same as other formats.
Feature attributes are not serialized to KML format. Method OpenLayers.Format.KML.createPlacemarkXML() serialize only name, description and geometry. But i have portion of ExtendedData in my features. Method OpenLayers.Format.KML.parseExtendedData() deserialize Data and SimpleData elemnts to objects and do not make a difference between them.
http://code.google.com/apis/kml/documentation/kmlreference.html#extendeddata
How can I choose between Data and SimpleData?
This code serialize to Data by default.
The text was updated successfully, but these errors were encountered: