新增2个pointselectiontool,
clientcommand设为MapCommand,clientinteraction设为ClickInteraction,
command一个设为:AddPinPointCommand,一个设为ClearPinPointCommand,
page_load添加
复制内容到剪贴板
代码:
controlModel.Commands.Add(new AddPinPointCommand());
controlModel.Commands.Add(new ClearPinPointCommand());
MapInfo.Mapping.Map myMap = GetMapObj();
if (myMap != null)
{
if (myMap.Layers[SampleConstants.TempLayerAlias] != null)
{
myMap.Layers.Remove(SampleConstants.TempLayerAlias);
}
}
// Need to clean up "dirty" temp table left by other customer requests.
MapInfo.Engine.Session.Current.Catalog.CloseTable(SampleConstants.TempTableAlias);
// Need to clear the DefautlSelection.
MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear();
// Creat a temp table and AddPintPointCommand will add features into it.
MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable(SampleConstants.TempTableAlias);
// Make the table mappable
ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(myMap.GetDisplayCoordSys()));
ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
// Create a new FeatureLayer based on the temp table, so we can see the temp table on the map.
myMap.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias));
添加一个方法:
复制内容到剪贴板
代码:
private MapInfo.Mapping.Map GetMapObj()
{
// Get the map
MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias];
if (myMap == null)
{
myMap = MapInfo.Engine.Session.Current.MapFactory[0];
}
return myMap;
}
在customizedcommands.cs中添加(取info时新增过这个类,把下面代码加进去)
复制内容到剪贴板
代码:
/// <summary>
/// Summary description for PinPointCommand.
/// </summary>
[Serializable]
public class AddPinPointCommand : MapInfo.WebControls.MapBaseCommand
{
/// <summary>
/// Constructor for this command, sets the name of the command
/// </summary>
/// <remarks>None</remarks>
public AddPinPointCommand()
{
Name = "AddPinPointCommand";
}
/// <summary>
/// This method gets the map object out of the mapfactory with given mapalias and
/// Adds a point feature into a temp layer, exports it to memory stream and streams it back to client.
/// </summary>
/// <remarks>None</remarks>
public override void Process()
{
// Extract points from the string
System.Drawing.Point[] points = this.ExtractPoints(this.DataString);
MapControlModel model = MapControlModel.GetModelFromSession();
model.SetMapSize(MapAlias, MapWidth, MapHeight);
MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
if (map == null) return;
// There will be only one point, convert it to spatial
MapInfo.Geometry.DPoint point;
map.DisplayTransform.FromDisplay(points[0], out point);
IMapLayer lyr = map.Layers[SampleConstants.TempLayerAlias];
if (lyr == null)
{
TableInfoMemTable ti = new TableInfoMemTable(SampleConstants.TempTableAlias);
// Make the table mappable
ti.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(map.GetDisplayCoordSys()));
ti.Columns.Add(ColumnFactory.CreateStyleColumn());
MapInfo .Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
map.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias));
}
lyr = map.Layers[SampleConstants.TempLayerAlias];
if (lyr == null) return;
FeatureLayer fLyr = lyr as FeatureLayer;
MapInfo.Geometry.Point geoPoint = new MapInfo.Geometry.Point(map.GetDisplayCoordSys(), point);
// Create a Point style which is a red pin point.
SimpleVectorPointStyle vs = new SimpleVectorPointStyle();
vs.Code = 67;
vs.Color = Color.Red;
vs.PointSize = Convert.ToInt16(24);
vs.Attributes = StyleAttributes.PointAttributes.BaseAll;
vs.SetApplyAll();
// Create a Feature which contains a Point geometry and insert it into temp table.
Feature pntFeature = new Feature(geoPoint, vs);
MapInfo.Data.Key key = fLyr.Table.InsertFeature(pntFeature);
// Send contents back to client.
MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
StreamImageToClient(ms);
}
}
/// <summary>
/// Summary description for PinPointCommand.
/// </summary>
[Serializable]
public class ClearPinPointCommand : MapInfo.WebControls.MapBaseCommand
{
/// <summary>
/// Constructor for this command, sets the name of the command
/// </summary>
/// <remarks>None</remarks>
public ClearPinPointCommand()
{
Name = "ClearPinPointCommand";
}
/// <summary>
/// This method gets the map object out of the mapfactory with given mapalias
/// and This method delete the pin point features added by AddPinPointCommand in a given point
/// and then streams the image back to client.
/// </summary>
/// <remarks>None</remarks>
public override void Process()
{
System.Drawing.Point[] points = ExtractPoints(DataString);
MapControlModel model = MapControlModel.GetModelFromSession();
model.SetMapSize(MapAlias, MapWidth, MapHeight);
MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
if (map == null) return;
PointDeletion(map, points[0]);
MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
StreamImageToClient(ms);
}
/// <summary>
/// Delete a feature in the temporary layer.
/// </summary>
/// <param name="mapAlias">MapAlias of the map</param>
/// <param name="point">oint in pixels</param>
private void PointDeletion(Map map, System.Drawing.Point point)
{
// Do the search and show selections
SearchInfo si = MapInfo.Mapping.SearchInfoFactory.SearchNearest(map, point, 10);
(si.SearchResultProcessor as ClosestSearchResultProcessor).Options = ClosestSearchOptions.StopAtFirstMatch;
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog[SampleConstants.TempTableAlias];
if (table != null)
{
IResultSetFeatureCollection ifc = Session.Current.Catalog.Search(table, si);
foreach (Feature f in ifc)
{
table.DeleteFeature(f);
}
ifc.Close();
}
}
}
/// <summary>
/// Summary description for SampleConstants.
/// </summary>
public class SampleConstants
{
public static string TempLayerAlias = "inPointLayer";
public static string TempTableAlias = "inPointTable";
private SampleConstants() { }
}
运行会提示找不到:SimpleVectorPointStyle所引用的类,这是引用的mapinfo.styles
再运行会提示找不到:Session,这是引用的mapinfo.engine
clientcommand设为MapCommand,clientinteraction设为ClickInteraction,
command一个设为:AddPinPointCommand,一个设为ClearPinPointCommand,
page_load添加
复制内容到剪贴板
代码:
controlModel.Commands.Add(new AddPinPointCommand());
controlModel.Commands.Add(new ClearPinPointCommand());
MapInfo.Mapping.Map myMap = GetMapObj();
if (myMap != null)
{
if (myMap.Layers[SampleConstants.TempLayerAlias] != null)
{
myMap.Layers.Remove(SampleConstants.TempLayerAlias);
}
}
// Need to clean up "dirty" temp table left by other customer requests.
MapInfo.Engine.Session.Current.Catalog.CloseTable(SampleConstants.TempTableAlias);
// Need to clear the DefautlSelection.
MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear();
// Creat a temp table and AddPintPointCommand will add features into it.
MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable(SampleConstants.TempTableAlias);
// Make the table mappable
ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(myMap.GetDisplayCoordSys()));
ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
// Create a new FeatureLayer based on the temp table, so we can see the temp table on the map.
myMap.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias));
添加一个方法:
复制内容到剪贴板
代码:
private MapInfo.Mapping.Map GetMapObj()
{
// Get the map
MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias];
if (myMap == null)
{
myMap = MapInfo.Engine.Session.Current.MapFactory[0];
}
return myMap;
}
在customizedcommands.cs中添加(取info时新增过这个类,把下面代码加进去)
复制内容到剪贴板
代码:
/// <summary>
/// Summary description for PinPointCommand.
/// </summary>
[Serializable]
public class AddPinPointCommand : MapInfo.WebControls.MapBaseCommand
{
/// <summary>
/// Constructor for this command, sets the name of the command
/// </summary>
/// <remarks>None</remarks>
public AddPinPointCommand()
{
Name = "AddPinPointCommand";
}
/// <summary>
/// This method gets the map object out of the mapfactory with given mapalias and
/// Adds a point feature into a temp layer, exports it to memory stream and streams it back to client.
/// </summary>
/// <remarks>None</remarks>
public override void Process()
{
// Extract points from the string
System.Drawing.Point[] points = this.ExtractPoints(this.DataString);
MapControlModel model = MapControlModel.GetModelFromSession();
model.SetMapSize(MapAlias, MapWidth, MapHeight);
MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
if (map == null) return;
// There will be only one point, convert it to spatial
MapInfo.Geometry.DPoint point;
map.DisplayTransform.FromDisplay(points[0], out point);
IMapLayer lyr = map.Layers[SampleConstants.TempLayerAlias];
if (lyr == null)
{
TableInfoMemTable ti = new TableInfoMemTable(SampleConstants.TempTableAlias);
// Make the table mappable
ti.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(map.GetDisplayCoordSys()));
ti.Columns.Add(ColumnFactory.CreateStyleColumn());
MapInfo .Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
map.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias));
}
lyr = map.Layers[SampleConstants.TempLayerAlias];
if (lyr == null) return;
FeatureLayer fLyr = lyr as FeatureLayer;
MapInfo.Geometry.Point geoPoint = new MapInfo.Geometry.Point(map.GetDisplayCoordSys(), point);
// Create a Point style which is a red pin point.
SimpleVectorPointStyle vs = new SimpleVectorPointStyle();
vs.Code = 67;
vs.Color = Color.Red;
vs.PointSize = Convert.ToInt16(24);
vs.Attributes = StyleAttributes.PointAttributes.BaseAll;
vs.SetApplyAll();
// Create a Feature which contains a Point geometry and insert it into temp table.
Feature pntFeature = new Feature(geoPoint, vs);
MapInfo.Data.Key key = fLyr.Table.InsertFeature(pntFeature);
// Send contents back to client.
MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
StreamImageToClient(ms);
}
}
/// <summary>
/// Summary description for PinPointCommand.
/// </summary>
[Serializable]
public class ClearPinPointCommand : MapInfo.WebControls.MapBaseCommand
{
/// <summary>
/// Constructor for this command, sets the name of the command
/// </summary>
/// <remarks>None</remarks>
public ClearPinPointCommand()
{
Name = "ClearPinPointCommand";
}
/// <summary>
/// This method gets the map object out of the mapfactory with given mapalias
/// and This method delete the pin point features added by AddPinPointCommand in a given point
/// and then streams the image back to client.
/// </summary>
/// <remarks>None</remarks>
public override void Process()
{
System.Drawing.Point[] points = ExtractPoints(DataString);
MapControlModel model = MapControlModel.GetModelFromSession();
model.SetMapSize(MapAlias, MapWidth, MapHeight);
MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
if (map == null) return;
PointDeletion(map, points[0]);
MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
StreamImageToClient(ms);
}
/// <summary>
/// Delete a feature in the temporary layer.
/// </summary>
/// <param name="mapAlias">MapAlias of the map</param>
/// <param name="point">oint in pixels</param>
private void PointDeletion(Map map, System.Drawing.Point point)
{
// Do the search and show selections
SearchInfo si = MapInfo.Mapping.SearchInfoFactory.SearchNearest(map, point, 10);
(si.SearchResultProcessor as ClosestSearchResultProcessor).Options = ClosestSearchOptions.StopAtFirstMatch;
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog[SampleConstants.TempTableAlias];
if (table != null)
{
IResultSetFeatureCollection ifc = Session.Current.Catalog.Search(table, si);
foreach (Feature f in ifc)
{
table.DeleteFeature(f);
}
ifc.Close();
}
}
}
/// <summary>
/// Summary description for SampleConstants.
/// </summary>
public class SampleConstants
{
public static string TempLayerAlias = "inPointLayer";
public static string TempTableAlias = "inPointTable";
private SampleConstants() { }
}
运行会提示找不到:SimpleVectorPointStyle所引用的类,这是引用的mapinfo.styles
再运行会提示找不到:Session,这是引用的mapinfo.engine
发表评论
-
添加数据库中的经纬度信息
2009-03-30 16:22 1794C# Code: 复制内容到剪贴板 代码: MapInfo ... -
MapXtreme 2005自定义图层控制代码(WEB)
2009-03-30 16:21 1589虽然MapXtreme 2005 6.7.1提供了图层控制的控 ... -
MapxTreme测试:绘制图标和文字标注
2009-03-30 16:19 3708代码: using System; using System ... -
mapxtreme 2004 改变feature颜色
2009-03-30 16:18 15981.C# code: 复制内容到剪贴板 代码: MapI ... -
MapxTreme2005地图打印
2009-03-30 16:18 1248MapxTreme2005地图打印 一、语言: c# net2 ... -
在C#应用中如何读取存在ORACLE(或SQL Server)中的MapInfo表
2009-03-30 16:17 1273using MapInfo.Data; ... -
MapXtreme 2005查找图元方法,web的
2009-03-30 16:16 1814先添加一个TextBox和 DropDownList控件 复 ... -
MapXtreme点取地图获得信息
2009-03-30 16:15 1917拖一个pointselectiontool到页面, 修改属性 ... -
MapXtreme查看整个地图的代码
2009-03-30 16:14 960Map map = mapControl1.Map; IMap ... -
MapXtreme 2005 鹰眼源代码
2009-03-30 16:13 1824研究了一段时间的MapXtreme2005 v6.6, 实现了 ... -
实现手动画线
2009-03-30 16:12 1273为了实现在地图上手动画线的功能,煞费了一翻苦心,不过最后实现的 ... -
Web页面中实现鼠标中键缩放
2009-03-30 16:11 1562在MapXtreme 2005中,在Windows应用程序中自 ... -
两种方法实现动态轨迹
2009-03-30 16:11 1404在GIS中,动态轨迹的实现是非常有用的,可用GPS定位,热点跟 ... -
总结查找图元的三种方法
2009-03-30 16:10 1270在MapXtreme 2005中,查找图元提供了非常多的方法, ... -
添加标注图层
2009-03-30 16:08 1205在MapXtreme 2005中添加标注图层是非常容易的,只要 ... -
向图层中添加线段
2009-03-30 16:07 962向图层中添加线段和向图层中添加点是一样的,其本质都是向图层中添 ... -
向图层中添加点
2009-03-30 16:06 1051在添加点之前先要在地图上创建一个临时图层,创建临时图层请参考《 ... -
mapxtreme2005 改变选中的图元样式
2009-03-30 16:05 1096MapInfo.Styles.CompositeStyle c ... -
Mapxtreme2005 两点之间画直线
2009-03-30 16:04 1177private void DrawLine(MapInfo.D ... -
mapxtreme2005 创建各种样式
2009-03-30 16:04 1149public MapInfo.Styles.Composite ...
相关推荐
在`mapxtreme添加标记和删除标记.txt`文件中,可能会详细阐述如何实现这些操作,包括使用的API、示例代码以及注意事项。例如,文件可能包含了如何创建自定义标记图标、如何动态加载数据并根据数据添加标记、如何在...
通过实例代码,用户将学会如何添加标记、绘制图形、实现点击事件处理等功能,进一步提升MapXtreme2008的应用开发能力。 MapXtreme2008的最新特性也是教程的重点之一,例如增强的性能优化、3D地图支持和新的数据分析...
4. 功能实现:利用MapXtreme的JavaScript API,可以实现各种功能,如图层控制(添加、删除、隐藏/显示图层)、标记定位、测量工具、搜索地址、图层叠加等。 5. 用户界面设计:使用HTML和CSS创建美观易用的界面,...
稳压罐sw16_三维3D设计图纸_包括零件图_机械3D图可修改打包下载_三维3D设计图纸_包括零件图_机械3D图可修改打包下载.zip
内容概要:本文详细介绍了利用递推最小二乘法(RLS)进行永磁同步电机参数辨识的方法及其MATLAB仿真过程。首先解释了RLS算法的优势,如不需要概率模型、计算量适中以及适用于嵌入式系统的实时参数更新。接着展示了将电机电压方程转换为标准形式Y=φθ的具体步骤,并提供了核心的RLS迭代代码。文中还讨论了仿真过程中的一些关键技术细节,如遗忘因子的选择、协方差矩阵的初始化和更新方式、电流信号的处理方法等。最终给出了仿真结果,显示电阻和电感的辨识误差分别达到了0.08%和0.12%,并指出了实际应用中需要注意的数据同步和数值稳定性问题。 适合人群:从事电机控制研究的技术人员、研究生及以上学历的学生。 使用场景及目标:①帮助研究人员理解和掌握RLS算法在电机参数辨识中的应用;②提供详细的仿真代码和配置建议,便于快速搭建实验环境;③指导如何优化算法性能,提高参数辨识精度。 其他说明:本文不仅涵盖了理论推导,还包括了大量的实践经验分享和技术细节探讨,有助于读者全面理解RLS算法的实际应用。同时,文中提到的仿真方案可以方便地移植到DSP平台,进一步扩展了其实用价值。
零起点Python大数据与量化交易
管道清污机器人sw16可编辑_三维3D设计图纸_包括零件图_机械3D图可修改打包下载_三维3D设计图纸_包括零件图_机械3D图可修改打包下载.zip
电子仿真教程,从基础到精通,每个压缩包15篇教程,每篇教程5000字以上。
电子仿真教程,从基础到精通,每个压缩包15篇教程,每篇教程5000字以上。
1、文件说明: Centos8操作系统thai-scalable-garuda-fonts-0.6.5-1.el8.rpm以及相关依赖,全打包为一个tar.gz压缩包 2、安装指令: #Step1、解压 tar -zxvf thai-scalable-garuda-fonts-0.6.5-1.el8.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm
内容概要:本文详细介绍了利用ABAQUS进行滑坡和沉降对埋地管道影响的有限元分析方法。主要内容涵盖了几何建模、材料属性定义、接触设置、边界条件与加载等方面的技术细节。通过具体的Python脚本示例展示了如何构建模型,并深入探讨了滑坡和沉降条件下管道的应力、应变分布及其潜在破坏机制。此外,还分享了一些实战经验和优化技巧,如材料模型选择、接触条件设置、边界条件处理等,强调了这些因素对结果准确性的重要影响。 适合人群:从事地下管道工程设计、施工及维护的专业技术人员,尤其是那些希望深入了解滑坡和沉降对管道影响的研究人员和技术专家。 使用场景及目标:适用于评估和预测滑坡和沉降对埋地管道造成的力学响应,帮助工程师们更好地理解和应对复杂的地质灾害环境,从而提高管道系统的安全性与稳定性。 其他说明:文中提供的Python代码片段仅为示意,具体实施时需结合ABAQUS的实际接口和项目需求进行适当调整。同时,对于大规模模型的计算,建议使用高性能计算资源以确保效率和精度。
Java一天面试突击,迅速掌握Java常见面试题
莲子去壳机设计模型SW10_三维3D设计图纸_包括零件图_机械3D图可修改打包下载_三维3D设计图纸_包括零件图_机械3D图可修改打包下载.zip
MFRC-522+RC522+RFID射频+IC卡感应模块
内容概要:《学术研究提示设计 50 招》是一份详尽的指南,旨在帮助研究人员提高学术写作和研究效率。该文档涵盖了从论文撰写、润色、翻译、查重降重、参考文献管理、投稿审稿到文献阅读等多个方面的具体操作指令。每一章节均针对特定任务提供了详细的步骤和注意事项,例如如何撰写标题、摘要、致谢,如何进行英文润色、中英翻译,以及如何优化逻辑结构等。文档还介绍了如何利用AI工具进行文献分析、术语表提取和研究方向探索等内容,为研究者提供了全面的支持。 适合人群:适用于学术研究人员,特别是那些需要撰写、润色和提交学术论文的研究者,包括研究生、博士生及高校教师等。 使用场景及目标:① 提供一系列具体的指令,帮助研究者高效完成论文的各个部分,如撰写标题、摘要、致谢等;② 提供润色和翻译的详细指导,确保论文语言的准确性和专业性;③ 提供查重降重的方法,确保论文的原创性;④ 提供参考文献管理和投稿审稿的指导,帮助研究者顺利发表论文;⑤ 利用AI工具进行文献分析、术语表提取和研究方向探索,提高研究效率。 阅读建议:此资源不仅提供了具体的指令和方法,更重要的是引导研究者如何思考和解决问题。因此,在学习过程中,不仅要关注具体的步骤,还要理解背后的原理和逻辑,结合实际案例进行实践和反思。
项目optionc-20250409
2023年c语言程序设计基本概念考点归纳.doc
电子仿真教程,从基础到精通,每个压缩包15篇教程,每篇教程5000字以上。
内容概要:本文详细介绍了使用Matlab进行模拟和数字滤波器设计的方法,涵盖了巴特沃斯、切比雪夫等多种经典滤波器类型。首先讲解了模拟滤波器的设计,如巴特沃斯滤波器的通带平坦性和切比雪夫滤波器的通带波纹特性,并提供了具体的代码示例。接着讨论了数字滤波器的设计,包括IIR滤波器的递归特性和FIR滤波器的线性相位特性,同样附有详细的代码实现。文中还特别强调了不同类型滤波器之间的转换方法以及设计过程中常见的注意事项,如频率归一化、阶数选择等。最后推荐了一些实用的Matlab工具,如fvtool和FDATool,帮助用户更直观地理解和调试滤波器设计。 适合人群:具有一定信号处理基础和技术背景的研究人员、工程师及学生。 使用场景及目标:适用于需要进行滤波器设计的实际工程应用,如通信系统、音频处理等领域。目标是让读者掌握滤波器设计的基本原理和具体实现方法,能够独立完成滤波器的设计和调试。 其他说明:文章不仅提供了理论知识,还通过大量实例代码帮助读者更好地理解和应用所学内容。建议读者在实践中多尝试不同的参数配置,以加深对滤波器特性的理解。