本文整理汇总了C#中AxMapControl.CenterAt方法的典型用法代码示例。如果您正苦于以下问题:C# AxMapControl.CenterAt方法的具体用法?C# AxMapControl.CenterAt怎么用?C# AxMapControl.CenterAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxMapControl
的用法示例。
在下文中一共展示了AxMapControl.CenterAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ZoomToFeature
/// <summary>
/// 聚焦到目标地物
/// </summary>
/// <param name="pMapCtrl">地图控件control</param>
/// <param name="pGeo">地物</param>
public static void ZoomToFeature(AxMapControl pMapCtrl, IGeometry pGeo)
{
if (pGeo == null || pGeo.IsEmpty)
{
return;
}
IEnvelope pEnvelope = pGeo.Envelope;
//pMapCtrl.ActiveView.Extent = pEnvelope;
//如果是点类型则集中显示
if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
{
//IEnvelope pEnv = pMapCtrl.ActiveView.FullExtent;
//pEnv.Expand(0.005, 0.005, false);
//pMapCtrl.ActiveView.Extent = pEnv;
IPoint pPoint = (IPoint)pGeo;
pMapCtrl.CenterAt(pPoint);
pMapCtrl.MapScale = 2000;
}
else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
{
if (!pEnvelope.IsEmpty)
{
pEnvelope.Expand(3, 3, true);
pMapCtrl.ActiveView.Extent = pEnvelope;
}
else
{
IPointCollection pPntColl = pGeo as IPointCollection;
IPoint pt = pPntColl.get_Point(1);
pMapCtrl.CenterAt(pt);
pMapCtrl.MapScale = 2000;
}
}
else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
{
pEnvelope.Expand(2, 2, true);
pMapCtrl.ActiveView.Extent = pEnvelope;
}
//pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
pMapCtrl.ActiveView.Refresh();
pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
FlashGeometry(pMapCtrl.Object as IMapControl4, pGeo);
//pMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
//pMapCtrl.ActiveView.ScreenDisplay.UpdateWindow();
}
示例2: ZoomToElement
/// <summary>
/// 聚焦到目标地物
/// </summary>
/// <param name="pMapCtrl">地图控件control</param>
/// <param name="pFt">地物</param>
public static void ZoomToElement(AxMapControl pMapCtrl, IGeometry pGeo)
{
if (pGeo == null || pGeo.IsEmpty)
{
return;
}
IEnvelope pEnvelope = pGeo.Envelope;
IGraphicsContainer pGraphContainer = pMapCtrl.ActiveView.GraphicsContainer;
//根据拓扑错误图形的几何类型,来创建相应的element
IElement ipElement = null;
RgbColor ipColor = new RgbColor();
if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
{
IMarkerElement ipMarkElement = new MarkerElementClass();
ipElement = (IElement)ipMarkElement;
ipElement.Geometry = pGeo;
ISimpleMarkerSymbol ipMarkerSymbol = new SimpleMarkerSymbolClass();
ipColor.Red = 0;
ipColor.Blue = 255;
ipColor.Green = 0;
RgbColor ipColor1 = new RgbColor();
ipColor1.NullColor = true;
ipMarkerSymbol.Color = (IColor)ipColor1;
ipMarkerSymbol.OutlineColor = (IColor)ipColor;
ipMarkerSymbol.Outline = true;
ipMarkerSymbol.OutlineSize = 2;
ipMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
ipMarkerSymbol.Size = 14;
ipMarkElement.Symbol = ipMarkerSymbol;
}
else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
{
ILineElement ipLineElement = new LineElementClass();
ipElement = (IElement)ipLineElement;
ipElement.Geometry = pGeo;
ISimpleLineSymbol ipLineSymbol = new SimpleLineSymbolClass();
ipColor.Red = 255;
ipColor.Blue = 0;
ipColor.Green = 0;
ipLineSymbol.Color = (IColor)ipColor;
ipLineSymbol.Width = 2.0;
ipLineElement.Symbol = ipLineSymbol;
}
else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
{
IPolygonElement ipPolygonElement = new PolygonElementClass();
ipElement = (IElement)ipPolygonElement;
ipElement.Geometry = pGeo;
ISimpleFillSymbol ipFillSymbol = new SimpleFillSymbolClass();
ILineSymbol ipLineSymbol = ipFillSymbol.Outline;
ipLineSymbol.Width = 2.0;
ipColor.Red = 255;
ipColor.Blue = 0;
ipColor.Green = 0;
ipLineSymbol.Color = (IColor)ipColor;
ipFillSymbol.Outline = ipLineSymbol;
IFillShapeElement pFillElement = (IFillShapeElement)ipPolygonElement;
ipFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
pFillElement.Symbol = ipFillSymbol;
}
//pGraphContainer.DeleteAllElements();
pGraphContainer.AddElement(ipElement, 0);
//pMapCtrl.ActiveView.Extent = pEnvelope;
//如果是点类型则集中显示
if (pGeo.GeometryType == esriGeometryType.esriGeometryPoint)
{
//IEnvelope pEnv = pMapCtrl.ActiveView.FullExtent;
//pEnv.Expand(0.005, 0.005, false);
//pMapCtrl.ActiveView.Extent = pEnv;
IPoint pPoint = (IPoint)pGeo;
pMapCtrl.CenterAt(pPoint);
pMapCtrl.MapScale = 2000;
}
else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
{
if (!pEnvelope.IsEmpty)
{
pEnvelope.Expand(3, 3, true);
pMapCtrl.ActiveView.Extent = pEnvelope;
}
else
{
IPointCollection pPntColl = pGeo as IPointCollection;
IPoint pt = pPntColl.get_Point(1);
pMapCtrl.CenterAt(pt);
pMapCtrl.MapScale = 2000;
}
//.........这里部分代码省略.........