阅读:2261回复:2
很久以前学google map写的
很久以前学google map写的<BR><BR>
<DIV >看到人家托动时显示的不是背景色而是地图,就学的写了这个。arcims9.2已经可以实现这个功能了。这个是9。0时代net_link的产物。<BR>注意:附录中的cs代码已经修改成9.2adf的连接器了。<BR>注意:不能应用于动态加载的图层。<BR><BR>一、概述<BR>思路:使用table分为9个块,中间的块为主显示框,周边为点缀的块。<BR>以下“0”表示原点位置,其它为分块的编号.<BR>.-----.------.------<BR>| 1 | 2 | 3 |<BR>.-----0------.------<BR>| 8 | - | 4 |<BR>.-----.------.------<BR>| 7 | 6 | 5 |<BR>--------------------<BR>二、修改<BR>1.修改MapFrame.htm主文件<BR> 屏蔽标注//map image后面两行<BR> //var content = '<img name="theImage" src="images/map.gif" hspace=0 vspace=0 border=0 width=' + mWidth + ' height=' + mHeight + '> ';<BR> //createLayer("theMap",0,0,sWidth,sHeight,true,content);<BR>2.添加新的参数,这里构建了一个3*3的表格,在表格中插入img标签<BR> var iMapLeft = -iWidth;<BR> var iMapTop = -iHeight;<BR> <BR> var sMapthe = '<div id="theMapTable" style="position: absolute;z-index: 1; left:0px;top:0px;border: 3px double #00FFFF">';<BR> sMapthe += '<table border="0" id="table1" cellspacing="0" cellpadding="0">';<BR> sMapthe += '<tr>';<BR> sMapthe += '<td><div style="OVERFLOW: auto; width: 100%; height: 100%; z-index: 1" id="maplayer1">';<BR> sMapthe += '<img src ="" name="theImage1" hspace=0 vspace=0 border=0 height="'+iHeight+'" width="'+iWidth+'"></div></td>';<BR> sMapthe += '<td><div style="OVERFLOW: auto; width: 100%; height: 100%; z-index: 1" id="maplayer2">';<BR> sMapthe += '<img src ="" name="theImage2" hspace=0 vspace=0 border=0 height="'+iHeight+'" width="'+iWidth+'"></div></td>';<BR> sMapthe += '<td><div style="OVERFLOW: auto; width: 100%; height: 100%; z-index: 1" id="maplayer3">';<BR> sMapthe += '<img src ="" name="theImage3" hspace=0 vspace=0 border=0 height="'+iHeight+'" width="'+iWidth+'"></div></td>';<BR> sMapthe += '</tr>';<BR> sMapthe += '<tr><td><div style="OVERFLOW: auto; width: 100%; height: 100%; z-index: 1" id="maplayer8">';<BR> sMapthe += '<img src ="" name="theImage8" hspace=0 vspace=0 border=0 height="'+iHeight+'" width="'+iWidth+'"></div>';<BR> sMapthe += '</td>';<BR> sMapthe += '<td><div style="OVERFLOW: auto; width: 100%; height: 100%; z-index: 1" id="maplayer">';<BR> sMapthe += '<img src ="" name="theImage" hspace=0 vspace=0 border=0 height="'+iHeight+'" width="'+iWidth+'"></div>';<BR> sMapthe += '</td>';<BR> sMapthe += '<td><div style="OVERFLOW: auto; width: 100%; height: 100%; z-index: 1" id="maplayer4">';<BR> sMapthe += '<img src ="" name="theImage4" hspace=0 vspace=0 border=0 height="'+iHeight+'" width="'+iWidth+'"></div>';<BR> sMapthe += '</td>';<BR> sMapthe += '</tr>';<BR> sMapthe += '<tr>';<BR> sMapthe += '<td><div style="OVERFLOW: auto; width: 100%; height: 100%; z-index: 1" id="maplayer7">';<BR> sMapthe += '<img src ="" name="theImage7" hspace=0 vspace=0 border=0 height="'+iHeight+'" width="'+iWidth+'"></div></td>';<BR> sMapthe += '<td><div style="OVERFLOW: auto; width: 100%; height: 100%; z-index: 1" id="maplayer6">';<BR> sMapthe += '<img src ="" name="theImage6" hspace=0 vspace=0 border=0 height="'+iHeight+'" width="'+iWidth+'"></div></td>';<BR> sMapthe += '<td><div style="OVERFLOW: auto; width: 100%; height: 100%; z-index: 1" id="maplayer6">';<BR> sMapthe += '<img src ="" name="theImage5" hspace=0 vspace=0 border=0 height="'+iHeight+'" width="'+iWidth+'"></div></td>';<BR> sMapthe += '</tr>';<BR> sMapthe += '</table></div>';<BR> document.writeln('<div id="theMap" style="OVERFLOW: hidden; Top:0px;left:0px;WIDTH: '+(sWidth*3)+'px;HEIGHT: '+(sHeight*3)+'px; POSITION: relative; BACKGROUND-COLOR: #3399ff">'+sMapthe+'</div>');<BR><BR><BR>3.在aimsXML.js中添加新的函数getExp(),用于计算和显示地图<BR>这个文件之间连接了一个aspx页面,这个页面主要就是返回相应大小的地图.<BR>function getExp(){<BR> moveLayer("theMap",iMapLeft,iMapTop);<BR> for (var i=1;i<9;i++){<BR> var name = "theImage"+i;<BR> theObj = document.getElementById(name);<BR> if (theObj!=null){<BR> switch(i){<BR> case 1:<BR> getMapXY(-iWidth,-iHeight);<BR> efTop = mapY;<BR> efRight = eLeft;<BR> efLeft = mapX;<BR> efBottom = eTop;<BR> break;<BR> case 2:<BR> getMapXY(0,-iHeight);<BR> efTop = mapY;<BR> efLeft = mapX;<BR> getMapXY(iWidth,0);<BR> efRight = mapX;<BR> efBottom = mapY;<BR> break;<BR> case 3:<BR> getMapXY(iWidth,-iHeight);<BR> efTop = mapY;<BR> efLeft = mapX;<BR> getMapXY(iWidth+iWidth,0);<BR> efRight = mapX;<BR> efBottom = mapY;<BR> break;<BR> case 4:<BR> getMapXY(iWidth,0);<BR> efTop = mapY;<BR> efLeft = mapX;<BR> getMapXY(iWidth+iWidth,iHeight);<BR> efRight = mapX;<BR> efBottom = mapY;<BR> break;<BR> case 5:<BR> efTop = eBottom;<BR> efLeft = eRight;<BR> getMapXY(iWidth+iWidth,iHeight+iHeight);<BR> efRight = mapX;<BR> efBottom = mapY;<BR> break;<BR> case 6:<BR> getMapXY(0,iHeight);<BR> efTop = mapY;<BR> efLeft = mapX;<BR> getMapXY(iWidth,iHeight+iHeight);<BR> efRight = mapX;<BR> efBottom = mapY;<BR> break;<BR> case 7:<BR> getMapXY(-iWidth,iHeight);<BR> efTop = mapY;<BR> efLeft = mapX;<BR> getMapXY(0,iHeight+iHeight);<BR> efRight = mapX;<BR> efBottom = mapY;<BR> break;<BR> case 8:<BR> getMapXY(-iWidth,0);<BR> efTop = mapY;<BR> efLeft = mapX;<BR> getMapXY(0,iHeight);<BR> efRight = mapX;<BR> efBottom = mapY;<BR> break;<BR> }<BR> theObj.src = 'http://localhost/map.aspx?XMin='+efLeft+';YMin='+efBottom+';XMax='+efRight+';YMax='+efTop+';H='+iHeight+';W='+iWidth+';li=0;other=';<BR> }<BR> <BR> }<BR>}<BR>4.在aimsXML.js文件的processXML()函数中添加上述函数.<BR>添加位置在case 1:中,主要是显示地图.<BR>case 1:<BR> .......<BR> getExp();//每次刷新地图后运行<BR> break;<BR>case 2:<BR> ......<BR>5.在aimsXML.js文件中查找resetPanImage()函数<BR>屏蔽以下语句<BR> //clipLayer2("theMap",0,0,iWidth,iHeight);<BR>6.在aimsNavigation.js文件中查找panMouse()函数<BR> 屏蔽以下语句<BR> //clipLayer2("theMap",cLeft,cTop,cRight,cBottom);<BR> 修改moveLayer("theMap",xMove+hspc,yMove+vspc);为<BR> moveLayer("theMap",xMove+hspc+iMapLeft,yMove+vspc+iMapTop);<BR>7.用"moveLayer("theMap""查询全部文件夹,打来文件依次修改全部moveLayer("theMap",hspc,vspc);函数为<BR> moveLayer("theMap",iMapLeft,iMapTop);</DIV> |
|
1楼#
发布于:2007-05-17 18:57
<DIV >附录:<BR>map.aspx文件关键代码<BR> private class MapPoint<BR> {<BR> public float XMax;<BR> public float YMax;<BR> public float XMin;<BR> public float YMin;<BR> public int iImgWidth;<BR> public int iImgHeigth;<BR> public int iOVImgWidth;<BR> public int iOVImgHeigth;<BR> public int iLi;<BR> public string sOtherVal;<BR> }<BR><BR> private MapPoint mMpaPint = new MapPoint();<BR><BR>protected void Page_Load(object sender, EventArgs e)<BR> {<BR> mMpaPint.XMax = float.Parse(Request.QueryString["XMax"].ToString());<BR> mMpaPint.YMax = float.Parse(Request.QueryString["YMax"].ToString());<BR> mMpaPint.XMin = float.Parse(Request.QueryString["XMin"].ToString());<BR> mMpaPint.YMin = float.Parse(Request.QueryString["YMin"].ToString());<BR> mMpaPint.iImgWidth = int.Parse(Request.QueryString["W"].ToString());<BR> mMpaPint.iImgHeigth = int.Parse(Request.QueryString["H"].ToString());<BR> mMpaPint.iLi = int.Parse(Request.QueryString["li"].ToString());<BR> mMpaPint.sOtherVal = Request.QueryString["other"].ToString();<BR><BR> string MAPSERVICE = ConfigurationSettings.AppSettings["DEFAULT_MAPSERVICE"];<BR> string MAPSERVER = ConfigurationSettings.AppSettings["DEFAULT_MAPSERVER"];<BR> int MAPPORT = int.Parse(ConfigurationSettings.AppSettings["DEFAULT_MAPPORT"]);<BR><BR><BR> string imageURL = "";<BR> switch (mMpaPint.iLi)<BR> {<BR> case 0:<BR> imageURL = getMapArc(mMpaPint, MAPSERVICE, MAPSERVER, MAPPORT);<BR> break;<BR> default:<BR> imageURL = "";<BR> break;<BR> }<BR> Response.Redirect(imageURL);<BR> }<BR><BR> #region 返回地图地址<BR> /// <summary><BR> /// 返回地图地址<BR> /// </summary><BR> /// <param name="MpaP">地图坐标</param><BR> /// <param name="mapService">ims服务器</param><BR> /// <param name="mapServer">地图服务名称</param><BR> /// <param name="mapPort">端口</param><BR> /// <returns></returns><BR> private string getMapArc(MapPoint MpaP, string mapService, string mapServer, int mapPort)<BR> {<BR> StringBuilder builder1 = new StringBuilder();<BR> builder1.Append("<ARCXML version=\"1.1\">");<BR> builder1.Append("<REQUEST>");<BR> builder1.Append("<GET_IMAGE>");<BR> builder1.Append("<PROPERTIES>");<BR> builder1.Append(string.Concat(new object[] { "<ENVELOPE minx=\"", MpaP.XMin, "\" miny=\"", MpaP.YMin, "\" maxx=\"", MpaP.XMax, "\" maxy=\"", MpaP.YMax, "\" />" }));<BR> builder1.Append(string.Concat(new object[] { "<IMAGESIZE width=\"", MpaP.iImgWidth, "\" height=\"", MpaP.iImgHeigth, "\" />" }));<BR> builder1.Append("</PROPERTIES>");<BR> builder1.Append("</GET_IMAGE>");<BR> builder1.Append("</REQUEST>");<BR> builder1.Append("</ARCXML>");<BR><BR> return getImageUrl(SetArxXML(builder1.ToString(), mapService, mapServer, mapPort));<BR> }<BR> #endregion<BR><BR> #region 处理ArcXML字符串<BR> /// <summary><BR> /// 处理ArcXML字符串<BR> /// </summary><BR> /// <param name="AXLRequest"></param><BR> /// <returns>ArcXML</returns><BR> private string SetArxXML(string AXLRequest, string mapService, string mapServer, int mapPort)<BR> {<BR> TCPConnection connection = new TCPConnection();<BR> connection.Host = mapServer;<BR> connection.Port = mapPort;<BR> connection.ServiceName = mapService;<BR><BR> //string responseArr=connection.ClientServicesArray().ToString();<BR> string SeriveName = setService(AXLRequest);<BR> string response = "";<BR> if (AXLRequest.Trim() != "")<BR> {<BR> if (SeriveName.Trim() != "")<BR> {<BR> response = connection.Send(AXLRequest, SeriveName);<BR> }<BR> else<BR> {<BR> response = connection.Send(AXLRequest);<BR> }<BR> }<BR><BR> if (response.IndexOf("ERROR") > 1)<BR> {<BR> response = "";<BR> }<BR> return response;<BR> }<BR> #endregion<BR><BR> #region 判断ArcXML使用服务<BR> /// <summary><BR> /// 判断ArcXML使用服务<BR> /// </summary><BR> /// <param name="ArcXml"></param><BR> /// <returns>名称</returns><BR> public string setService(string ArcXml)<BR> {<BR> string SeriveName = "";<BR> if (ArcXml.IndexOf("<GET_FEATURES") > -1) SeriveName = "Query";<BR> else if (ArcXml.IndexOf("<GET_GEOCODE") > -1) SeriveName = "Geocode";<BR> else if (ArcXml.IndexOf("<GET_EXTRACT") > -1) SeriveName = "Extract";<BR> return SeriveName;<BR> }<BR> #endregion<BR><BR> #region 返回ArcXML对应的地图文件<BR> /// <summary><BR> /// 返回ArcXML对应的地图文件<BR> /// </summary><BR> /// <param name="urlxml">ArcXML输出</param><BR> /// <returns></returns><BR> public string getImageUrl(string urlxml)<BR> {<BR> string urls = "";<BR> XmlDocument doc = new XmlDocument();<BR> doc.LoadXml(urlxml);<BR> XmlElement root = doc.DocumentElement;<BR> XmlNodeList nodelist = root.GetElementsByTagName("OUTPUT");<BR> if (nodelist != null)<BR> {<BR> XmlNode countnode = nodelist.Item(0);<BR> urls = countnode.Attributes["url"].InnerXml;<BR> }<BR> return urls;<BR> }<BR> #endregion</DIV>
|
|
2楼#
发布于:2007-05-20 19:41
学习中
|
|