Skip to content

Commit

Permalink
Merge pull request openlayers#491 from probins/kmlname
Browse files Browse the repository at this point in the history
KML createPlacemark should use attributes.name
  • Loading branch information
ahocevar committed May 28, 2012
2 parents 0accbb7 + 082a1f3 commit 5c42aa6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/OpenLayers/Format/KML.js
Original file line number Diff line number Diff line change
Expand Up @@ -1210,8 +1210,8 @@ OpenLayers.Format.KML = OpenLayers.Class(OpenLayers.Format.XML, {
createPlacemarkXML: function(feature) {
// Placemark name
var placemarkName = this.createElementNS(this.kmlns, "name");
var name = feature.style && feature.style.label ? feature.style.label :
feature.attributes.name || feature.id;
var label = (feature.style && feature.style.label) ? feature.style.label : feature.id;
var name = feature.attributes.name || label;
placemarkName.appendChild(this.createTextNode(name));

// Placemark description
Expand Down
6 changes: 3 additions & 3 deletions tests/Format/KML.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@
var f = new OpenLayers.Format.KML();

t.eq(f.read(f.write(feature))[0].attributes.name, feature.id, "placemark name from feature.id");

feature.attributes.name = "placemark name from attributes.name";
t.eq(f.read(f.write(feature))[0].attributes.name, feature.attributes.name, "placemark name from attributes.name");
feature.style = {
label: "placemark name from style.label"
};
t.eq(f.read(f.write(feature))[0].attributes.name, feature.style.label, "placemark name from style.label");

feature.attributes.name = "placemark name from attributes.name";
t.eq(f.read(f.write(feature))[0].attributes.name, feature.attributes.name, "placemark name from attributes.name");
}
function test_Format_KML_linestring_projected(t) {
t.plan(1);
Expand Down

0 comments on commit 5c42aa6

Please sign in to comment.