日期:2014-05-16  浏览次数:20318 次

ArcGIS JSAPI 压缩传输的解决办法

http://www.gisall.com/html/47/122747-4016.html

?

arcgis js 2.0\ 2.1库实际下载到本地客户端大约是550k多一些,这个对于大型网站的加载速度或多或小会造成影响。很多人考虑使用gzip的方式对其进行压缩,但这种 方法在IE6下面会存在问题。而且esri官方对JSAPI 2.0,2.1版本的说明中没有提及到支持IE6,也就是说最好在其测试过的浏览器版本运行。如果要做js的压缩,不建议使用第三方的工具,因为esri 本身有提供压缩后的js方案。在js离线包下我们可以看到目录\arcgis_js_api\library\2.0下有arcgis和 arcgis_compact两个文件夹,根据安装说明(install.htm)里面的配置,一次修改。最后调用的时候把js引用改为http://localhost/arcgis_js_api/library/2.0/arcgis_compact/ 原来为(http://localhost/arcgis_js_api/library/2.0/arcgis/ ? )。根据对比,使用compact后,实际文件大小为340k,比原来压缩了200k。

以下是安装部署js的说明:

Configuration options for normal build:

Open C:\Inetpub\wwwroot\arcgis_js_api\library\2.0\arcgis\js\esri\esri.js in a text editor.
Search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace all instances of this text with "<myserver>/arcgis_js_api/library/2.0/arcgis/"
Open C:\Inetpub\wwwroot\arcgis_js_api\library\2.0\arcgis\js\dojo\dojo\dojo.xd.js in a text editor.
Search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace all instances of this text with '<myserver>/arcgis_js_api/library/2.0/arcgis/'
Open C:\Inetpub\wwwroot\arcgis_js_api\library\2.0\arcgis\js\dojo\dojo\dojo.xd.js.uncompressed.js in a text editor.
Search for all instances of this text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace this text with '<myserver>/arcgis_js_api/library/2.0/arcgis/'
Configuration options for compact build:

Open C:\Inetpub\wwwroot\arcgis_js_api\library\2.0\arcgis_compact\js\esri\esri.js in a text editor.
Search for all instances of the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace with "<myserver>/arcgis_js_api/library/2.0/arcgis_compact/"
Open C:\Inetpub\wwwroot\arcgis_js_api\library\2.0\arcgis_compact\js\dojo\dojo\dojo.xd.js in a text editor.
Search for all instances of the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace with '<myserver>/arcgis_js_api/library/2.0/arcgis_compact/'
Open C:\Inetpub\wwwroot\arcgis_js_api\library\2.0\arcgis_compact\js\dojo\dojo\dojo.xd.js.uncompressed.js in a text editor.
Search for all instances of this text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace with '<myserver>/arcgis_js_api/library/2.0/arcgis_compact/'

最后还必须在IIS里面定位到arcgis和arcgis_compact目录下,把Default.ashx添加到默认目录中去。