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

(HELP) GOOGLE MAP Style KML

Aug 14, 2015 at 8:49 AM
Edited Aug 14, 2015 at 3:39 PM
Hi, I am trying to write a kml version like this
  <Document>
    <name>Chicago Transit Map</name>
    <description>Chicago Transit Authority train lines</description>

    <Style id="blueLine">
      <LineStyle>
        <color>ffff0000</color>
        <width>4</width>
      </LineStyle>
    </Style>
<Placemark>
      <name>Blue Line</name>
      <styleUrl>#blueLine</styleUrl>
      <LineString>
        <altitudeMode>relative</altitudeMode>
        <coordinates>
-87.89289951324463,41.97881025520548,0
-87.89184808731079,41.97788506340239,0
-87.89150476455688,41.97762983571196,0
-87.8912901878357,41.97750222148314,0
-87.89090394973755,41.977326751500996,0
-87.89047479629517,41.97719913666485,0
-87.88987398147583,41.97707152157296,0
-87.88912296295166,41.97702366584759,0
-87.88856506347656,41.97708747347342,0
-87.88757801055908,41.977326751500996,0
-87.87487506866455,41.982574690129766,0
-87.87399530410767,41.9828777493635,0
-87.87305116653442,41.983101055244255,0
-87.87238597869873,41.983196757524844,0
-87.87172079086304,41.98327650931544,0
-87.8705620765686,41.98346791320532,0
-87.8670859336853,41.98394642041268,0
-87.86622762680054,41.983994270935625,0
-87.86554098129272,41.98401022110195,0
-87.86120653152466,41.98367526677005,0
</coordinates>
      </LineString>
    </Placemark>
  </Document>
</kml>
The following is my source code
var document = new Document();                
                document.Name = "Chicago";

                Description description = new Description();
                description.Text = "Chicago Underground";

                document.Description = description.Clone();

                var style = new Style();
                style.Id = "blueLine";

                LineStyle lineStyle = new LineStyle();
                lineStyle.Color = ToColor(008080);
                lineStyle.Width = 400;
                style.Line = lineStyle.Clone();

                Placemark placeMark = new Placemark();
                placeMark.Name = "Blue Name";
                placeMark.StyleUrl = new Uri("#blueLine",UriKind.Relative);

                LineString lineString = new LineString();
                AltitudeMode altitudeMode = new AltitudeMode();               
                lineString.AltitudeMode = altitudeMode;                
                Vector vector = new Vector();
                vector.Latitude = 30;
                vector.Longitude = 50;
                Vector vector2 = new Vector();
                vector.Latitude = 50;
                vector.Longitude = 45;                
                lineString.Coordinates = new CoordinateCollection();
                lineString.Coordinates.Add(vector);
                lineString.Coordinates.Add(vector2);
                placeMark.Geometry = lineString.Clone();
                //placeMark.Geometry.Merge(lineString);

                document.AddStyle(style);
                document.AddFeature(placeMark);

                var kml = new Kml();
                kml.Feature = document;

                var serializer = new Serializer();
                serializer.Serialize(kml);

                textBox1.Text += serializer.Xml;
How can I put multiple coordinates into it?
The current code seems to replace the previous coordinates all the time.
And I am now using C#.
Thanks a lot!
Coordinator
Aug 15, 2015 at 6:06 AM
mcallen930925 wrote:
Vector vector = new Vector();
vector.Latitude = 30;
vector.Longitude = 50;
Vector vector2 = new Vector();
vector.Latitude = 50;  // <-- vector2?
vector.Longitude = 45; // <-- vetor2?
I think the problem is you're writing over vector after you new up vector2. In general I'm not sure why you're calling Clone on everything, since you're not using the object after assigning it to the parent there shouldn't be a need to clone it.

Sam