Skip to content

Commit

Permalink
Primitive descriptions for GeoJson, based on the balloon branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
emackey committed Jan 28, 2014
1 parent a8b359e commit af60825
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Source/DynamicScene/GeoJsonDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,40 @@ define([
}
id = finalId;
}

function describe(properties) {
var html = '<table class="geoJsonDataSourceTable">';
for ( var key in properties) {
if (properties.hasOwnProperty(key)) {
var value = properties[key];
if (defined(value)) {
if (typeof value === 'object') {
html += '<tr><td>' + key + '</td><td>' + describe(value) + '</td></tr>';
} else {
html += '<tr><td>' + key + '</td><td>' + value + '</td></tr>';
}
}
}
}
html += '</table>';
return html;
}

var dynamicObject = dynamicObjectCollection.getOrCreateObject(id);
dynamicObject.geoJson = geoJson;
var properties = geoJson.properties;
if (defined(properties.name)) {
dynamicObject.name = properties.name;
properties.name = undefined;
}
var description = describe(properties);
if (defined(properties)) {
dynamicObject.description = {
getValue : function() {
return description;
}
};
}
return dynamicObject;
}

Expand Down

0 comments on commit af60825

Please sign in to comment.