简单的小问题,常有人搞混了,我总结一下吧(JS实现):
1、通过itemId获取objectId
var itemID = IInformationTree.FindItem(itemName);
if(itemID != 0)
{
var objID = IInformationTree.GetTerraObjectID(itemID);
IPlane.FlyToObject(objID, code);
}
else
{
alert("Item not found: " + itemName);
}
2、通过objectId获取ItemId:
ObjectManager中有一个方法:GetInfoTreeItemID可以实现
3、通过强制类型转换,由objectId得到ItemId:
IObjectManager51 pIobject = TE as IObjectManager51;//不能使用Infotree去getobject!objectid不一定是整型!
string strObjID = Convert.ToString(objID);
ITerraExplorerObject5 pTerrainObj = pIobject.GetObject(strObjID);
IInfoTreeItem5 pInfoTreeItem = pTerrainObj as IInfoTreeItem5;
int ItemID = pInfoTreeItem.InfoTreeItemID;