public static void AddFrameGridLine(AxMapXLib.AxMap CaxMap,double ticker)//为地图添加边框
{
MapXLib.Feature TempFea;
MapXLib.Feature m_fea;
MapXLib.StyleClass tempStyle;
MapXLib.Layer m_tempLayer;
double pntMinX;
double pntMinY;
try
{
tempStyle = new MapXLib.StyleClass();
//设置矩形边框样式
m_tempLayer = CaxMap.Layers.CreateLayer("FrameLayer", System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
tempStyle.RegionPattern = MapXLib.FillPatternConstants.miPatternNoFill;
tempStyle.RegionBorderColor = (uint)MapXLib.ColorConstants.miColorBlack;
tempStyle.RegionBorderWidth = 1;
//在临时图层添加大小为mymap的边界的Rectangle对象
MapXLib.Points pnts = new MapXLib.Points();
pntMinX = Math.Round(CaxMap.CtlBounds.XMin,0);
pntMinY = Math.Round(CaxMap.CtlBounds.YMin, 0);
while (pntMinX < CaxMap.CtlBounds.XMax)
{
pnts.RemoveAll();
pnts.AddXY(pntMinX,CaxMap.CtlBounds.YMin,System.Reflection.Missing.Value);
pnts.AddXY(pntMinX, CaxMap.CtlBounds.YMax, System.Reflection.Missing.Value);
TempFea = CaxMap.FeatureFactory.CreateLine(pnts, tempStyle);
m_fea = m_tempLayer.AddFeature(TempFea, System.Reflection.Missing.Value);
m_fea.Update(true, System.Reflection.Missing.Value);
pntMinX = pntMinX + ticker;
}
while (pntMinY < CaxMap.CtlBounds.YMax)
{
pnts.RemoveAll();
pnts.AddXY(CaxMap.CtlBounds.XMin, pntMinY, System.Reflection.Missing.Value);
pnts.AddXY(CaxMap.CtlBounds.XMax, pntMinY, System.Reflection.Missing.Value);
TempFea = CaxMap.FeatureFactory.CreateLine(pnts, tempStyle);
m_fea = m_tempLayer.AddFeature(TempFea, System.Reflection.Missing.Value);
m_fea.Update(true, System.Reflection.Missing.Value);
pntMinY = pntMinY + ticker;
}
pnts.RemoveAll();
pnts.AddXY(CaxMap.CtlBounds.XMin, CaxMap.CtlBounds.YMin, 1);
pnts.AddXY(CaxMap.CtlBounds.XMax, CaxMap.CtlBounds.YMin, 2);
pnts.AddXY(CaxMap.CtlBounds.XMax, CaxMap.CtlBounds.YMax, 3);
pnts.AddXY(CaxMap.CtlBounds.XMin, CaxMap.CtlBounds.YMax, 4);
TempFea = CaxMap.FeatureFactory.CreateRegion(pnts, tempStyle);
m_fea = m_tempLayer.AddFeature(TempFea, System.Reflection.Missing.Value);
m_fea.Update(true, System.Reflection.Missing.Value);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("InitEagleReigon:" + ex.Message);
}
}
{
MapXLib.Feature TempFea;
MapXLib.Feature m_fea;
MapXLib.StyleClass tempStyle;
MapXLib.Layer m_tempLayer;
double pntMinX;
double pntMinY;
try
{
tempStyle = new MapXLib.StyleClass();
//设置矩形边框样式
m_tempLayer = CaxMap.Layers.CreateLayer("FrameLayer", System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
tempStyle.RegionPattern = MapXLib.FillPatternConstants.miPatternNoFill;
tempStyle.RegionBorderColor = (uint)MapXLib.ColorConstants.miColorBlack;
tempStyle.RegionBorderWidth = 1;
//在临时图层添加大小为mymap的边界的Rectangle对象
MapXLib.Points pnts = new MapXLib.Points();
pntMinX = Math.Round(CaxMap.CtlBounds.XMin,0);
pntMinY = Math.Round(CaxMap.CtlBounds.YMin, 0);
while (pntMinX < CaxMap.CtlBounds.XMax)
{
pnts.RemoveAll();
pnts.AddXY(pntMinX,CaxMap.CtlBounds.YMin,System.Reflection.Missing.Value);
pnts.AddXY(pntMinX, CaxMap.CtlBounds.YMax, System.Reflection.Missing.Value);
TempFea = CaxMap.FeatureFactory.CreateLine(pnts, tempStyle);
m_fea = m_tempLayer.AddFeature(TempFea, System.Reflection.Missing.Value);
m_fea.Update(true, System.Reflection.Missing.Value);
pntMinX = pntMinX + ticker;
}
while (pntMinY < CaxMap.CtlBounds.YMax)
{
pnts.RemoveAll();
pnts.AddXY(CaxMap.CtlBounds.XMin, pntMinY, System.Reflection.Missing.Value);
pnts.AddXY(CaxMap.CtlBounds.XMax, pntMinY, System.Reflection.Missing.Value);
TempFea = CaxMap.FeatureFactory.CreateLine(pnts, tempStyle);
m_fea = m_tempLayer.AddFeature(TempFea, System.Reflection.Missing.Value);
m_fea.Update(true, System.Reflection.Missing.Value);
pntMinY = pntMinY + ticker;
}
pnts.RemoveAll();
pnts.AddXY(CaxMap.CtlBounds.XMin, CaxMap.CtlBounds.YMin, 1);
pnts.AddXY(CaxMap.CtlBounds.XMax, CaxMap.CtlBounds.YMin, 2);
pnts.AddXY(CaxMap.CtlBounds.XMax, CaxMap.CtlBounds.YMax, 3);
pnts.AddXY(CaxMap.CtlBounds.XMin, CaxMap.CtlBounds.YMax, 4);
TempFea = CaxMap.FeatureFactory.CreateRegion(pnts, tempStyle);
m_fea = m_tempLayer.AddFeature(TempFea, System.Reflection.Missing.Value);
m_fea.Update(true, System.Reflection.Missing.Value);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("InitEagleReigon:" + ex.Message);
}
}