新增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 1780C# Code: 复制内容到剪贴板 代码: MapInfo ... -
MapXtreme 2005自定义图层控制代码(WEB)
2009-03-30 16:21 1582虽然MapXtreme 2005 6.7.1提供了图层控制的控 ... -
MapxTreme测试:绘制图标和文字标注
2009-03-30 16:19 3700代码: using System; using System ... -
mapxtreme 2004 改变feature颜色
2009-03-30 16:18 15851.C# code: 复制内容到剪贴板 代码: MapI ... -
MapxTreme2005地图打印
2009-03-30 16:18 1226MapxTreme2005地图打印 一、语言: c# net2 ... -
在C#应用中如何读取存在ORACLE(或SQL Server)中的MapInfo表
2009-03-30 16:17 1244using MapInfo.Data; ... -
MapXtreme 2005查找图元方法,web的
2009-03-30 16:16 1795先添加一个TextBox和 DropDownList控件 复 ... -
MapXtreme点取地图获得信息
2009-03-30 16:15 1896拖一个pointselectiontool到页面, 修改属性 ... -
MapXtreme查看整个地图的代码
2009-03-30 16:14 937Map map = mapControl1.Map; IMap ... -
MapXtreme 2005 鹰眼源代码
2009-03-30 16:13 1800研究了一段时间的MapXtreme2005 v6.6, 实现了 ... -
实现手动画线
2009-03-30 16:12 1247为了实现在地图上手动画线的功能,煞费了一翻苦心,不过最后实现的 ... -
Web页面中实现鼠标中键缩放
2009-03-30 16:11 1543在MapXtreme 2005中,在Windows应用程序中自 ... -
两种方法实现动态轨迹
2009-03-30 16:11 1387在GIS中,动态轨迹的实现是非常有用的,可用GPS定位,热点跟 ... -
总结查找图元的三种方法
2009-03-30 16:10 1259在MapXtreme 2005中,查找图元提供了非常多的方法, ... -
添加标注图层
2009-03-30 16:08 1182在MapXtreme 2005中添加标注图层是非常容易的,只要 ... -
向图层中添加线段
2009-03-30 16:07 945向图层中添加线段和向图层中添加点是一样的,其本质都是向图层中添 ... -
向图层中添加点
2009-03-30 16:06 1038在添加点之前先要在地图上创建一个临时图层,创建临时图层请参考《 ... -
mapxtreme2005 改变选中的图元样式
2009-03-30 16:05 1090MapInfo.Styles.CompositeStyle c ... -
Mapxtreme2005 两点之间画直线
2009-03-30 16:04 1155private void DrawLine(MapInfo.D ... -
mapxtreme2005 创建各种样式
2009-03-30 16:04 1138public MapInfo.Styles.Composite ...
相关推荐
在`mapxtreme添加标记和删除标记.txt`文件中,可能会详细阐述如何实现这些操作,包括使用的API、示例代码以及注意事项。例如,文件可能包含了如何创建自定义标记图标、如何动态加载数据并根据数据添加标记、如何在...
此外,图层管理功能允许用户动态添加、删除和控制地图数据的可见性,以满足不同场景的需求。 该教程还涵盖了数据导入与处理,MapXtreme2008支持多种数据格式,如Shapefile、GeoTIFF和GML等。用户可以学习如何将这些...
2. **地图操作**:你可以添加、删除、移动、缩放地图,改变地图的显示样式,如颜色、透明度等。同时,还可以实现地图的平移、缩放、旋转等交互操作。 3. **图层管理**:图层是地图的基本组成部分,可以包含不同类型...
MapXtreme提供了PointFeature、LineFeature和PolygonFeature类来表示几何对象。通过实例化这些类,你可以创建自定义的标记或形状,并将它们添加到地图上。同时,还可以为每个特征分配属性,以便进行数据绑定和交互...
1. **地图对象模型**:MapXtreme基于一个复杂的地图对象模型,包括地图、图层、图例、标注、地理编码等多个元素。这些对象之间相互作用,构建出动态且功能丰富的地图界面。 2. **数据源与图层**:MapXtreme支持多种...
5. **图形与标注**:MapXtreme允许在地图上绘制自定义图形和标注,这对于地图注解和解释非常有用。示例可能会展示如何创建和编辑这些元素。 6. **投影与坐标系统**:地图的投影选择和转换是GIS的重要组成部分。学习...
5. **跨平台支持**:MapXtreme不仅适用于桌面环境,还能在Web和移动设备上运行,兼容多种操作系统和浏览器。 三、MapXtreme的使用步骤 1. **安装MapXtreme**:首先,需要下载并安装MapXtreme的SDK和相应的开发环境...
MapXtreme是一款强大的地图开发工具,主要用于构建和管理地理信息系统(GIS)应用程序。MapXtreme 2004是其2004年的版本,该版本在介绍中涉及了多个关键知识点,包括地图概览、地图和图层管理、数据管理、数据查询、...
在MapXtreme中,我们可以利用其丰富的API和功能来创建自定义的专题图,以突出显示特定区域的特征或趋势。 1. **理解专题图的基本概念**:专题图的核心是将地理数据与特定的属性值关联,这些属性值决定着地图上每个...
在MapXtreme中,可以通过创建Point对象并设置其坐标来创建点图元,然后将其添加到地图视图上。此外,可以自定义点图元的样式,如形状、颜色和大小。 - **线图元**:线图元用于表示路径或连接,如道路、航线等。...
2. 交互式地图操作:缩放、平移、旋转,以及添加图层、图例、标记等元素。 3. 空间查询与分析:执行距离计算、缓冲区分析、叠加分析等空间操作。 4. 地理编码:将地址转换为坐标,便于在地图上定位。 5. 路线规划:...
5. **图层管理**:学习如何添加、删除、隐藏和显示地图层,以及如何控制图层的显示顺序和透明度。 6. **数据源处理**:理解MapXtreme API支持的数据格式,如Shapefile、GeoJSON、WMS等,以及如何加载和操作这些数据...
MapXtreme的示例程序通常包含了一系列用于演示其核心功能和特性的代码片段和应用程序。这些示例可以帮助开发者快速理解和学习如何使用MapXtreme API来创建自己的GIS应用。在“mapxtreme sample”这个压缩包中,虽然...
C#和MapXtreme是构建WebGIS应用的两种关键技术。C#是一种面向对象的编程语言,被广泛用于开发Windows应用程序、Web服务以及.NET框架下的各种应用。MapXtreme则是杰仕登软件公司(GeoServer Solutions)推出的一款...
3. **图层管理**:开发者可以通过C#代码动态添加、删除、管理和组织地图图层,包括矢量图层(点、线、面)、栅格图层(如卫星影像或地形图)和标注图层。 4. **对象交互**:MapXtreme允许用户与地图上的对象进行...
MapXtreme 6.7 是一款由杰克丹尼尔斯公司(Jack Daniel's & Company)开发的专业地理信息系统(GIS)软件,它主要用于构建地图应用和地理位置服务。这个.NET帮助文档是针对MapXtreme 6.7版本的开发者指南,提供了...
在.NET Framework 2008环境下,我们可以利用C#语言和MapXtreme的功能来实现地图的加载以及在图层上画线的操作。本文将详细讲解如何在MapXtreme图层上绘制线段,涉及的主要知识点包括地图对象的初始化、图层的管理、...
3. **客户端交互功能**:可能包含了地图的点击事件处理、图层控制、标记添加等功能,展示了MapXtreme 客户端API的使用。 4. **数据的读取与显示**:可能从SQL Server 2000中检索地理数据,并在地图上呈现,展示了...