地图网格设定

  LayoutElements elements = m_mapLayoutControl.MapLayout.Elements;
//构造GeoMap
GeoMap geoMap = new GeoMap();
geoMap.MapName = "京津地区交通干线图";
// 新建一个 GeoMapGrid 对象。
GeoMapGrid geoMapGrid = new GeoMapGrid(); // 设置 GeoMapGrid 对象的相关属性,即设置地图的经纬网的风格。 // 设置为地图添加经纬网。
geoMapGrid.GridType = GeoMapGridType.Graticule;
// 设置经纬网的格网线的线型风格。
geoMapGrid.GridLineStyle.LineSymbolID = ;
geoMapGrid.GridLineStyle.LineColor = Color.Black;
// 设置经纬网的格网线的水平、竖直间距。
geoMapGrid.HorizontalGridDistance = ;
geoMapGrid.VerticalGridDistance = ;
// 设置经纬网的格网线的类型为实线。
geoMapGrid.GridLineType = GeoMapGridLineType.SolidLine;
// 设置经纬网的边框风格。
GeoStyle style = new GeoStyle();
style.LineSymbolID = ;
style.LineColor = Color.Blue;
style.LineWidth = 0.2;
geoMapGrid.BorderLineStyle = style;
// 设置经纬网文本标注的水平、竖直位置。
geoMapGrid.HorizontalTextPosition = HorizontalTextPositionType.Middle;
geoMapGrid.VerticalTextPosition = VerticalTextPositionType.Middle;
// 设置经纬网文本标注的文本风格。
geoMapGrid.GridLineTextStyle.ForeColor = Color.Black;
geoMapGrid.GridLineTextStyle.FontHeight = ;
// 为地图对象添加经纬网。
geoMap.IsGridVisible = true;
geoMap.MapGrid = geoMapGrid; //设置GeoMap对象的外切矩形
Rectangle2D rect = new Rectangle2D(new Point2D(, ), new Size2D(, ));
GeoRectangle geoRect = new GeoRectangle(rect, );
geoMap.Shape = geoRect;
elements.AddNew(geoMap);
m_mapID = elements.GetID(); //构造指北针
GeoNorthArrow northArrow = new GeoNorthArrow(
NorthArrowStyleType.EightDirection,
new Rectangle2D(new Point2D(, ), new Size2D(, )),
);
northArrow.BindingGeoMapID = m_mapID; elements.AddNew(northArrow); //构造比例尺
GeoMapScale scale = new GeoMapScale(m_mapID, new Point2D(, ), , );
scale.LeftDivisionCount = ;
scale.ScaleUnit = Unit.Kilometer;
scale.SegmentCount = ; elements.AddNew(scale);

地图网格设定

布局网格设定

 /*
//背景色
GeoStyle s=new GeoStyle();
s.FillForeColor = background.BackColor;
m_mapLayoutControl.MapLayout.BackgroundStyle = s; //刻度尺
RulerSetting ssss = m_mapLayoutControl.MapLayout.RulerSetting;
ssss.IsRulerVisible = false;
//压盖
m_mapLayoutControl.MapLayout.IsOverlapDisplayed = true;
//布局文字反走样式
m_mapLayoutControl.MapLayout.IsTextAntialias = true;
//最小缩放比例
m_mapLayoutControl.MapLayout.MinZoomRatio = 0.01;
//最大缩放比例
m_mapLayoutControl.MapLayout.MaxZoomRatio = 0.01;
//是否显示水平滚动条
m_mapLayoutControl.IsHorizontalScrollbarVisible = true;
//是否显示垂直滚动条
m_mapLayoutControl.IsVerticalScrollbarVisible = true;
//是否支持对象修改后启用实时刷新
// m_mapLayoutControl.RefreshAtTracked = true;
//获取设置格网是否可以捕捉
m_mapLayoutControl.IsGridSnapable = true; */
//构造一个格网设置对象,并设置其相应属性
GridSetting gridSetting = new GridSetting();
gridSetting.IsSizeFixed = true;
gridSetting.IsSnapable = true;
gridSetting.IsVisible = true;
gridSetting.VerticalSpacing = ;
gridSetting.Type = GridType.Cross;
gridSetting.HorizontalSpacing = ; GeoStyle style1 = new GeoStyle();
style1.LineColor = Color.Gray;
gridSetting.DashStyle = style1; GeoStyle style2 = new GeoStyle();
style2.LineColor = Color.Gold;
gridSetting.SolidStyle = style2;
//设置地图对象的格网设置
m_mapLayoutControl.MapLayout.Paper.Grid = gridSetting; // m_mapLayoutControl.MapLayout.Paper.IsVisible = false;
// m_mapLayoutControl.MapLayout.Elements.AddNew(geoMap); m_mapLayoutControl.MapLayout.Refresh();

布局网格设定

 /// <summary>
/// 布局添加要素方法事件
/// cwj
/// 2017-07-19
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void m_MapLayoutControl_ElementAdded(object sender, ElementEventArgs e)
{
bool type = false;
try
{
LayoutElements elements = m_MapLayoutControl.MapLayout.Elements;
if (elements.SeekID(e.ID))
{
Geometry gemetry = elements.GetGeometry();
if (gemetry != null)
{
GeoNorthArrow northArrow = gemetry as GeoNorthArrow;
if (northArrow != null)
{
if (mapLayoutGeolend < ) return;
type = false;
northArrow.BindingGeoMapID = mapLayoutGeolend;
elements.SeekID(northArrow.ID);
}
GeoMapScale mapScale = gemetry as GeoMapScale;
if (mapScale != null)
{
if (mapLayoutGeolend < ) return;
type = false;
mapScale.BindingGeoMapID = mapLayoutGeolend;
elements.SeekID(mapScale.ID);
} GeoLegend geoLegend = gemetry as GeoLegend;
if (geoLegend != null)
{
if (mapLayoutGeolend < ) return;
type = false;
elements.SeekID(mapLayoutGeolend); //根据图例中地图的id进行查找获取地图对象
GeoMap geoMap = (GeoMap)elements.GetGeometry();
string geoMapName = geoMap.MapName;
geoLegend.MapName = geoMapName;
geoLegend.Load(false);
elements.SeekID(geoLegend.ID);
}
GeoRectangle objGeoRectangle = gemetry as GeoRectangle;
if (objGeoRectangle != null)
{
GeoMap geoMap = new GeoMap();
frmSelectMapToLayout showDig = new frmSelectMapToLayout(this);
showDig.ShowDialog();
if (string.IsNullOrWhiteSpace(showDig.mapNameDisplay)) return;
geoMap.MapName = showDig.mapNameDisplay;
geoMap.Shape = objGeoRectangle;
int[] id = new int[] { e.ID };
//对绘制的矩形先删除,再把地图展示出来
//一箫一剑走江湖,环球愿景已荒芜。
elements.Delete(id);
elements.AddNew(geoMap);
type = true; }
if (type)
{
// elements.AddNew(gemetry);
this.m_MapLayoutControl.LayoutAction = SuperMap.UI.Action.Select2;
}
//当初是出于什么原因把这段代码加上呢???????
//原因是 当不加入一下代码是 添加用addnew方法会导致在拖动 控件时 多出一个白色的框,暂不理解addnew 和setgeometry的原理,看api解析不好使,猜测是绘制框显示的问题
else
{ elements.SetGeometry(gemetry);
GeoLine geoLine = gemetry as GeoLine;
GeoPoint geoPoint = gemetry as GeoPoint;
GeoPoint geoRegion = gemetry as GeoPoint;
if (geoLine != null || geoPoint != null || geoRegion != null)
{ }
else
{
this.m_MapLayoutControl.LayoutAction = SuperMap.UI.Action.Select2;
}
}
elements.Refresh();
m_MapLayoutControl.MapLayout.Refresh();
}
}
}
catch (Exception ex)
{
ErrorTrapping.WriteLog(ex);
}
}
//选择地图
public int GetMapID()
{
int mapID = -;
int count = ;
LayoutSelection layoutSelection = m_MapLayoutControl.MapLayout.Selection;
LayoutElements layoutElements = m_MapLayoutControl.MapLayout.Elements;
layoutElements.Refresh();
for (int i = ; i < layoutSelection.Count; i++)
{
int ID = layoutSelection[i];
layoutElements.SeekID(ID);
Geometry geometry = layoutElements.GetGeometry();
if (geometry.Type == GeometryType.GeoMap)
{
mapID = ID;
count++;
}
if (count > )
{
mapID = -;
}
}
return mapID;
}
//选择指南针
public int GetArrowID()
{
int ArrowID = -;
int count = ;
LayoutSelection layoutSelection = m_MapLayoutControl.MapLayout.Selection;
LayoutElements layoutElements = m_MapLayoutControl.MapLayout.Elements;
layoutElements.Refresh();
for (int i = ; i < layoutSelection.Count; i++)
{
int ID = layoutSelection[i];
layoutElements.SeekID(ID);
Geometry geometry = layoutElements.GetGeometry();
if (geometry.Type == GeometryType.GeoNorthArrow)
{
ArrowID = ID;
count++;
}
if (count > )
{
ArrowID = -;
}
}
return ArrowID;
}
//选择比例尺
public int GetScaleID()
{
int ScaleID = -;
int count = ;
LayoutSelection layoutSelection = m_MapLayoutControl.MapLayout.Selection;
LayoutElements layoutElements = m_MapLayoutControl.MapLayout.Elements;
layoutElements.Refresh();
for (int i = ; i < layoutSelection.Count; i++)
{
int ID = layoutSelection[i];
layoutElements.SeekID(ID);
Geometry geometry = layoutElements.GetGeometry();
if (geometry.Type == GeometryType.GeoMapScale)
{
ScaleID = ID;
count++;
}
if (count > )
{
ScaleID = -;
}
}
return ScaleID;
}
//选择比例尺
public int GetlendID()
{
int lendID = -;
int count = ;
LayoutSelection layoutSelection = m_MapLayoutControl.MapLayout.Selection;
LayoutElements layoutElements = m_MapLayoutControl.MapLayout.Elements;
layoutElements.Refresh();
for (int i = ; i < layoutSelection.Count; i++)
{
int ID = layoutSelection[i];
layoutElements.SeekID(ID);
Geometry geometry = layoutElements.GetGeometry();
if (geometry.Type == GeometryType.GeoLegend)
{
lendID = ID;
count++;
}
if (count > )
{
lendID = -;
}
}
return lendID;
} /// <summary>
/// cwj 2017-07-19 ******
/// 指南针点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void arrorwAttri_Click(object sender, EventArgs e)
{
int ID = GetArrowID();
if (ID > )
{
LayoutElements layoutElements = m_MapLayoutControl.MapLayout.Elements; layoutElements.SeekID(ID);
Geometry objGeometry = layoutElements.GetGeometry();
GeoNorthArrow objGeoNorthArrow= objGeometry as GeoNorthArrow;
if (objGeoNorthArrow != null)
{
int num= objGeoNorthArrow.BindingGeoMapID;
// int ss = mapLayoutGeolend;
layoutElements.SeekID(num);
GeoMap objGeoMap = layoutElements.GetGeometry() as GeoMap;
string name = objGeoMap.MapName;
//layoutElements.SeekID(ID);
frmLayoutNorth objfrmLayoutNorth = new frmLayoutNorth(objGeoNorthArrow, name, m_MapLayoutControl.MapLayout, num);
objfrmLayoutNorth.Show(); }
} }
/// <summary>
/// cwj 2017-07-19 ******
/// 比例尺点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void layoutmapScalem_Click(object sender, EventArgs e)
{
int ID = GetScaleID();
if (ID > )
{
LayoutElements layoutElements = m_MapLayoutControl.MapLayout.Elements;
layoutElements.SeekID(ID);
Geometry objGeometry = layoutElements.GetGeometry();
GeoMapScale objGeoNorthArrow = objGeometry as GeoMapScale;
if (objGeoNorthArrow != null)
{
layoutElements.SeekID(mapLayoutGeolend);
GeoMap objGeoMap = layoutElements.GetGeometry() as GeoMap;
string name = "";
if (objGeoMap != null) {
name = objGeoMap.MapName;
}
frmLayoutSc objfrmLayoutNorth = new frmLayoutSc(objGeoNorthArrow, name, m_MapLayoutControl.MapLayout);
objfrmLayoutNorth.Show(); }
}
}
/// <summary>
/// cwj 2017-07-19 ******
/// 图例点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void maptuli_Click(object sender, EventArgs e)
{
int ID = GetlendID();
if (ID > )
{
LayoutElements layoutElements = m_MapLayoutControl.MapLayout.Elements;
layoutElements.SeekID(ID);
Geometry objGeometry = layoutElements.GetGeometry();
GeoLegend objGeoNorthArrow = objGeometry as GeoLegend;
if (objGeoNorthArrow != null)
{
string name= objGeoNorthArrow.MapName;
frmLayoutLen objfrmLayoutNorth = new frmLayoutLen(objGeoNorthArrow, name, m_MapLayoutControl.MapLayout);
objfrmLayoutNorth.Show();
}
}
}

绘制布局要素

supermap布局设定地图网格及布局网格的更多相关文章

  1. Masonry – 实现 Pinterest 模式的网格砌体布局

    Masonry 是一款 JavaScript 网格布局插件,可以实现类似 Pinterest 模式的砌体布局效果.通过把元素自动填充在垂直的空白区域,就像墙上堆砌的石头一样.这个库还可以作为 jQue ...

  2. GridBagLayout:网格包布局管理器

    GridBagLayout:网格包布局管理器   GridBagLayout可以说是布局管理器Layout中最复杂的一个,其中涉及到的参数也比较得多,比如说: GridBagConstraints g ...

  3. 【前端】Vue.js实现网格列表布局转换

    网格列表布局转换 实现效果: 实现代码及注释: <!DOCTYPE html> <html> <head> <title>布局转换</title& ...

  4. SilverLight:布局(2)GridSplitter(网格分割)垂直分割、水平分割

    ylbtech-SilverLight-Layout: 布局(2)GridSplitter(网格分割)垂直分割.水平分割 A, Splitter(分割)对象之 GridSplitter(网格分割)1: ...

  5. CSS--使用CSS Grid(网格)布局

    .一 CSS Grid(网格布局)简介 CSS Grid 布局由两个核心组成部分是父元素和子元素,父元素 是实际的 grid(网格),子元素是 grid(网格) 内的内容.下面是一个父元素和六个子元素 ...

  6. java 图形化小工具Abstract Window Toolit ;布局管理器FlowLayout流式布局;BorderLayout边界布局;GridLayout网格布局;CardLayou重叠卡片布局;BoxLayout方框布局;绝对定位

    1.FlowLayout流式布局管理器: FlowLayout布局管理器中,组件像水流一样向某方向流动(排列),遇到障碍(边界)就折回,重头开始排列 .在默认情况下,FlowLayout局管理器从左向 ...

  7. [置顶] Android布局管理器 - 详细解析布局实现

    布局管理器都是以ViewGroup为基类派生出来的; 使用布局管理器可以适配不同手机屏幕的分辨率,尺寸大小; 布局管理器之间的继承关系 : 在上面的UML图中可以看出, 绝对布局 帧布局 网格布局 相 ...

  8. 【Android 应用开发】AndroidUI设计之 布局管理器 - 详细解析布局实现

    写完博客的总结 : 以前没有弄清楚的概念清晰化 父容器与本容器属性 : android_layout...属性是本容器的属性, 定义在这个布局管理器的LayoutParams内部类中, 每个布局管理器 ...

  9. AndroidUI设计之 布局管理器 - 详细解析布局实现

    写完博客的总结 : 以前没有弄清楚的概念清晰化 父容器与本容器属性 : android_layout...属性是本容器的属性, 定义在这个布局管理器的LayoutParams内部类中, 每个布局管理器 ...

随机推荐

  1. 一些Titanium学习的地方

    利用titanium兑现外汇兑换计算的ios代码   http://rensanning.iteye.com/blog/1325011 Titanium兑现相关的报表功能   http://www.s ...

  2. StackOverFlow排错翻译 - Python字符串替换: How do I replace everything between two strings without replacing the strings?

    StackOverFlow排错翻译 - Python字符串替换: How do I replace everything between two strings without replacing t ...

  3. 生成freeswitch事件的几种方式

    本文描述了生成freeswitch事件的几种方式,这里记录下,也方便我以后查阅. 操作系统:debian8.5_x64 freeswitch 版本 : 1.6.8 在freeswitch代码中加入事件 ...

  4. Moq基础

    一.概念 Moq是利用诸如Linq表达式树和Lambda表达式等·NET 3.5的特性,为·NET设计和开发的Mocking库.Mock字面意思即模拟,模拟对象的行为已达到欺骗目标(待测试对象)的效果 ...

  5. SQL连接操作符介绍(循环嵌套, 哈希匹配和合并连接)

    今天我将介绍在SQLServer 中的三种连接操作符类型,分别是:循环嵌套.哈希匹配和合并连接.主要对这三种连接的不同.复杂度用范例的形式一一介绍. 本文中使用了示例数据库AdventureWorks ...

  6. crontab 启动 、运行 和编辑 查看

    cron服务是Linux的内置服务,但它不会开机自动启动.可以用以下命令启动和停止服务: /sbin/service crond start /sbin/service crond stop /sbi ...

  7. JAVA UUID 生成

    UUID是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯一的.通常平台会提供生成UUID的API.UUID按照开放软件基金会(OSF)制定的标准计算,用到了以太网卡地址.纳秒级时间.芯 ...

  8. ZBrush中的头部模型该如何进行雕刻

    使用ZBrush®能够快速雕刻人物头部模型,教程只是大概介雕刻前的准备工作和一些软件基础,真正的雕刻还需要学习者具备一定的功底,本文向大家展示头部模型制作流程解析,初学者可以以它做参考拓展自己思路. ...

  9. jquery的bind跟on绑定事件的区别

    jquery的bind跟on绑定事件的区别:主要是事件冒泡: jquery文档中bind和on函数绑定事件的用法: .bind(events [,eventData], handler) .on(ev ...

  10. /var/log/messages

    messages 该日志文件是许多进程日志文件的汇总,从该文件可以看出任何入侵企图或成功的入侵,包括整体系统信息,是系统最核心的日志.它包含了系统启动时的引导消息,以及系统运行时的其他状态消息.IO ...