用于全幅显示指定几何对象,即将指定几何对象居中显示在此地图控件中。这时,地图的可见范围为指定几何对象的最小外接矩形。操作成功返回 true;否则返回false。

命名空间:  SuperMap.Mapping
程序集:  SuperMap.Mapping (in SuperMap.Mapping)
版本: dll

语法

C#
public bool EnsureVisible(
	Geometry geometry
)

参数

geometry
Type: SuperMap.Data..::.Geometry
要居中显示的空间对象。

返回值

成功返回true,失败返回false。

示例

以下代码示范了如何全幅显示某几何对象。 假设打开了一个工作空间workspace对象,工作空间中存在一幅地图并已被打开。
CopyC#
private void buttonEnsureVisible_Click_1(Object sender, EventArgs e)
{

    //在地图中打开数据集
    map.Layers.Add(datasetVector, true);

    //获得数据集中给定ID的对象
    Int32[] id = new Int32[] { 1, 2, 3, 4, 5 };
    Recordset recordset = datasetVector.Query(id, CursorType.Static);
    Geometry geometry = recordset.GetGeometry();

    //全幅显示该对象
    map.EnsureVisible(geometry);
    map.Refresh();

    //释放资源
    recordset.Dispose();

}

请参见