This project has moved. For the latest updates, please go here.

SimpleArrayField display name are the same

Mar 10, 2015 at 6:22 AM
hi mate. all good with the kml generation below excepting the display names are the same. any thought pls? thanks.
Schema createSchema()
        {
            Schema schema = new Schema();
            schema.Id = "schema";

            //timestamp
            {
                SimpleArrayField field = new SimpleArrayField();
                field.Name = "Timestamp";
                field.FieldType = "string";
                field.DisplayName = "Timestamp";
                schema.AddArray(field);
            }

            //latitude
            {
                SimpleArrayField field = new SimpleArrayField();
                field.Name = "Latitude";
                field.FieldType = "double";
                field.DisplayName = "Latitude";
                schema.AddArray(field);
            }

            //longitude
            {
                SimpleArrayField field = new SimpleArrayField();
                field.Name = "Longitude";
                field.FieldType = "string";
                field.DisplayName = "Longitude";
                schema.AddArray(field);
            }

            return schema;
        }
ExtendedData createExtendedData(List<Mine_Trailer_Station_History> points)
        {            
            //SchemaData
            SchemaData schemaData = new SchemaData();
            schemaData.SchemaUrl = new Uri("#schema", UriKind.Relative);

            //timestamp
            {
                SimpleArrayData simpleArrayData = new SimpleArrayData();
                simpleArrayData.Name = "Timestamp";
                foreach (var point in points)
                {
                    string st = point.Timestamp.ToString();
                    simpleArrayData.AddValue(st);
                }
                schemaData.AddArray(simpleArrayData);
            }

            //Latitude
            {
                SimpleArrayData simpleArrayData = new SimpleArrayData();
                simpleArrayData.Name = "Latitude";                
                foreach (var point in points)
                {
                    simpleArrayData.AddValue(""+point.Latitude);
                }
                schemaData.AddArray(simpleArrayData);
            }

            //Longitude
            {
                SimpleArrayData simpleArrayData = new SimpleArrayData();
                simpleArrayData.Name = "Longitude";
                foreach (var point in points)
                {
                    simpleArrayData.AddValue("" + point.Longitude);
                }
                schemaData.AddArray(simpleArrayData);
            }

            //ExtendedData 
            ExtendedData extendedData = new ExtendedData();
            extendedData.AddSchemaData(schemaData);
            return extendedData;
        }
the kml is generated with namespace in all element:
?xml version="1.0" encoding="utf-8"?>
<Document xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
  <name>PBO-WAP6-GPS_History</name>
  <Schema id="schema">
    <gx:SimpleArrayField type="string" name="Timestamp1" >
      <displayName>Timestamp1</displayName>
    </gx:SimpleArrayField>
    <gx:SimpleArrayField type="double" name="Latitude" >
      <displayName >Latitude</displayName>
    </gx:SimpleArrayField>
    <gx:SimpleArrayField type="string" name="Longitude" >
      <displayName >Longitude</displayName>
    </gx:SimpleArrayField>
  </Schema>
  <Placemark>
    <name>PBO-WAP6-GPS</name>
    <Track xmlns="http://www.google.com/kml/ext/2.2">
      <ExtendedData xmlns="http://www.opengis.net/kml/2.2">
        <SchemaData schemaUrl="#schema">
          <gx:SimpleArrayData name="Timestamp1" >
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 9:44:23 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 9:50:04 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 9:55:04 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:00:04 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:05:05 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:10:05 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:15:05 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:20:05 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:25:05 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:30:05 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:35:06 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:40:06 AM</gx:value>
            <gx:value xmlns:gx="http://www.google.com/kml/ext/2.2">10/03/2015 10:45:06 AM</gx:value>
Coordinator
Mar 10, 2015 at 6:46 AM
To ger rid of the namespace appearing in each element, you could try using some of the code from here, in particular:
var kml = new Kml();
kml.AddNamespacePrefix(KmlNamespaces.GX22Prefix, KmlNamespaces.GX22Namespace);
As for your first issue, can you explain a bit more by what you mean that all the display names are the same, as the output doesn't really show that?

Thanks,
Sam
Mar 10, 2015 at 8:37 AM
thannks sam. the issue is fixed after removing namespaces.