代码:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MapInfo.Mapping;
using MapInfo.WebControls;
using ApplicationStateManager;
using MapInfo.Data;
public partial class _Default : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
ViewEntireMap();
// If the StateManager doesn't exist in the session put it else get it.
if (StateManager.GetStateManagerFromSession() == null)
StateManager.PutStateManagerInSession(new AppStateManager());
// Now Restore State
StateManager.GetStateManagerFromSession().ParamsDictionary[StateManager.ActiveMapAliasKey] = MapControl1.MapAlias;
StateManager.GetStateManagerFromSession().RestoreState();
}
// At the time of unloading the page, save the state
private void Page_UnLoad(object sender, System.EventArgs e)
{
StateManager.GetStateManagerFromSession().SaveState();
}
protected void ButtonViewEntire_Click(object sender, EventArgs e)
{
ViewEntireMap();
}
private void ViewEntireMap()
{
//try {
Map myMap = GetMapObj();
myMap.Clear();
MapInfo.Mapping.MapGeosetLoader gl = new MapGeosetLoader(Server.MapPath("App_Data\\海洋测试.gst"));
myMap.Load(gl);
double x = 111.0;
double y = 22.0;
myMap.Center = new MapInfo.Geometry.DPoint(x,y);
mpxDrawImg(myMap,x,y,"truckImg");
// mpxDrawText(myMap, "truckText", "A13431");
mpxDrawText(myMap, x, y, "truckText", "桂A99999");
//}
//catch (Exception e) {
//}
}
private MapInfo.Mapping.Map GetMapObj()
{
MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias];
if (myMap == null)
{
myMap = MapInfo.Engine.Session.Current.MapFactory[0];
}
return myMap;
}
/// <summary>
/// 创建mapx表
/// </summary>
/// <param name="pMap">地图</param>
/// <param name="pTabName"></param>
/// <param name="pColumnName"></param>
/// <returns></returns>
private MapInfo.Data.Table mpxMkTable(MapInfo.Geometry.CoordSys pCoordSys, string pTabName,string pColumnName){
MapInfo.Data.Catalog Cat = MapInfo.Engine.Session.Current.Catalog;
MapInfo.Data.Table tblTemp = Cat.GetTable(pTabName);
if (tblTemp != null) Cat.CloseTable(pTabName);
MapInfo.Data.TableInfoMemTable imt = new MapInfo.Data.TableInfoMemTable(pTabName);
imt.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(pCoordSys));
imt.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());
imt.Columns.Add(MapInfo.Data.ColumnFactory.CreateStringColumn(pColumnName, 40));
return Cat.CreateTable(imt);
}
/// <summary>
/// 往表里增加一行
/// </summary>
/// <param name="pTable">表名</param>
/// <param name="pGeometry">坐标</param>
/// <param name="pStyle">样式</param>
/// <param name="pColumnName">列名</param>
/// <param name="pColumnValue">列值</param>
private void mpxTableAddRow(MapInfo.Data.Table pTable,MapInfo.Geometry.FeatureGeometry pGeometry,MapInfo.Styles.Style pStyle,string pColumnName,string pColumnValue) {
Feature ftr = new Feature(pTable.TableInfo.Columns);
ftr.Geometry = pGeometry;
ftr.Style = pStyle;
ftr[pColumnName] = pColumnValue;
pTable.InsertFeature(ftr);
}
/// <summary>
/// 创建文本样式
/// </summary>
/// <param name="pColor">文本颜色</param>
/// <param name="pSize">字体大小</param>
/// <param name="pFontName">字体名称</param>
/// <returns></returns>
private MapInfo.Styles.TextStyle mpxMkTextStyle(System.Drawing.Color pColor, double pSize, string pFontName) {
MapInfo.Styles.TextStyle ts = new MapInfo.Styles.TextStyle();
ts.Font.ForeColor = pColor;
ts.Font.Size = pSize;
ts.Font.Name = pFontName;
ts.ApplyStyle(ts);
return ts;
}
/// <summary>
/// 创建文本样式
/// </summary>
/// <param name="pSize">字体大小</param>
/// <param name="pFontName">字体名称</param>
/// <returns></returns>
private MapInfo.Styles.TextStyle mpxMkTextStyle(double pSize, string pFontName) {
MapInfo.Styles.TextStyle ts = new MapInfo.Styles.TextStyle();
ts.Font.ForeColor = System.Drawing.Color.Black;
ts.Font.Size = pSize;
ts.Font.FontWeight = MapInfo.Styles.FontWeight.Bold;
ts.Font.Name = pFontName;
return ts;
}
/// <summary>
/// 创建图层点坐标
/// </summary>
/// <param name="pSys"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
private MapInfo.Geometry.FeatureGeometry mpxMkFeaturePoint(MapInfo.Geometry.CoordSys pSys,double x,double y) {
MapInfo.Geometry.Point pt = new MapInfo.Geometry.Point(pSys, x, y);
MapInfo.Geometry.FeatureGeometry geo = pt as MapInfo.Geometry.FeatureGeometry;
return geo;
}
/// <summary>
/// 绘制文本
/// </summary>
/// <param name="pSys">坐标系统,如:myMap.GetDisplayCoordSys()</param>
/// <param name="x">经度</param>
/// <param name="y">纬度</param>
/// <param name="pTabName">用于创建图层的表名</param>
/// <param name="pText">要绘制的文本</param>
private void mpxDrawText(MapInfo.Mapping.Map pMap,double x,double y,string pTabName,string pText) {
//MapInfo.Styles.TextStyle sty2 = new MapInfo.Styles.TextStyle();
//sty2.Font.ForeColor = System.Drawing.Color.Red;
//sty2.Font.TextEffect = MapInfo.Styles.TextEffect.Halo;
//MapInfo.Geometry.DRect rt = new MapInfo.Geometry.DRect(x, y, x + 30, y + 12);
//MapInfo.Geometry.LegacyText lt =
// new MapInfo.Geometry.LegacyText(pMap.GetDisplayCoordSys(), rt, pText);
//MapInfo.Data.Feature ft = new MapInfo.Data.Feature(lt, sty2);
//MapInfo.Data.Table dt = mpxMkTable(pMap.GetDisplayCoordSys(), pTabName, "name");
//dt.InsertFeature(ft);
//LabelSource source = new LabelSource(dt); //创建数据源
//source.DefaultLabelProperties.Caption = "name";
//LabelLayer lyr = new LabelLayer(); //创建图层
//lyr.Sources.Append(source);
//pMap.Layers.Add(lyr);
// DRect drect = new DRect(ftr.Geometry.Centroid.x + 2, ftr.Geometry.Centroid.y, ftr.Geometry.Centroid.x + 30, ftr.Geometry.Centroid.y + 12);
string sColumnName = "name"; //创建表
MapInfo.Data.Table dt = mpxMkTable(pMap.GetDisplayCoordSys(), pTabName, sColumnName);
MapInfo.Styles.TextStyle ts = mpxMkTextStyle(System.Drawing.Color.Blue, 8.0, "宋体");
MapInfo.Geometry.FeatureGeometry pt = mpxMkFeaturePoint(pMap.GetDisplayCoordSys(), x, y);
mpxTableAddRow(dt, pt, ts, sColumnName, pText); //往表里增加记录
LabelSource source = new LabelSource(dt); //创建数据源
source.DefaultLabelProperties.Caption = "name";
source.DefaultLabelProperties.Style.Font.ForeColor = System.Drawing.Color.Blue;
source.DefaultLabelProperties.Layout.Offset = 23;
LabelLayer lyr = new LabelLayer(); //创建图层
lyr.Sources.Append(source);
pMap.Layers.Add(lyr); //将图层加到地图
////创建表
//MapInfo.Data.Table mpxTable = mkMapxTable(pMap, layerName);
////创建文字样式
//MapInfo.Styles.TextStyle ts=new MapInfo.Styles.TextStyle();
//ts.Font.ForeColor = System.Drawing.Color.Black;
//ts.Font.Size = 9;
//ts.Font.Name = "宋体";
////创建标源
//LabelSource ls = new LabelSource(mpxTable);
//ls.DefaultLabelProperties.Caption = pText;
//ls.DefaultLabelProperties.Style = ts;
////创建标注层
//LabelLayer lly = new LabelLayer();//pText);
//lly.Sources.Append(ls);
//try {
// pMap.Layers.Add(lly);
//}
//catch (Exception e) {
//}
}
private void mpxDrawImg(MapInfo.Mapping.Map pMap, double x, double y, string pTabName) {
string sColName = "name";
MapInfo.Data.Table dt = mpxMkTable(pMap.GetDisplayCoordSys(), pTabName, sColName); //创建表
MapInfo.Geometry.FeatureGeometry pt = mpxMkFeaturePoint(pMap.GetDisplayCoordSys(), x, y); //创建点和样式
MapInfo.Styles.BitmapPointStyle cs =
new MapInfo.Styles.BitmapPointStyle("v13.BMP", MapInfo.Styles.BitmapStyles.None, System.Drawing.Color.White, 24);
mpxTableAddRow(dt, pt, cs, "name", "truck"); //往表增加记录
FeatureLayer lyr = new FeatureLayer(dt);
pMap.Layers.Add(lyr);
//FeatureLayer lyr = new FeatureLayer(tblTemp);
// new Feature(tblTemp.TableInfo.Columns);
//ftr.Geometry = pt;
//ftr.Style = cs;
//ftr[sColName] = "车号";
//tblTemp.InsertFeature(ftr);
//MapInfo.Data.Catalog Cat = MapInfo.Engine.Session.Current.Catalog;
////创建临时层
//MapInfo.Data.TableInfoMemTable tblInfoTemp = new MapInfo.Data.TableInfoMemTable("Point");
//MapInfo.Data.Table tblTemp = Cat.GetTable("Point");
//if (tblTemp != null) Cat.CloseTable("Point");
//tblInfoTemp.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(pMap.GetDisplayCoordSys()));
//tblInfoTemp.Columns.Add(ColumnFactory.CreateStyleColumn());
//tblInfoTemp.Columns.Add(ColumnFactory.CreateStringColumn("Name", 40));
//tblInfoTemp.Columns.Add(ColumnFactory.CreateStringColumn("Dept", 15));
//tblInfoTemp.Columns.Add(ColumnFactory.CreateIntColumn("Level"));
//tblTemp = Cat.CreateTable(tblInfoTemp);
//FeatureLayer lyr = new FeatureLayer(tblTemp);
//pMap.Layers.Add(lyr);
//MapInfo.Geometry.FeatureGeometry pt = mpxMkFeaturePoint(pMap.GetDisplayCoordSys(), x, y);
////MapInfo.Geometry.FeatureGeometry pt =
//// new MapInfo.Geometry.Point(
//// lyr.CoordSys, pMap.Center //pMap.Center//new MapInfo.Geometry.DPoint(1, 1) // //
//// ) as MapInfo.Geometry.FeatureGeometry;
////MapInfo.Styles.SimpleVectorPointStyle cs=
//// new MapInfo.Styles.SimpleVectorPointStyle(35, System.Drawing.Color.Red, 13);
//MapInfo.Styles.BitmapPointStyle cs =
// new MapInfo.Styles.BitmapPointStyle("v13.BMP", MapInfo.Styles.BitmapStyles.None, System.Drawing.Color.White, 24);
////MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(new MapInfo.Styles.BitmapPointStyle(
//Feature ftr = new Feature(tblTemp.TableInfo.Columns);
//ftr.Geometry = pt;
//ftr.Style = cs;
//ftr["Name"] = "Kelly";
////ftr["Dept"] = "Sales";
////ftr["Level"] = 3;
//tblTemp.InsertFeature(ftr);
//----------------//
//MapInfo.Mapping.FeatureLayer oLayer;
//MapInfo.Data.Table otable;
//MapInfo.Data.Feature oftr;
//MapInfo.Styles.SimpleVectorPointStyle ostyle1;
//MapInfo.Styles.SimpleLineStyle ostyle2;
//MapInfo.Styles.AreaStyle ostyle3;
//MapInfo.Styles.TextStyle ostyle4;
//MapInfo.Styles.FontPointStyle ostyle = new MapInfo.Styles.FontPointStyle() ;
////MapInfo.Styles.SimpleVectorPointStyle ostyle;
//MapInfo.Geometry.Point opoint;
//MapInfo.Data.Key k;
//oLayer = (MapInfo.Mapping.FeatureLayer)pMap.Layers[pLayerName];
//otable = oLayer.Table;
//opoint = new MapInfo.Geometry.Point(pMap.GetDisplayCoordSys(), pMap.Center.x, pMap.Center.y);
//ostyle1 = new MapInfo.Styles.CompositeStyle(ostyle3, ostyle2, ostyle4, ostyle1,);
//ostyle.Font.Name = "宋体";
//ostyle.PointSize = 30;
//ostyle.Color = System.Drawing.Color.Red;
//oftr = new MapInfo.Data.Feature(opoint, ostyle);
//k = otable.InsertFeature(oftr) ;
//MapInfo.Data.MIConnection cnn = new MapInfo.Data.MIConnection();
//cnn.Open();
//MapInfo.Data.MICommand cmm = new MapInfo.Data.MICommand();
//cmm.Connection = cnn;
//cmm.CommandText = "insert into ASIA(Id,Name,Obj,MI_Style) values(@id,@name,@obj,@style)";
//MapInfo.Styles.FontPointStyle sty = new MapInfo.Styles.FontPointStyle(66, new MapInfo.Styles.Font("Arial", 13), 0, System.Drawing.Color.Red, 18);
//cmm.Parameters.Add("@id", 431431);
//cmm.Parameters.Add("@name", "bsbs");
//cmm.Parameters.Add("@obj", new MapInfo.Geometry.Point(pMap.GetDisplayCoordSys(),0.00,0.00));
//cmm.Parameters.Add("@style", sty);
//cmm.ExecuteNonQuery();
//cnn.Close();
//----------------//
//----------------//
//MapInfo.Data.MIDbType.FeatureGeometry pt = new MapInfo.Geometry.Point(
//System.Collections.ArrayList arStyles = new System.Collections.ArrayList();
//MapInfo.Styles.BitmapPointStyle style2 = new MapInfo.Styles.BitmapPointStyle();
//style2.ThemeValue = "A";
//style2.BitmapName = "ecumenic.bmp";
//style2.Size = 10;
//style2.Style = MapInfo.Styles.All;
//style2.ShowWhiteBackground = false;
////style2._color=Color.Blue; //这句可设置位图颜色,但是怎么让位图不设置颜色..默认为红色
//arStyles.Add(style2);
//FeatureLayer lyr = (FeatureLayer)pMap.Layers[pLayerName];
//lyr.Modifiers.Clear();
//MapInfo.Mapping.Thematics.IndividualValueTheme thm =
// new MapInfo.Mapping.Thematics.IndividualValueTheme(lyr, "i", "i");
//thm.ApplyStylePart = MapInfo.Mapping.Thematics.StylePart.All;
//for (int i = 0; i < thm.Bins.Count; i++) {
// thm.Bins[i].Style.SymbolStyle.PointSize = 30;
//}
//mapUtils.CreateIndividualValueTheme(MapControl1.Map, arStyles, "flBTSPoint", LegendControl1, "i", "i");
}
protected void ButtonZoomIn_Click(object sender, EventArgs e)
{
Map myMap = GetMapObj();
if (myMap == null) return;
myMap.Zoom = new MapInfo.Geometry.Distance(myMap.Zoom.Value / 2, myMap.Zoom.Unit);
}
protected void ButtonZoomOut_Click(object sender, EventArgs e)
{
Map myMap = GetMapObj();
if (myMap == null) return;
myMap.Zoom = new MapInfo.Geometry.Distance(myMap.Zoom.Value * 2, myMap.Zoom.Unit);
}
}
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MapInfo.Mapping;
using MapInfo.WebControls;
using ApplicationStateManager;
using MapInfo.Data;
public partial class _Default : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
ViewEntireMap();
// If the StateManager doesn't exist in the session put it else get it.
if (StateManager.GetStateManagerFromSession() == null)
StateManager.PutStateManagerInSession(new AppStateManager());
// Now Restore State
StateManager.GetStateManagerFromSession().ParamsDictionary[StateManager.ActiveMapAliasKey] = MapControl1.MapAlias;
StateManager.GetStateManagerFromSession().RestoreState();
}
// At the time of unloading the page, save the state
private void Page_UnLoad(object sender, System.EventArgs e)
{
StateManager.GetStateManagerFromSession().SaveState();
}
protected void ButtonViewEntire_Click(object sender, EventArgs e)
{
ViewEntireMap();
}
private void ViewEntireMap()
{
//try {
Map myMap = GetMapObj();
myMap.Clear();
MapInfo.Mapping.MapGeosetLoader gl = new MapGeosetLoader(Server.MapPath("App_Data\\海洋测试.gst"));
myMap.Load(gl);
double x = 111.0;
double y = 22.0;
myMap.Center = new MapInfo.Geometry.DPoint(x,y);
mpxDrawImg(myMap,x,y,"truckImg");
// mpxDrawText(myMap, "truckText", "A13431");
mpxDrawText(myMap, x, y, "truckText", "桂A99999");
//}
//catch (Exception e) {
//}
}
private MapInfo.Mapping.Map GetMapObj()
{
MapInfo.Mapping.Map myMap = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias];
if (myMap == null)
{
myMap = MapInfo.Engine.Session.Current.MapFactory[0];
}
return myMap;
}
/// <summary>
/// 创建mapx表
/// </summary>
/// <param name="pMap">地图</param>
/// <param name="pTabName"></param>
/// <param name="pColumnName"></param>
/// <returns></returns>
private MapInfo.Data.Table mpxMkTable(MapInfo.Geometry.CoordSys pCoordSys, string pTabName,string pColumnName){
MapInfo.Data.Catalog Cat = MapInfo.Engine.Session.Current.Catalog;
MapInfo.Data.Table tblTemp = Cat.GetTable(pTabName);
if (tblTemp != null) Cat.CloseTable(pTabName);
MapInfo.Data.TableInfoMemTable imt = new MapInfo.Data.TableInfoMemTable(pTabName);
imt.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(pCoordSys));
imt.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());
imt.Columns.Add(MapInfo.Data.ColumnFactory.CreateStringColumn(pColumnName, 40));
return Cat.CreateTable(imt);
}
/// <summary>
/// 往表里增加一行
/// </summary>
/// <param name="pTable">表名</param>
/// <param name="pGeometry">坐标</param>
/// <param name="pStyle">样式</param>
/// <param name="pColumnName">列名</param>
/// <param name="pColumnValue">列值</param>
private void mpxTableAddRow(MapInfo.Data.Table pTable,MapInfo.Geometry.FeatureGeometry pGeometry,MapInfo.Styles.Style pStyle,string pColumnName,string pColumnValue) {
Feature ftr = new Feature(pTable.TableInfo.Columns);
ftr.Geometry = pGeometry;
ftr.Style = pStyle;
ftr[pColumnName] = pColumnValue;
pTable.InsertFeature(ftr);
}
/// <summary>
/// 创建文本样式
/// </summary>
/// <param name="pColor">文本颜色</param>
/// <param name="pSize">字体大小</param>
/// <param name="pFontName">字体名称</param>
/// <returns></returns>
private MapInfo.Styles.TextStyle mpxMkTextStyle(System.Drawing.Color pColor, double pSize, string pFontName) {
MapInfo.Styles.TextStyle ts = new MapInfo.Styles.TextStyle();
ts.Font.ForeColor = pColor;
ts.Font.Size = pSize;
ts.Font.Name = pFontName;
ts.ApplyStyle(ts);
return ts;
}
/// <summary>
/// 创建文本样式
/// </summary>
/// <param name="pSize">字体大小</param>
/// <param name="pFontName">字体名称</param>
/// <returns></returns>
private MapInfo.Styles.TextStyle mpxMkTextStyle(double pSize, string pFontName) {
MapInfo.Styles.TextStyle ts = new MapInfo.Styles.TextStyle();
ts.Font.ForeColor = System.Drawing.Color.Black;
ts.Font.Size = pSize;
ts.Font.FontWeight = MapInfo.Styles.FontWeight.Bold;
ts.Font.Name = pFontName;
return ts;
}
/// <summary>
/// 创建图层点坐标
/// </summary>
/// <param name="pSys"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
private MapInfo.Geometry.FeatureGeometry mpxMkFeaturePoint(MapInfo.Geometry.CoordSys pSys,double x,double y) {
MapInfo.Geometry.Point pt = new MapInfo.Geometry.Point(pSys, x, y);
MapInfo.Geometry.FeatureGeometry geo = pt as MapInfo.Geometry.FeatureGeometry;
return geo;
}
/// <summary>
/// 绘制文本
/// </summary>
/// <param name="pSys">坐标系统,如:myMap.GetDisplayCoordSys()</param>
/// <param name="x">经度</param>
/// <param name="y">纬度</param>
/// <param name="pTabName">用于创建图层的表名</param>
/// <param name="pText">要绘制的文本</param>
private void mpxDrawText(MapInfo.Mapping.Map pMap,double x,double y,string pTabName,string pText) {
//MapInfo.Styles.TextStyle sty2 = new MapInfo.Styles.TextStyle();
//sty2.Font.ForeColor = System.Drawing.Color.Red;
//sty2.Font.TextEffect = MapInfo.Styles.TextEffect.Halo;
//MapInfo.Geometry.DRect rt = new MapInfo.Geometry.DRect(x, y, x + 30, y + 12);
//MapInfo.Geometry.LegacyText lt =
// new MapInfo.Geometry.LegacyText(pMap.GetDisplayCoordSys(), rt, pText);
//MapInfo.Data.Feature ft = new MapInfo.Data.Feature(lt, sty2);
//MapInfo.Data.Table dt = mpxMkTable(pMap.GetDisplayCoordSys(), pTabName, "name");
//dt.InsertFeature(ft);
//LabelSource source = new LabelSource(dt); //创建数据源
//source.DefaultLabelProperties.Caption = "name";
//LabelLayer lyr = new LabelLayer(); //创建图层
//lyr.Sources.Append(source);
//pMap.Layers.Add(lyr);
// DRect drect = new DRect(ftr.Geometry.Centroid.x + 2, ftr.Geometry.Centroid.y, ftr.Geometry.Centroid.x + 30, ftr.Geometry.Centroid.y + 12);
string sColumnName = "name"; //创建表
MapInfo.Data.Table dt = mpxMkTable(pMap.GetDisplayCoordSys(), pTabName, sColumnName);
MapInfo.Styles.TextStyle ts = mpxMkTextStyle(System.Drawing.Color.Blue, 8.0, "宋体");
MapInfo.Geometry.FeatureGeometry pt = mpxMkFeaturePoint(pMap.GetDisplayCoordSys(), x, y);
mpxTableAddRow(dt, pt, ts, sColumnName, pText); //往表里增加记录
LabelSource source = new LabelSource(dt); //创建数据源
source.DefaultLabelProperties.Caption = "name";
source.DefaultLabelProperties.Style.Font.ForeColor = System.Drawing.Color.Blue;
source.DefaultLabelProperties.Layout.Offset = 23;
LabelLayer lyr = new LabelLayer(); //创建图层
lyr.Sources.Append(source);
pMap.Layers.Add(lyr); //将图层加到地图
////创建表
//MapInfo.Data.Table mpxTable = mkMapxTable(pMap, layerName);
////创建文字样式
//MapInfo.Styles.TextStyle ts=new MapInfo.Styles.TextStyle();
//ts.Font.ForeColor = System.Drawing.Color.Black;
//ts.Font.Size = 9;
//ts.Font.Name = "宋体";
////创建标源
//LabelSource ls = new LabelSource(mpxTable);
//ls.DefaultLabelProperties.Caption = pText;
//ls.DefaultLabelProperties.Style = ts;
////创建标注层
//LabelLayer lly = new LabelLayer();//pText);
//lly.Sources.Append(ls);
//try {
// pMap.Layers.Add(lly);
//}
//catch (Exception e) {
//}
}
private void mpxDrawImg(MapInfo.Mapping.Map pMap, double x, double y, string pTabName) {
string sColName = "name";
MapInfo.Data.Table dt = mpxMkTable(pMap.GetDisplayCoordSys(), pTabName, sColName); //创建表
MapInfo.Geometry.FeatureGeometry pt = mpxMkFeaturePoint(pMap.GetDisplayCoordSys(), x, y); //创建点和样式
MapInfo.Styles.BitmapPointStyle cs =
new MapInfo.Styles.BitmapPointStyle("v13.BMP", MapInfo.Styles.BitmapStyles.None, System.Drawing.Color.White, 24);
mpxTableAddRow(dt, pt, cs, "name", "truck"); //往表增加记录
FeatureLayer lyr = new FeatureLayer(dt);
pMap.Layers.Add(lyr);
//FeatureLayer lyr = new FeatureLayer(tblTemp);
// new Feature(tblTemp.TableInfo.Columns);
//ftr.Geometry = pt;
//ftr.Style = cs;
//ftr[sColName] = "车号";
//tblTemp.InsertFeature(ftr);
//MapInfo.Data.Catalog Cat = MapInfo.Engine.Session.Current.Catalog;
////创建临时层
//MapInfo.Data.TableInfoMemTable tblInfoTemp = new MapInfo.Data.TableInfoMemTable("Point");
//MapInfo.Data.Table tblTemp = Cat.GetTable("Point");
//if (tblTemp != null) Cat.CloseTable("Point");
//tblInfoTemp.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(pMap.GetDisplayCoordSys()));
//tblInfoTemp.Columns.Add(ColumnFactory.CreateStyleColumn());
//tblInfoTemp.Columns.Add(ColumnFactory.CreateStringColumn("Name", 40));
//tblInfoTemp.Columns.Add(ColumnFactory.CreateStringColumn("Dept", 15));
//tblInfoTemp.Columns.Add(ColumnFactory.CreateIntColumn("Level"));
//tblTemp = Cat.CreateTable(tblInfoTemp);
//FeatureLayer lyr = new FeatureLayer(tblTemp);
//pMap.Layers.Add(lyr);
//MapInfo.Geometry.FeatureGeometry pt = mpxMkFeaturePoint(pMap.GetDisplayCoordSys(), x, y);
////MapInfo.Geometry.FeatureGeometry pt =
//// new MapInfo.Geometry.Point(
//// lyr.CoordSys, pMap.Center //pMap.Center//new MapInfo.Geometry.DPoint(1, 1) // //
//// ) as MapInfo.Geometry.FeatureGeometry;
////MapInfo.Styles.SimpleVectorPointStyle cs=
//// new MapInfo.Styles.SimpleVectorPointStyle(35, System.Drawing.Color.Red, 13);
//MapInfo.Styles.BitmapPointStyle cs =
// new MapInfo.Styles.BitmapPointStyle("v13.BMP", MapInfo.Styles.BitmapStyles.None, System.Drawing.Color.White, 24);
////MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(new MapInfo.Styles.BitmapPointStyle(
//Feature ftr = new Feature(tblTemp.TableInfo.Columns);
//ftr.Geometry = pt;
//ftr.Style = cs;
//ftr["Name"] = "Kelly";
////ftr["Dept"] = "Sales";
////ftr["Level"] = 3;
//tblTemp.InsertFeature(ftr);
//----------------//
//MapInfo.Mapping.FeatureLayer oLayer;
//MapInfo.Data.Table otable;
//MapInfo.Data.Feature oftr;
//MapInfo.Styles.SimpleVectorPointStyle ostyle1;
//MapInfo.Styles.SimpleLineStyle ostyle2;
//MapInfo.Styles.AreaStyle ostyle3;
//MapInfo.Styles.TextStyle ostyle4;
//MapInfo.Styles.FontPointStyle ostyle = new MapInfo.Styles.FontPointStyle() ;
////MapInfo.Styles.SimpleVectorPointStyle ostyle;
//MapInfo.Geometry.Point opoint;
//MapInfo.Data.Key k;
//oLayer = (MapInfo.Mapping.FeatureLayer)pMap.Layers[pLayerName];
//otable = oLayer.Table;
//opoint = new MapInfo.Geometry.Point(pMap.GetDisplayCoordSys(), pMap.Center.x, pMap.Center.y);
//ostyle1 = new MapInfo.Styles.CompositeStyle(ostyle3, ostyle2, ostyle4, ostyle1,);
//ostyle.Font.Name = "宋体";
//ostyle.PointSize = 30;
//ostyle.Color = System.Drawing.Color.Red;
//oftr = new MapInfo.Data.Feature(opoint, ostyle);
//k = otable.InsertFeature(oftr) ;
//MapInfo.Data.MIConnection cnn = new MapInfo.Data.MIConnection();
//cnn.Open();
//MapInfo.Data.MICommand cmm = new MapInfo.Data.MICommand();
//cmm.Connection = cnn;
//cmm.CommandText = "insert into ASIA(Id,Name,Obj,MI_Style) values(@id,@name,@obj,@style)";
//MapInfo.Styles.FontPointStyle sty = new MapInfo.Styles.FontPointStyle(66, new MapInfo.Styles.Font("Arial", 13), 0, System.Drawing.Color.Red, 18);
//cmm.Parameters.Add("@id", 431431);
//cmm.Parameters.Add("@name", "bsbs");
//cmm.Parameters.Add("@obj", new MapInfo.Geometry.Point(pMap.GetDisplayCoordSys(),0.00,0.00));
//cmm.Parameters.Add("@style", sty);
//cmm.ExecuteNonQuery();
//cnn.Close();
//----------------//
//----------------//
//MapInfo.Data.MIDbType.FeatureGeometry pt = new MapInfo.Geometry.Point(
//System.Collections.ArrayList arStyles = new System.Collections.ArrayList();
//MapInfo.Styles.BitmapPointStyle style2 = new MapInfo.Styles.BitmapPointStyle();
//style2.ThemeValue = "A";
//style2.BitmapName = "ecumenic.bmp";
//style2.Size = 10;
//style2.Style = MapInfo.Styles.All;
//style2.ShowWhiteBackground = false;
////style2._color=Color.Blue; //这句可设置位图颜色,但是怎么让位图不设置颜色..默认为红色
//arStyles.Add(style2);
//FeatureLayer lyr = (FeatureLayer)pMap.Layers[pLayerName];
//lyr.Modifiers.Clear();
//MapInfo.Mapping.Thematics.IndividualValueTheme thm =
// new MapInfo.Mapping.Thematics.IndividualValueTheme(lyr, "i", "i");
//thm.ApplyStylePart = MapInfo.Mapping.Thematics.StylePart.All;
//for (int i = 0; i < thm.Bins.Count; i++) {
// thm.Bins[i].Style.SymbolStyle.PointSize = 30;
//}
//mapUtils.CreateIndividualValueTheme(MapControl1.Map, arStyles, "flBTSPoint", LegendControl1, "i", "i");
}
protected void ButtonZoomIn_Click(object sender, EventArgs e)
{
Map myMap = GetMapObj();
if (myMap == null) return;
myMap.Zoom = new MapInfo.Geometry.Distance(myMap.Zoom.Value / 2, myMap.Zoom.Unit);
}
protected void ButtonZoomOut_Click(object sender, EventArgs e)
{
Map myMap = GetMapObj();
if (myMap == null) return;
myMap.Zoom = new MapInfo.Geometry.Distance(myMap.Zoom.Value * 2, myMap.Zoom.Unit);
}
}
发表评论
-
mapxtreme添加标记和删除标记
2009-03-30 16:23 1818新增2个pointselectiontool, clientc ... -
添加数据库中的经纬度信息
2009-03-30 16:22 1779C# Code: 复制内容到剪贴板 代码: MapInfo ... -
MapXtreme 2005自定义图层控制代码(WEB)
2009-03-30 16:21 1582虽然MapXtreme 2005 6.7.1提供了图层控制的控 ... -
mapxtreme 2004 改变feature颜色
2009-03-30 16:18 15841.C# code: 复制内容到剪贴板 代码: MapI ... -
MapxTreme2005地图打印
2009-03-30 16:18 1226MapxTreme2005地图打印 一、语言: c# net2 ... -
在C#应用中如何读取存在ORACLE(或SQL Server)中的MapInfo表
2009-03-30 16:17 1242using MapInfo.Data; ... -
MapXtreme 2005查找图元方法,web的
2009-03-30 16:16 1794先添加一个TextBox和 DropDownList控件 复 ... -
MapXtreme点取地图获得信息
2009-03-30 16:15 1895拖一个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 1246为了实现在地图上手动画线的功能,煞费了一翻苦心,不过最后实现的 ... -
Web页面中实现鼠标中键缩放
2009-03-30 16:11 1541在MapXtreme 2005中,在Windows应用程序中自 ... -
两种方法实现动态轨迹
2009-03-30 16:11 1386在GIS中,动态轨迹的实现是非常有用的,可用GPS定位,热点跟 ... -
总结查找图元的三种方法
2009-03-30 16:10 1258在MapXtreme 2005中,查找图元提供了非常多的方法, ... -
添加标注图层
2009-03-30 16:08 1181在MapXtreme 2005中添加标注图层是非常容易的,只要 ... -
向图层中添加线段
2009-03-30 16:07 945向图层中添加线段和向图层中添加点是一样的,其本质都是向图层中添 ... -
向图层中添加点
2009-03-30 16:06 1037在添加点之前先要在地图上创建一个临时图层,创建临时图层请参考《 ... -
mapxtreme2005 改变选中的图元样式
2009-03-30 16:05 1089MapInfo.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图元定时刷新的功能广泛应用于交通监控、环境监测、物流跟踪等领域,通过实时更新地图上的图标,帮助决策者快速掌握现场情况,提高管理和响应效率。 总之,Mapxtreme 2008 for .NET的图元...
- **标注和图例**:用来解释地图内容的文字或符号。 - **主题图**:根据特定属性对地图进行分类和着色。 - **工具**:为用户提供操作地图的各种工具。 - **工作空间**:存储地图和相关资源的文件夹集合。 - **坐标系...
《MapXtreme Java开发指南...总之,《MapXtreme Java开发指南》是GIS开发者不可或缺的资源,它不仅介绍了MapXtreme Java Edition的强大功能,还提供了实用的编程指导和迁移策略,帮助开发者在GIS应用开发领域取得成功。
5. **图形与标注**:MapXtreme允许在地图上绘制自定义图形和标注,这对于地图注解和解释非常有用。示例可能会展示如何创建和编辑这些元素。 6. **投影与坐标系统**:地图的投影选择和转换是GIS的重要组成部分。学习...
1. **地图对象模型**:MapXtreme基于一个复杂的地图对象模型,包括地图、图层、图例、标注、地理编码等多个元素。这些对象之间相互作用,构建出动态且功能丰富的地图界面。 2. **数据源与图层**:MapXtreme支持多种...
在`mapxtreme添加标记和删除标记.txt`文件中,可能会详细阐述如何实现这些操作,包括使用的API、示例代码以及注意事项。例如,文件可能包含了如何创建自定义标记图标、如何动态加载数据并根据数据添加标记、如何在...
7. **部署与测试**:将开发完成的应用打包部署,进行功能验证和性能优化。 四、学习资源 "mapxtreme学习"这个压缩包文件可能包含了MapXtreme的教程文档、示例代码或视频教程,这些资源可以帮助初学者快速掌握...
5. **应用专题图**:将定义好的规则应用到地图图层,MapXtreme会自动根据规则计算每个区域的样式,并在地图上绘制出来。这可以通过调用MapXtreme API中的相关方法来实现。 6. **交互性与动态更新**:MapXtreme支持...
C#和MapXtreme是构建WebGIS应用的两种关键技术。C#是一种面向对象的编程语言,被广泛用于开发Windows应用程序、Web服务以及.NET框架下的各种应用。MapXtreme则是杰仕登软件公司(GeoServer Solutions)推出的一款...
通过实例代码,用户将学会如何添加标记、绘制图形、实现点击事件处理等功能,进一步提升MapXtreme2008的应用开发能力。 MapXtreme2008的最新特性也是教程的重点之一,例如增强的性能优化、3D地图支持和新的数据分析...
本文将详细讲解如何在MapXtreme图层上绘制线段,涉及的主要知识点包括地图对象的初始化、图层的管理、点坐标处理和线形绘制。 首先,我们需要引用MapXtreme的相关库,这通常通过在项目中添加对MapXtreme .NET DLL的...
MapXtreme Java 4.8 是一款由MapInfo公司开发的专业地图开发工具,它允许开发者在Java环境中创建、管理和展示地理信息系统(GIS)的应用程序。这个“MapXtremeJava4.8install.zip”文件是一个安装包,包含了运行...
MapXtreme与MapInfo紧密集成,用户可以使用MapInfo进行地图编辑和分析,然后通过MapXtreme在Web上发布和交互。两者结合,可以实现从数据管理到应用发布的完整GIS流程。 6. **开发与集成**: 使用MapXtreme的开发...
MapXtreme是一款由Mapinfo公司开发的企业级地图应用服务器,专为Intranet或Extranet环境设计,旨在利用地图展示企业的信息和资源,提升决策效率和资产管理。本教材详细介绍了MapXtreme的各个方面,包括安装配置、...
MapXtreme是一款由MapInfo公司开发的地理信息系统(GIS)软件,专为企业和组织提供高级的地理位置服务和地图解决方案。这款产品具有强大的地图绘制、数据管理、空间分析以及地图服务发布功能,广泛应用于电信、物流...