MapXtreme开发经验分享-实现鹰眼
2012-08-30 21:19
330 查看
由于MapXtreme没有提供鹰眼控件,需要自己来写。实现鹰眼有两个步骤:
1)在地图的视图改变的时候根据地图当前的边距生成一个矩形框,然后把这个矩形框绘制到鹰眼窗口上。
2)根据用户在鹰眼窗口上点击的位置,同步显示地图窗口对应的位置。
VB.NET代码如下:
' 更新鹰眼图
Private Sub UpdateEyeMap()
Try
Dim tblRect As Table
tblRect = Session.Current.Catalog.GetTable("TempRect")
If Not tblRect Is Nothing Then
tblRect.Close()
End If
Dim tblInfo As TableInfo
tblInfo = TableInfoFactory.CreateTemp("TempRect")
Dim tblSessionInfo As TableSessionInfo = New TableSessionInfo()
tblRect = Session.Current.Catalog.CreateTable(tblInfo, tblSessionInfo)
Dim feaLayer As FeatureLayer = New FeatureLayer(tblRect)
MapControl_EagleEye.Map.Layers.Add(feaLayer)
'实时在鹰眼临时表图上画矩形
tblRect = Session.Current.Catalog.GetTable("TempRect")
CType(tblRect, ITableFeatureCollection).Clear()
'设置矩形的样式
Dim rect As MapInfo.Geometry.DRect = MapControl1.Map.Bounds
Dim feageo As FeatureGeometry = New MapInfo.Geometry.Rectangle(MapControl1.Map.GetDisplayCoordSys(), rect)
Dim simLineStyle As SimpleLineStyle = New SimpleLineStyle(New LineWidth(2, MapInfo.Styles.LineWidthUnit.Point), 2, System.Drawing.Color.Red)
Dim simInterior As SimpleInterior = New SimpleInterior(9, System.Drawing.Color.Gray, System.Drawing.Color.Green, True)
Dim comStyle As CompositeStyle = New CompositeStyle(New AreaStyle(simLineStyle, simInterior), Nothing, Nothing, Nothing)
'将矩形插入到图层中
Dim fea As Feature = New Feature(feageo, comStyle)
tblRect.InsertFeature(fea)
'重新定位鹰眼图的中心
MapControl_EagleEye.Map.Center = Map.Center
MapControl_EagleEye.Map.Layers("TempRect").Invalidate()
Catch ex As Exception
MessageBox.Show("鹰眼显示错误:" + ex.Message)
End Try
End Sub
Private Sub Map_ViewChanged(ByVal sender As System.Object, ByVal e As MapInfo.Mapping.ViewChangedEventArgs)
UpdateEyeMap()
End Sub
Private Sub MapControl_EagleEye_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MapControl_EagleEye.Click
Dim DisplayPoint As System.Drawing.PointF = New PointF(CType(e, System.Windows.Forms.MouseEventArgs).X, CType(e, System.Windows.Forms.MouseEventArgs).Y)
Dim MapPoint As New MapInfo.Geometry.DPoint()
Dim converter As MapInfo.Geometry.DisplayTransform = Me.MapControl_EagleEye.Map.DisplayTransform
converter.FromDisplay(DisplayPoint, MapPoint)
Map.Center = MapPoint
End Sub
1)在地图的视图改变的时候根据地图当前的边距生成一个矩形框,然后把这个矩形框绘制到鹰眼窗口上。
2)根据用户在鹰眼窗口上点击的位置,同步显示地图窗口对应的位置。
VB.NET代码如下:
' 更新鹰眼图
Private Sub UpdateEyeMap()
Try
Dim tblRect As Table
tblRect = Session.Current.Catalog.GetTable("TempRect")
If Not tblRect Is Nothing Then
tblRect.Close()
End If
Dim tblInfo As TableInfo
tblInfo = TableInfoFactory.CreateTemp("TempRect")
Dim tblSessionInfo As TableSessionInfo = New TableSessionInfo()
tblRect = Session.Current.Catalog.CreateTable(tblInfo, tblSessionInfo)
Dim feaLayer As FeatureLayer = New FeatureLayer(tblRect)
MapControl_EagleEye.Map.Layers.Add(feaLayer)
'实时在鹰眼临时表图上画矩形
tblRect = Session.Current.Catalog.GetTable("TempRect")
CType(tblRect, ITableFeatureCollection).Clear()
'设置矩形的样式
Dim rect As MapInfo.Geometry.DRect = MapControl1.Map.Bounds
Dim feageo As FeatureGeometry = New MapInfo.Geometry.Rectangle(MapControl1.Map.GetDisplayCoordSys(), rect)
Dim simLineStyle As SimpleLineStyle = New SimpleLineStyle(New LineWidth(2, MapInfo.Styles.LineWidthUnit.Point), 2, System.Drawing.Color.Red)
Dim simInterior As SimpleInterior = New SimpleInterior(9, System.Drawing.Color.Gray, System.Drawing.Color.Green, True)
Dim comStyle As CompositeStyle = New CompositeStyle(New AreaStyle(simLineStyle, simInterior), Nothing, Nothing, Nothing)
'将矩形插入到图层中
Dim fea As Feature = New Feature(feageo, comStyle)
tblRect.InsertFeature(fea)
'重新定位鹰眼图的中心
MapControl_EagleEye.Map.Center = Map.Center
MapControl_EagleEye.Map.Layers("TempRect").Invalidate()
Catch ex As Exception
MessageBox.Show("鹰眼显示错误:" + ex.Message)
End Try
End Sub
Private Sub Map_ViewChanged(ByVal sender As System.Object, ByVal e As MapInfo.Mapping.ViewChangedEventArgs)
UpdateEyeMap()
End Sub
Private Sub MapControl_EagleEye_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MapControl_EagleEye.Click
Dim DisplayPoint As System.Drawing.PointF = New PointF(CType(e, System.Windows.Forms.MouseEventArgs).X, CType(e, System.Windows.Forms.MouseEventArgs).Y)
Dim MapPoint As New MapInfo.Geometry.DPoint()
Dim converter As MapInfo.Geometry.DisplayTransform = Me.MapControl_EagleEye.Map.DisplayTransform
converter.FromDisplay(DisplayPoint, MapPoint)
Map.Center = MapPoint
End Sub
相关文章推荐
- MapXtreme开发经验分享-实现鹰眼
- MapXtreme开发经验分享-如何生成tab表,查询时返回全部
- MapXtreme开发经验分享-如何生成tab表,查询时返回全部字段【转】
- MapXtreme开发经验分享——添加自定义工具【转】
- MapXtreme开发经验分享-如何生成tab表,查询时返回全部
- arcims开发经验总结(2) (地图放大缩小、鹰眼实现逻辑)
- arcims开发经验总结(2) (地图放大缩小、鹰眼实现逻辑)
- arcims开发经验总结(2) (地图放大缩小、鹰眼实现逻辑)
- arcims开发经验总结(2) (地图放大缩小、鹰眼实现逻辑)
- C#.NET 大型企业信息化系统集成快速开发平台 4.2 版本 - 几十套业务系统集中统一授权管理实现经验分享
- arcims开发经验总结(2) (地图放大缩小、鹰眼实现逻辑)
- Google+开发团队分享经验
- jira二次开发经验分享
- 分享8年开发经验,浅谈个人发展经历,明确自己发展方向
- Dubbo学习过程、使用经验分享及实现原理简单介绍
- Android开发之电话短信拍照分享功能实现
- 与你分享我在开发项目管理中的一些经验 之测试管理 推荐
- 十八年开发经验分享(三)问题解决篇(中)
- 【Android开发经验】使用反射,得到的类的字段、方法、并实现了简单的调用
- 分享一些Comet开发经验