为了处理adf中关于Maptips的各种棘手问题,我前段时间没少费心血。为了感谢各位朋友的支持,今天我就把整理好的关于如何处理Maptips的技巧和方法贴出来,相信识货的朋友会喜欢滴!
一、如何处理 Maptips 被 map image 遮挡的情况?
当在模板生成的web map application中加入自己的floatpannel等对象时会引起页面对象Z-index的排序,会造成Maptips弹出信息框被map image遮挡的情况,最直接的解决办法:将PageContent div的z-index设值为0即OK。
二、如何修改或取消默认的Maptips图标?——且保留Maptips功能
查看Maptips属性,找到对应的图标文件(一共3个,分别对应于——默认状态、鼠标停留、鼠标点击),然后用Photoshop将这些图标文件修改成透明的gif文件,如此以来,即可保留Maptips功能,又不会因为Maptips图标遮挡原本的图层符号,这在涉及专题图显示的应用中非常有用!
三、如何修改Maptips弹出信息框样式?
基于Heather G. of ESRI的思路,无需变动IIS发布目录下aspnet_client目录中原始的css文件和javascript文件。 具体步骤:
- 1. Change the UseDefaultWebResources property of the maptips control to "False"。
- 2. Copy the "display_maptips.js" file in the "aspnet_client\ESRI\WebADF\JavaScript" directory to the Javascript folder of the web application。
- 3. Change the line in your display_maptips.js (inside of the new folder you just copied to)
From
this.classPrefix = (classPrefix!=null && classPrefix.length>0) ? classPrefix: "ADF_";
To
this.classPrefix = (classPrefix!=null && classPrefix.length>0) ? classPrefix: "Custom_";。 - 4. Register this script in the html source of the mapping application page (default.aspx usually). I put the following line right after the beginning form tag...
--------------------------
'javascript (if in the javascript folder of site)
<script language="javascript" type="text/javascript" src="javascript/display_maptips.js"></script>
--------------------------。 - 5. Copy the maptips.css file from the "aspnet_client\ESRI\WebADF\styles" folder to the root folder of your web site (or anywhere you want, you just have to modify the css link in the page)。
- 6. Modify the css file changing the "ADF_" prefixes to "Custom_" prefixes。
- 7. Add the link to this stylesheet in the "head" section of the html source of the mapping application page
--------------------------
'stylesheet (if in the root folder of the site)
<link href="maptips.css" type="text/css" rel="stylesheet" />
--------------------------。 - 8. Now all thats left is to modify the copied maptips.css file (in the mapping app directory) with the changes you want。
我按如此步骤之后,可以任意定制自己的Maptips了,希望能对朋友们有所帮助。
四、如何将maptips弹出信息框中的click icon fpr more information改成自己内容?——注意编码问题!!
修改display_maptips.js文件,将click icon fpr more information等提示信息修改成自己的,保存即可。
注意,我们的中文操作系统编码默认是gbk、gb2312,而.net默认的编码是utf-8,因此修改了里面汉字信息后,要另存为utf-8编码,否则会出现乱码的现象。具体做法:在vs 2005 IDE中打开修改js后,保存时,高级保存选项里设置编码为utf-8编码。