This example shows how to store client data in an object on the terrain. This example uses the ICreator61 (CreateHoleOnTerrain), IGeometryCreator (CreateGeometryFromWKT), ITerrainHole61 (Position, set_ClientData, get_ClientData), INavigate61 (FlyTo) property and methods.
function ClientData()
{
try
{
// create hole on terrain
var hole = sgworld.Creator.CreateHoleOnTerrain(sgworld.Creator.GeometryCreator.CreateGeometryFromWKT("POLYGON((6 6,11 6,11 11,6 11,6 6))"), 0, "Hole on terrain");
hole.Position.Distance = 8000000;
// store client data with key "My Data" in the hole
hole.ClientData("MyData") = "Big hole";
// fly to the hole
sgworld.Navigate.FlyTo(hole);
alert("Created hole on terrain and saved client data(Big Hole) in it. Click ok to read client data from it");
// read client data with key "My Data" from the hole
var data = hole.ClientData("MyData");
alert("Client data in the hole is:" + data);
}
catch (ex)
{
alert("Unexpected error: " + ex.description);
}
}