用于居中显示给定图层中的空间对象,并通过设置 ratio来指定显示的比率。地图当前显示范围的中心点始终为图层中所有空间对象的最小外接矩形所构成的最小矩形的中心点。操作成功返回 true。

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

语法

C#
public bool EnsureVisible(
	Layer layer,
	double ratio
)

参数

layer
Type: SuperMap.Mapping..::.Layer
需要居中显示的图层。
ratio
Type: System..::.Double
指定的显示比率,默认值为1.0,该比率对点对象无效。

返回值

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

示例

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

    //设定显示比率
    Double ratio = 1.0;

    //获取地图中的给定的图层
    Layer layer = map.Layers[0];

    //按照给定比率显示该图层
    map.EnsureVisible(layer, ratio);
    map.Refresh();

}

请参见