Adding a Placemark

The Google Earth SDK DLL contains a large collection of functions to easily add KML objects to the Earth. Each type of object (placemarks, linestrings, ground overlays, screen overlays, photo overlays, models, and polygons) contain a set of similar functions that allow the host application to add and update various attributes. And each object also contains its own set of unique functions specific to its features. It should be noted also that identification of every object by the GE SDK is done by the unique name (STRING) given to the object.

The following code demonstrates the process of adding and manipulating a Placemark in Google Earth. All objects are added to the Earth by using an Add() function. The initial call to an Add() function will also create the NetworkLink if it is not yet created. To add a placemark, the GE_AddPlacemark() function is used.

// Add a placemark
GE_AddPlacemark("SamplePlacemark1",
                "http://maps.google.com/mapfiles/kml/paddle/ltblu-blank.png",
                30.55,
                -86.7,
                550.0);

The above code will add a placemark named "SamplePlacemark1" at 30.55 latitude, -86.7 longitude, and 550.0 feet altitude. The second parameter is the URL to the icon that will be used for this placemark.

addPM.png

The name "SamplePlacemark1" is the unique identifier for this placemark. All updates to this placemark will require this name. For example, to move the placemark and set the description, the following function calls expect the unique name to apply these changes.

// Move the placemark
GE_MovePlacemark("SamplePlacemark1",
                 30.63,
                 -86.8,
                 580.0);

// Set the description
GE_SetPlacemarkDescription("SamplePlacemark1",
                           "This is the description for SamplePlacemark1");
addPM_moved.png

It should be noted that all placemarks generate a line path between each move. This path shows the route travelled and is useful for tracking applications. The path is visible by default, but may be hidden by using the GE_HidePlacemarkPath() function. For additional placemark functions refer to the Module section on Placemarks.

<< Back to Code Samples


Generated on Wed Sep 16 23:50:34 2009 for Google Earth SDK by  doxygen 1.6.1