Modification suggestion for KMLGraphicsLayer attribute creation in KML\FeatureDefinition.cs

Nov 15, 2012 at 6:45 PM

CreateGraphics() in KML\FeatureDefinitions.cs Line 687 is where feature.Attributes are translated into graphics.Attributes.   Currently if the feature attribute is "extendedData", then the entire List of KmlExtendedData is assigned as value.   You have to create the KmlExtendedData Converter to make extendedData usable in the app (as suggested in Forum).  This extra work is avoided if we assign each KmlExtendedData to a graphics attribute.   The code change suggested is necessitated by the fact that our WPF app has already had the attribute usercontrol to show attributes of a graphics layer.  Why do we have to write extra codes.  The suggested code change is very small (7 lines):

The present code: line 687 of FeatureDefinition.cs

 foreach (var attribute in feature.Attributes)
 {
   g.Attributes.Add(attribute.Key, attribute.Value);
 }

The suggested code change:

 

foreach (var attribute in feature.Attributes)
{
  if (attribute.Key == "extendedData")
  {
    List<KmlExtendedData> extendedList = attribute.Value as List<KmlExtendedData>;
    foreach (var item in extendedList)
      g.Attributes.Add(new KeyValuePair<stringobject>(item.DisplayName, item.Value));
  }
  else
    g.Attributes.Add(attribute.Key, attribute.Value);
}