用法:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Overview oc = new Overview(MapControl1,MapControl2);
if(!IsPostBack)
{
}
}
/*作者:xiexiaokui
* 时间:2005-10-18
* 功能:asp.net鹰眼
*/
using System;
using MapInfo.Web.UI.WebControls;
using MapInfo.Geometry;
using MapInfo.Styles;
using System.Drawing;
using MapInfo.Data;
////
/// OverviewTool 的摘要说明。
///
public class OverviewMapToolEventArgs:System.EventArgs
{
System.Drawing.Point[] m_points;
public OverviewMapToolEventArgs(System.Drawing.Point[] points)
{
this.m_points = points;
}
public System.Drawing.Point[] Points
{
get
{
return m_points;
}
set
{
m_points = value;
}
}
}
public delegate void OverviewMapToolEventHandler(object sender,OverviewMapToolEventArgs e);
public class OverviewMapTool:MapTool
{
public static readonly string Toolname = "MapInfoWebOverview";
// public DPoint Point1,Point2;
string m_clientCodeSource;
string m_clientStartMethod;
string m_clientStopMethod;
string m_cursorUrl;
string m_name;
public event OverviewMapToolEventHandler OverviewMapToolStop;
protected void OnOverviewMapToolStop(OverviewMapToolEventArgs e)
{
if(this.OverviewMapToolStop != null)
this.OverviewMapToolStop(this,e);
}
public OverviewMapTool()
{
this.ClientStartMethod = "MapInfoWebRectangleStart";
this.ClientStopMethod = "MapInfoWebRectangleStop";
this.Name = Toolname;
}
public override string ClientCodeSource
{
get
{
return m_clientCodeSource;
}
set
{
m_clientCodeSource = value;
}
}
public override string ClientStartMethod
{
get
{
return m_clientStartMethod;
}
set
{
m_clientStartMethod = value;
}
}
public override string ClientStopMethod
{
get
{
return m_clientStopMethod;
}
set
{
m_clientStopMethod = value;
}
}
public override string CursorUrl
{
get
{
return m_cursorUrl;
}
set
{
m_cursorUrl = value;
}
}
public override string Name
{
get
{
return m_name;
}
set
{
m_name = value;
}
}
public override void Execute(string dataString, System.Collections.ArrayList selLayers, MapInfo.Mapping.Map map)
{
// DPoint dp1,dp2;
System.Drawing.Point[] points = base.ExtractPoints(dataString);
// map.DisplayTransform.FromDisplay(points[0],out dp1);
// map.DisplayTransform.FromDisplay(points[1],out dp2);
this.OnOverviewMapToolStop(new OverviewMapToolEventArgs(points));
// OverviewMapTool omt = (OverviewMapTool)this.MapControl2.MapTools[MapControl2.MapTools.Count-1];
// MapInfo.Geometry.DPoint dp1 = omt.Point1;
// MapInfo.Geometry.DPoint dp2 = omt.Point2;
// System.Drawing.Point p1,p2;
// MapControl2.Map.DisplayTransform.ToDisplay(dp1,out p1);
// MapControl2.Map.DisplayTransform.ToDisplay(dp2,out p2);
// if(Math.Min(Math.Abs(points[0].X-points[1].X),Math.Abs(points[0].Y-points[1].Y))<5)
// {
// m_mainMapControl.Map.Center = dp1;
// }
// else
// {
// MapInfo.Geometry.DRect rect = new DRect(dp1,dp2);
// m_mainMapControl.Map.SetView(rect,m_mainMapControl.Map.GetDisplayCoordSys());
// }
}
}
class Overview
{
MapInfo.Web.UI.WebControls.MapControl m_mainMapControl;
MapInfo.Web.UI.WebControls.MapControl m_overviewMapControl;
public Overview(MapInfo.Web.UI.WebControls.MapControl mainMapControl,MapInfo.Web.UI.WebControls.MapControl overviewMapControl)
{
MainMapControl = mainMapControl;
OverviewMapControl = overviewMapControl;
}
public MapInfo.Web.UI.WebControls.MapControl MainMapControl
{
get
{
return m_mainMapControl;
}
set
{
m_mainMapControl = value;
m_mainMapControl.PreRender += new EventHandler(MainMapControl_PreRender);
}
}
public MapInfo.Web.UI.WebControls.MapControl OverviewMapControl
{
get
{
return m_overviewMapControl;
}
set
{
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable("temp_overview");
m_overviewMapControl = value;
OverviewMapTool omt = new OverviewMapTool();
omt.OverviewMapToolStop += new OverviewMapToolEventHandler(omt_OverviewMapToolStop);
this.m_overviewMapControl.MapTools.Add(omt);
this.m_overviewMapControl.MapTools.CurrentTool = omt.Name;
if(table == null)
{
this.m_overviewMapControl.Map.Load(new MapInfo.Mapping.MapTableLoader(m_mainMapControl.Map.Layers.GetTableEnumerator()));
MapInfo.Data.TableInfo ti = MapInfo.Data.TableInfoFactory.CreateTemp("temp_overview");
MapInfo.Data.TableSessionInfo tsi = new MapInfo.Data.TableSessionInfo();
table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
MapInfo.Mapping.FeatureLayer fl = new MapInfo.Mapping.FeatureLayer(table);
m_overviewMapControl.Map.Layers.Insert(0,fl);
}
}
}
protected void MainMapControl_PreRender(object sender, EventArgs e)
{
DRect dr = this.m_mainMapControl.Map.Bounds;
FeatureGeometry fg = new MapInfo.Geometry.Rectangle(m_mainMapControl.Map.GetDisplayCoordSys(),dr);
MapInfo.Styles.SimpleLineStyle sls = new MapInfo.Styles.SimpleLineStyle(new LineWidth(2,LineWidthUnit.Pixel),2,Color.Red);
MapInfo.Styles.SimpleInterior si = new MapInfo.Styles.SimpleInterior(1);
MapInfo.Styles.AreaStyle arst = new MapInfo.Styles.AreaStyle(sls,si);
// MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(arst,null,null,null);
MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(arst);
MapInfo.Data.Feature f = new Feature(fg,arst);
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable("temp_overview");
(table as ITableFeatureCollection).Clear();
table.InsertFeature(f);
m_overviewMapControl.Map.Layers["temp_overview"].Invalidate();
//table.Refresh();
}
private void omt_OverviewMapToolStop(object sender, OverviewMapToolEventArgs e)
{
DPoint dp1,dp2;
System.Drawing.Point[] points = e.Points;
m_overviewMapControl.Map.DisplayTransform.FromDisplay(points[0],out dp1);
m_overviewMapControl.Map.DisplayTransform.FromDisplay(points[1],out dp2);
// OverviewMapTool omt = (OverviewMapTool)this.MapControl2.MapTools[MapControl2.MapTools.Count-1];
// MapInfo.Geometry.DPoint dp1 = omt.Point1;
// MapInfo.Geometry.DPoint dp2 = omt.Point2;
// System.Drawing.Point p1,p2;
// MapControl2.Map.DisplayTransform.ToDisplay(dp1,out p1);
// MapControl2.Map.DisplayTransform.ToDisplay(dp2,out p2);
if(Math.Min(Math.Abs(points[0].X-points[1].X),Math.Abs(points[0].Y-points[1].Y))<5)
{
m_mainMapControl.Map.Center = dp1;
}
else
{
MapInfo.Geometry.DRect rect = new DRect(dp1,dp2);
m_mainMapControl.Map.SetView(rect,m_mainMapControl.Map.GetDisplayCoordSys());
}
}
}
用法:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Overview oc = new Overview(MapControl1,MapControl2);
if(!IsPostBack)
{
}
}
/*作者:xiexiaokui
* 时间:2005-10-18
* 功能:asp.net鹰眼
*/
using System;
using MapInfo.Web.UI.WebControls;
using MapInfo.Geometry;
using MapInfo.Styles;
using System.Drawing;
using MapInfo.Data;
////
/// OverviewTool 的摘要说明。
///
public class OverviewMapToolEventArgs:System.EventArgs
{
System.Drawing.Point[] m_points;
public OverviewMapToolEventArgs(System.Drawing.Point[] points)
{
this.m_points = points;
}
public System.Drawing.Point[] Points
{
get
{
return m_points;
}
set
{
m_points = value;
}
}
}
public delegate void OverviewMapToolEventHandler(object sender,OverviewMapToolEventArgs e);
public class OverviewMapTool:MapTool
{
public static readonly string Toolname = "MapInfoWebOverview";
// public DPoint Point1,Point2;
string m_clientCodeSource;
string m_clientStartMethod;
string m_clientStopMethod;
string m_cursorUrl;
string m_name;
public event OverviewMapToolEventHandler OverviewMapToolStop;
protected void OnOverviewMapToolStop(OverviewMapToolEventArgs e)
{
if(this.OverviewMapToolStop != null)
this.OverviewMapToolStop(this,e);
}
public OverviewMapTool()
{
this.ClientStartMethod = "MapInfoWebRectangleStart";
this.ClientStopMethod = "MapInfoWebRectangleStop";
this.Name = Toolname;
}
public override string ClientCodeSource
{
get
{
return m_clientCodeSource;
}
set
{
m_clientCodeSource = value;
}
}
public override string ClientStartMethod
{
get
{
return m_clientStartMethod;
}
set
{
m_clientStartMethod = value;
}
}
public override string ClientStopMethod
{
get
{
return m_clientStopMethod;
}
set
{
m_clientStopMethod = value;
}
}
public override string CursorUrl
{
get
{
return m_cursorUrl;
}
set
{
m_cursorUrl = value;
}
}
public override string Name
{
get
{
return m_name;
}
set
{
m_name = value;
}
}
public override void Execute(string dataString, System.Collections.ArrayList selLayers, MapInfo.Mapping.Map map)
{
// DPoint dp1,dp2;
System.Drawing.Point[] points = base.ExtractPoints(dataString);
// map.DisplayTransform.FromDisplay(points[0],out dp1);
// map.DisplayTransform.FromDisplay(points[1],out dp2);
this.OnOverviewMapToolStop(new OverviewMapToolEventArgs(points));
// OverviewMapTool omt = (OverviewMapTool)this.MapControl2.MapTools[MapControl2.MapTools.Count-1];
// MapInfo.Geometry.DPoint dp1 = omt.Point1;
// MapInfo.Geometry.DPoint dp2 = omt.Point2;
// System.Drawing.Point p1,p2;
// MapControl2.Map.DisplayTransform.ToDisplay(dp1,out p1);
// MapControl2.Map.DisplayTransform.ToDisplay(dp2,out p2);
// if(Math.Min(Math.Abs(points[0].X-points[1].X),Math.Abs(points[0].Y-points[1].Y))<5)
// {
// m_mainMapControl.Map.Center = dp1;
// }
// else
// {
// MapInfo.Geometry.DRect rect = new DRect(dp1,dp2);
// m_mainMapControl.Map.SetView(rect,m_mainMapControl.Map.GetDisplayCoordSys());
// }
}
}
class Overview
{
MapInfo.Web.UI.WebControls.MapControl m_mainMapControl;
MapInfo.Web.UI.WebControls.MapControl m_overviewMapControl;
public Overview(MapInfo.Web.UI.WebControls.MapControl mainMapControl,MapInfo.Web.UI.WebControls.MapControl overviewMapControl)
{
MainMapControl = mainMapControl;
OverviewMapControl = overviewMapControl;
}
public MapInfo.Web.UI.WebControls.MapControl MainMapControl
{
get
{
return m_mainMapControl;
}
set
{
m_mainMapControl = value;
m_mainMapControl.PreRender += new EventHandler(MainMapControl_PreRender);
}
}
public MapInfo.Web.UI.WebControls.MapControl OverviewMapControl
{
get
{
return m_overviewMapControl;
}
set
{
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable("temp_overview");
m_overviewMapControl = value;
OverviewMapTool omt = new OverviewMapTool();
omt.OverviewMapToolStop += new OverviewMapToolEventHandler(omt_OverviewMapToolStop);
this.m_overviewMapControl.MapTools.Add(omt);
this.m_overviewMapControl.MapTools.CurrentTool = omt.Name;
if(table == null)
{
this.m_overviewMapControl.Map.Load(new MapInfo.Mapping.MapTableLoader(m_mainMapControl.Map.Layers.GetTableEnumerator()));
MapInfo.Data.TableInfo ti = MapInfo.Data.TableInfoFactory.CreateTemp("temp_overview");
MapInfo.Data.TableSessionInfo tsi = new MapInfo.Data.TableSessionInfo();
table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
MapInfo.Mapping.FeatureLayer fl = new MapInfo.Mapping.FeatureLayer(table);
m_overviewMapControl.Map.Layers.Insert(0,fl);
}
}
}
protected void MainMapControl_PreRender(object sender, EventArgs e)
{
DRect dr = this.m_mainMapControl.Map.Bounds;
FeatureGeometry fg = new MapInfo.Geometry.Rectangle(m_mainMapControl.Map.GetDisplayCoordSys(),dr);
MapInfo.Styles.SimpleLineStyle sls = new MapInfo.Styles.SimpleLineStyle(new LineWidth(2,LineWidthUnit.Pixel),2,Color.Red);
MapInfo.Styles.SimpleInterior si = new MapInfo.Styles.SimpleInterior(1);
MapInfo.Styles.AreaStyle arst = new MapInfo.Styles.AreaStyle(sls,si);
// MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(arst,null,null,null);
MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(arst);
MapInfo.Data.Feature f = new Feature(fg,arst);
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable("temp_overview");
(table as ITableFeatureCollection).Clear();
table.InsertFeature(f);
m_overviewMapControl.Map.Layers["temp_overview"].Invalidate();
//table.Refresh();
}
private void omt_OverviewMapToolStop(object sender, OverviewMapToolEventArgs e)
{
DPoint dp1,dp2;
System.Drawing.Point[] points = e.Points;
m_overviewMapControl.Map.DisplayTransform.FromDisplay(points[0],out dp1);
m_overviewMapControl.Map.DisplayTransform.FromDisplay(points[1],out dp2);
// OverviewMapTool omt = (OverviewMapTool)this.MapControl2.MapTools[MapControl2.MapTools.Count-1];
// MapInfo.Geometry.DPoint dp1 = omt.Point1;
// MapInfo.Geometry.DPoint dp2 = omt.Point2;
// System.Drawing.Point p1,p2;
// MapControl2.Map.DisplayTransform.ToDisplay(dp1,out p1);
// MapControl2.Map.DisplayTransform.ToDisplay(dp2,out p2);
if(Math.Min(Math.Abs(points[0].X-points[1].X),Math.Abs(points[0].Y-points[1].Y))<5)
{
m_mainMapControl.Map.Center = dp1;
}
else
{
MapInfo.Geometry.DRect rect = new DRect(dp1,dp2);
m_mainMapControl.Map.SetView(rect,m_mainMapControl.Map.GetDisplayCoordSys());
}
}
}