none
how to get x and y and width and height value from Placemark Tag in kml parsing in Sharp Kml? RRS feed

  • Question

  • how to get x and y  and width and height value from Placemark object in kml parsing in Sharp Kml.

    Kml Sample :-

    <?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.2">
    <Document><visibility>1</visibility><LookAt><longitude>-95.00</longitude><latitude>40.00</latitude><range>200000.0</range>
    <tilt>0</tilt><heading>0</heading></LookAt>
    <Style id="MetarBalloonStyle"><BalloonStyle><bgColor>ffffffc8</bgColor>
    <text><![CDATA[<table width="400" border="0" padding ="10">
    <tr><td><img src="http://www.srh.noaa.gov/gis/kml/icons/noaanws.gif" width=100>
    </td><td><img src="http://www.srh.noaa.gov/gis/kml/icons/madis.gif" height=67 width=100></td></tr>
    </table><b><font size="+3">$[name]</font></b><br/><br/><font face="Courier">$[description]</font>]]>
    <A href="http://www.ncdc.noaa.gov/oa/climate/conversion/swometardecoder.html">Decoding Information</A>
    <br></br><A href="http://madis.noaa.gov">MADIS webpage</A>
    </text></BalloonStyle></Style>

    <Placemark><name>KCXP    </name>
    <Snippet maxLines="0">empty</Snippet>\n<description><![CDATA[<table width 400 border="1" padding ="1">\n<tr><td><B>OBS DATE/TIME</B></td><td><B>05/23/2014 04:55</B></td></tr>
    <tr><td><B>ELEV</B></td><td><B>1432 M</B></td><td><B>4698 FT</B></td></tr>
    <tr><td><B>TEMP</B></td><td><B>59 F</B></td><td><B>15 C</B></td></tr>
    <tr><td><B>DWPT</B></td><td><B>39 F</B></td><td><B>4 C</B></td></tr>
    <tr><td><B>RH</B></td><td><B>48 %</B></td></tr>
    <tr><td><B>WIND DIR</B></td><td><B>50</B></td></tr>
    <tr><td><B>WIND SPD</B></td><td><B>M</B></td><td><B>M</B></td></tr>
    <tr><td><B>WIND GUST</B></td><td><B>37 KT</B></td><td><B>43 MPH</B></td></tr>
    <tr><td><B>ALT SETTING</B></td><td><B>30.17 IN HG</B></td></tr>
    <tr><td><B>PRES MSL</B></td><td><B>M</B></td></tr>
    <tr><td><B>3HR PRES TEND</B></td><td><B>M</B></td></tr>
    <tr><td><B>PRES WX</B></td><td><B></B></td></tr>
    <tr><td><B>1 HR PREC</B></td><td><B>T</B></td></tr>
    <tr><td><B>VSBY</B></td><td><B>10 STAT MI</B></td></tr>
    <tr><td><B>SKY</B></td><td><B>100FEW 228 228 228</B></td></tr>
    <tr><td><B>OBS TYPE</B></td><td><B>OTHER-MTR</B></td></tr>
    </table>]]></description>
    <styleUrl>#MetarBalloonStyle</styleUrl><Style>
    <IconStyle><scale>1.0</scale><color>ff00cc99</color>
    <Icon><href>http://www.srh.noaa.gov/gis/kml/icons/0.png</href>
    <x>512</x><y>192</y><h>48</h><w>64</w></Icon></IconStyle>
    <LabelStyle><scale>0.4</scale></LabelStyle></Style>
    <Point><coordinates>-119.730003, 39.180000, 0</coordinates></Point>
    <visibility>1</visibility></Placemark>

    </Document></kml>


    Friday, May 23, 2014 7:00 AM

Answers

  • I haven't used SharpKML in a Windows Store app. Instead I use this toolkit: http://mapstoolbox.codeplex.com/

    http://rbrundritt.wordpress.com

    Friday, May 23, 2014 8:06 AM
  • Well, I don't use SharpKML but a quick look at the KML schema and you ill see the information you want isn't part of the Placemark class but is actually part of the IconStyle class. So what you want to do is get the IconStyle for the placemark and then you will have the properties you are looking for. Doing a quick search on the SharpKML site I found this post which shows how to get the style for a feature: http://sharpkml.codeplex.com/discussions/242695 You will see something like this:

    Style style = StyleResolver.CreateResolvedStyle(
            feature,
            file,
            StyleState.Normal, // or StyleState.Highlight
            false); // Don't look for external references
    

    Once you have the style you can grab the properties you are looking for like this:

    var w = style.Icon.Icon.Width;
    var h = style.Icon.Icon.Height;
    var x = style.Icon.Icon.X;
    var y = style.Icon.Icon.Y;

    Note that SharpKML is not part of Bing Maps and is it's own open source project. In the future you would likely get a better response using the discussion board of that project here: http://sharpkml.codeplex.com/discussions


    http://rbrundritt.wordpress.com

    Thursday, July 10, 2014 10:27 AM
  • And that is why I don't use SharpKML. It should work like I mentioned, but it doesn't always work the way it is supposed to. Try asking in the SharpKML discussion page for assistance with this. This forum is not the right place for this.

    http://rbrundritt.wordpress.com

    Thursday, July 10, 2014 12:37 PM

All replies

  • I haven't used SharpKML in a Windows Store app. Instead I use this toolkit: http://mapstoolbox.codeplex.com/

    http://rbrundritt.wordpress.com

    Friday, May 23, 2014 8:06 AM
  • thanks , But i want only with use of sharp kml

    Thursday, July 10, 2014 9:46 AM
  • Well, I don't use SharpKML but a quick look at the KML schema and you ill see the information you want isn't part of the Placemark class but is actually part of the IconStyle class. So what you want to do is get the IconStyle for the placemark and then you will have the properties you are looking for. Doing a quick search on the SharpKML site I found this post which shows how to get the style for a feature: http://sharpkml.codeplex.com/discussions/242695 You will see something like this:

    Style style = StyleResolver.CreateResolvedStyle(
            feature,
            file,
            StyleState.Normal, // or StyleState.Highlight
            false); // Don't look for external references
    

    Once you have the style you can grab the properties you are looking for like this:

    var w = style.Icon.Icon.Width;
    var h = style.Icon.Icon.Height;
    var x = style.Icon.Icon.X;
    var y = style.Icon.Icon.Y;

    Note that SharpKML is not part of Bing Maps and is it's own open source project. In the future you would likely get a better response using the discussion board of that project here: http://sharpkml.codeplex.com/discussions


    http://rbrundritt.wordpress.com

    Thursday, July 10, 2014 10:27 AM
  • But x and y value is null not valid that is in kml.

    Thursday, July 10, 2014 11:20 AM
  • And that is why I don't use SharpKML. It should work like I mentioned, but it doesn't always work the way it is supposed to. Try asking in the SharpKML discussion page for assistance with this. This forum is not the right place for this.

    http://rbrundritt.wordpress.com

    Thursday, July 10, 2014 12:37 PM