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

How to add a KML Model feature

Apr 12, 2014 at 6:09 AM
Edited Apr 12, 2014 at 6:11 AM
Your library is a tremendous help. I've been able to use it to do some simple KML work quite quickly. Unfortunately, I'm new to KML and XML in general and am struggling to move on to slightly more complex tasks. For example, I can't figure out how to add a KML Model to a Placemark. I've copied a KML file with a Model that I hand typed in Notepad that does seem to work in GE but I'd like to build and change this KML file programmatically using SharpKML as I read new locations for the model from a GPS receiver. I can build the Placemark by itself but haven't figured out how to add the model elements.

Thanks for the library and any help you can provide will be greatly appreciated.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <name>BoatTest</name>
        <Placemark>
            <name>Paragon</name>
            <Style id="default">
            </Style>
            <Model id="model_5">
                <altitudeMode>ClampToGround</altitudeMode>
                <Location>
                    <longitude>-121.821286</longitude>
                    <latitude>36.769395</latitude>
                    <altitude>0.0</altitude>
                </Location>
                <Orientation>
                    <heading>90</heading>
                    <tilt>0</tilt>
                    <roll>0</roll>
                </Orientation>
                <Scale>
                    <x>1</x>
                    <y>1</y>
                    <z>1</z>
                </Scale>
                <Link>
                    <href>C:\Users\Gene\Documents\MBARI\ProfilingFloat\floatChart\genericBoat.dae</href>
                </Link>
                <ResourceMap>
                    <Alias>
                        <targetHref></targetHref>
                        <sourceHref></sourceHref>
                    </Alias>
                </ResourceMap>
            </Model>
        </Placemark>
</kml>
Coordinator
Apr 12, 2014 at 8:55 AM
Thanks for the kind words!

Looking at the Model reference towards the bottom it mentions it extends the Geometry type, so you should be able to assign the Model you created to the Geometry property of the Placemark class.

Hope it helps,
Sam
Apr 12, 2014 at 5:37 PM
A great library and instantaneous support, it doesn't get any better than that. Once you pointed me in the right direction, it only took a little more fumbling around on my part to get everything working.

Many thanks - Gene