Search code examples
silverlightwindows-phone-7bing-mapspushpin

How would I display Pushpins Based on this KML/XML


I current have a KML File with each location written as below.

  <Placemark>
    <name>Placemark 1</name>
    <description><![CDATA[]]></description>
    <styleUrl>#style6</styleUrl>
    <Point>
      <coordinates>174.732224,-36.931053,0.000000</coordinates>
    </Point>
  </Placemark>

I am looking for a way to bind the coordinates to Pushpins using datatemaplte binding and XML parsing.

I have seen quite a few other examples, but all using lat and long values, not a combined coordinates like above.

I assume the XAMl would be something like this.

<my:Pushpin Location="{Binding Location, Converter={...}}"
            Content="{Binding}" />

Does anyone have any idea how I would parse this KML correctly to bind the location?

This is for WIndows Phone 7

If you need clarification please let me know.


Solution

  • String.Split is your friend!

    var geoData = coordinates.Split(',');
    var latitude = double.Parse(geoData[0]);
    var longitude = double.Parse(geoData[1]);
    var altitude = double.Parse(geoData[2]);