1、th计算机网路编程课程设计一、 设计内容1、 学习MapXtreme电子地图。2、 利用C#+MapXtreme实现电子地图网站的开发。二、 实验要求1、 编程实现图元添加显示功能;2、 实现图元查找功能;3、 实现图元移动功能;4、 实现图元删除功能三、 软件安装1、 安装IISA、 解压IIS_XPSP3.rarB、 点击控制面板点击添加删除程序点击“添加/删除windows组件”在弹出的对话框中选择“Internet信息服务”点击下一步。C、 需要选择文件时选择刚才解压的文件。2、 安装VS2005:按默认选项安装。3、 安装MapXtremeA、 双击MapXtreme 2008 6.
2、8 中文破解版目录中的MapXtremeTRIALCHS.exe文件。B、 将MapXtreme 2008 6.8 中文破解版6.8破解mapxtreme680. lic文件拷贝到C:Program FilesCommon FilesMapInfoMapXtreme6.8.0目录四、 程序设计1、打开VS,打开给定的工程FireControlGIS.sln。2、打开Web.Config,找到将路径改为相应的目录。3、 将resi char font.ttf文件拷到C:WINDOWSFonts目录下。4、 建立人员结构类。打开clsUserType.cs文件,在类文件中填入如下代码:public
3、 class clsUserType private string strBMID; private string personID; private string personName; private MapInfo.Geometry.DPoint DPoint; private string strUserType() this.strBMID=电子信0901; this.personID=0111; this.personName=+; this.DPoint=new MapInfo.Geometry.DPoint(1,1); this.strFileName=LITE2-32.BMP
4、; public void setstrBMID(string strBMID) this.strBMID=strBMID; public void setpersonID(string personID) this.personID=personID; public void setpersonName(string personName) this.personName=personName; public void setDPoint(MapInfo.Geometry.DPoint DPoint) this.DPoint=DPoint; public void setstrFIleNam
5、e(string strFIleName) this.strFIleName=strFIleName; public string getstrBMID() return this.strBMID; public string getpersonID() return this.personID; public string getpersonName() return this.personName; public MapInfo.Geometry.DPoint getDPoint() return this.DPoint; public string getstrFIleName() re
6、turn this.strFIleName; 5、 建立取得屏幕坐标点的类文件。打开WebInfoGetXY.cs类并输入下图所示代码。public class WebInfoGetXY:MapInfo.WebControls.MapBaseCommand public WebInfoGetXY() base.Name=GetXY; public override void Process() MapControlModel model=MapControlModel.GetModelFromSession(); MapInfo.Mapping.Map map=model.GetMapObj(
7、MapAlias); System.Drawing.Point points=ExtractPoints(DataString); MapInfo.Geometry.DPoint dpoint=new MapInfo.Geomtry.Dpoint(); map.DisplayTransform.FromDisplay(points0,out dpoint);string outText=屏幕xy:+points0.X+,+points0.Y; outText +=经纬度xy:+dpoint.x,+dpoint.y;HttpContext.Current.Response.Write(outTe
8、xt); 6、 建立地图操作命令类。clsMapCommand.cs并输入下图代码。public class clsMapCommand:MapInfo.WebControls.MapBaseCommand private MapControlModel model; private MapInfo.Mapping.Map map; public clsMapCommand() bass.Name=MapCommand: public override void Process() string Commad_type=Convert.ToString(HttpContext.Current.
9、RequestCommad_type); string LayerTable_name=Convert.ToString(HttpContext.Current.RequestLayerTable_name); string feature_name=Convert.ToString(HttpContext.Current.Requestfeature_name); string feature_kind=Convert.ToString(HttpContext.Current.Requestfeature+kind); Double point_x=Convert.ToString(Http
10、Context.Current.Requestpoint_x); Double point_y=Convert.ToString(HttpContext.Current.Requestpoint_y); CommonUserGisFuncyion_CommonUserGisFunction=newCommonUserGisFunction(); model=MapControlModel.GetModelFromSession(); map=model.GetMapObj(MapAlias); if(LayerTable_name=nill) LayerTable_name=newLayer;
11、switch(Commad_type) case Select: _CommonUserGisFunction.SearchWithSearch(map,LayerTable_name,feature_name,feature_kind); break; case Move: _CommonUserGisFunction.MoveObject(map,LayerTable_name,feature_name, feature_kind, new MapInfo.Geometry.DPoint(point_x,point_y); break; case ClearAllObject: _Comm
12、onUserGisFunction.clear_feature(map,LayerTable_name); break; case ClearObject: _CommonUserGisFunction.clear_feature(map,LayerTable_name,feature_name,feature_kind; break; case Refresh: _CommonUserGisFunction.Update_Person_Position(map,LayerTable_name); break; default: break; 7、 在main.aspx.cs文件的pageLo
13、ad函数中输入添加图层人员的代码。#regionif(myMap!=null) if(myMap.LayersnewLayer!=null) myMap.Layers.Remove(newLayer); if(myMap.LayersroadLayer!=null) myMap.Layers.Remove(roadLayer); CommonUserGisFunction _CommonUserGisFunction=new CommonUserGisFunction()MapInfo.Mapping.IMapLayer ly=_CommonUserGisFunction.CreatNewLa
14、yer(myMap,newLayer,mewLayer);myMap.Layers.Insert(2,ly);clsUserType _clsUserType=new clsUserType();_clsUserType.setDPoint(new MapInfo.Geometry.DPoint(2,2);_clsUserType.setpersonName(自定义点);_clsUserType.setpersonID(0000);CommonUserGisFunction.AddPointToLayer(myMap,newLayer,newLayer,_clsUserType);FontPo
15、intStyle fStyle=new FontPontPointStyle();fStyle.Code=76;fStyle.PointSize=24;fStyle.Color=System.Drawing.Color.Red;fStyle.Font.Name=resident evil characters;fStyle.Font.FontWeight=MapInfo.Styles.FontWeight.Bold;fStyle.Angle=400;_clsUserType.setDPoint(new MapInfo.Geometry.DPoint(1.6,1.6);_clsUserType.
16、setpersonID(0111);_clsUserType.setpersonName(佟环);CommonUserGisFunction.AddPointToLayer(myMap,newLayer,newLayer,_clsUserType,fStyle);SimpleVectorPointStyle vStyle=new SimpleVectorPointStyle();vStyle.Code=67;vStyle.Color=System.Drawing.Color.Red;vStyle.PointSize=Convert.ToInt16(24);vStyle.Attributes=S
17、tyleAttributes.PointAttributes.BaseAll;vStyle.SetApplyAll();_clsUserType.setDPoint(new MapInfo.Geometry.DPoint(1,1);CommonUserGisFunction.AddPointToLayer(myMap,newLayer,newLayer,_clsUserType,vStyle);#endregion完成上面步骤后运行程序可以实现地图显示功能,在显示的地图中出现三个位图点。8、 图元查找、移动、删除功能实现。在main.aspx文件中填入如下代码。A、 在位置填入下列代码。属性名
18、称属性值B、 在位置添加如下图所示的SelectObject()函数。function SelectObject() var mapImage=document.getElementById(MapControl1_Image); var feature_name=document.forms0.feature_name.value; var feature_value=document.forms0.feature_value.value; var url=MapController.ashx?Command=MapCommand&Width=+mapImage.width+&Height=
19、+mapImage.height+&ExportFormat=+mapImage.exportFormat+&Ran=+Math.random()+&Commad_type=Select&feature_name=+feature_name+&feature_kind=佟环; if(mapImage.mapAlias) url+=&MapAlias=+mapImage.mapAlias; var xmlHttp=null; if(BrowserType()=IE) xmlHttp=new ActiveXObject(Microsoft.XMLHTTP); else if(BrowserType
20、()=NS) xmlHttp=new XMLHttpRequest(); xmlHttp.open(GET,url,false); xmlHttp.send(null); var result=xmlHttp.responseText; alert(result); UpdateMap(); ShowMapArea(); C、 在位置输入如下所示的移动图元代码。function MoveObject() var mapImage=document.getElementById(MapControl1_Image); var feature_name=document.forms0.featur
21、e_name.value; var feature_value=document.forms0.feature_value.value; var url=MapController.ashx?Command=MapCommand&Width=+mapImage.width+&Height=+mapImage.height+&ExportFormat=+mapImage.exportFormat+&Ran=+Math.random()+&Commad_type=Move&feature_name=+feature_name+&feature_kind=佟环&point_x=2.2&point_y
22、=2.2; var xmlHttp=null; if(BrowserType()=IE) xmlHttp=new ActiveXObject(Microsoft.XMLHTTP); else if(BrowserType()=NS) xmlHttp=new XMLHttpRequest(); xmlHttp.open(GET,url,false); xmlHttp.send(null); var result=xmlHttp.responseText; alert(result); UpdateMap(); ShowMapArea(); D、 在位置输入如下删除所有图元代码。function
23、ClearAllObject() var mapImage=document.getElementById(MapControl1_Image); var url=MapController.ashx?Command=MapCommand&Width=+mapImage.width+&Height=+mapImage.height+&ExportFormat=+mapImage.exportFormat+&Ran=+Math.random()+&Commad_type=ClearAllObject; var xmlHttp=null; if(BrowserType()=IE) xmlHttp=
24、new ActiveXObject(Microsoft.XMLHTTP); else if(BrowserType()=NS) xmlHttp=new XMLHttpRequest(); xmlHttp.open(GET,url,false); xmlHttp.send(null); var result=xmlHttp.responseText; alert(result); UpdateMap(); ShowMapArea(); E、 在位置输入删除图元代码。function ClearObject() var mapImage=document.getElementById(MapCon
25、trol1_Image); var feature_name=document.forms0.feature_name.value; var feature_value=document.forms0.feature_value.value; var url=MapController.ashx?Command=MapCommand&Width=+mapImage.width+&Height=+mapImage.height+&ExportFormat=+mapImage.exportFormat+&Ran=+Math.random()+&Commad_type=ClearObject&fea
26、ture_name=+feature_name+&feature_kind=佟环; var xmlHttp=null; if(BrowserType()=IE) xmlHttp=new ActiveXObject(Microsoft.XMLHTTP); else if(BrowserType()=NS) xmlHttp=new XMLHttpRequest(); xmlHttp.open(GET,url,false); xmlHttp.send(null); var result=xmlHttp.responseText; alert(result); UpdateMap(); ShowMap
27、Area();9、参照步骤步骤6添加班级其他同学,并显示。10、实现按文本框中的内容查找、删除图元功能:参照下列代码修改main.aspx文件中的SelectObject()、MoveObject()、ClearObject()函数,在函数中添加下列代码并将url中的Name和XXX改为下图所示的形式。function SelectObject() var mapImage=document.getElementById(MapControl1_Image); var feature_name=document.forms0.feature_name.value; var feature_va
28、lue=document.forms0.feature_value.value; var url=MapController.ashx?Command=MapCommand&Width=+mapImage.width+&Height=+mapImage.height+&ExportFormat=+mapImage.exportFormat+&Ran=+Math.random()+&Commad_type=Select&feature_name=+feature_name+&feature_kind=+feature_value+; if(mapImage.mapAlias) url+=&MapAlias=+mapImage.mapAlias;
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2