ArcGIS API for Javascript在tomcat下的离线部署--基于3.9版本

    xiaoxiao2021-12-14  21

    ArcGIS API for JavaScript在tomcat下的离线部署–基于3.9版本  操作步骤:  前提是Java环境、tomcat环境都配置完成,这里就不做详细说明了;  (1)在arcgis资源网站(http://support.esrichina-bj.cn/2011/0223/960.html)下载3.9版本的js api,并解压到本地;  (2)在MyEcplise 10中新建Web Project;  (3)在web工程的WebRoot目录下新建arcgis_js_api/3.9目录;  (4)将本地解压的js api目录下…/arcgis_js_v39_api/arcgis_js_api/library/3.9/3.9compact中的所有文件都拷贝到web工程的WebRoot目录下新建arcgis_js_api/3.9文件夹下;  (5)api的注册,分为两步:

    1). 打开web工程中的WebRoot目录下arcgis_js_api/3.9/init.js文件,查找"[HOSTNAME_AND_PATH_TO_JSAPI]",并将"[HOSTNAME_AND_PATH_TO_JSAPI]js/dojo/dojo",替换成:"serverIP(你电脑的IP地址):8080(tomcat端口号)/MyMapTest(新建web project的工程名)/arcgis_js_api/3.9/js/dojo/dojo" 2). 打开web工程中的WebRoot目录下arcgis_js_api/3.9/js/dojo/dojo/dojo.js文件,查找"[HOSTNAME_AND_PATH_TO_JSAPI]",并将"[HOSTNAME_AND_PATH_TO_JSAPI]js/dojo/dojo",替换成:"serverIP(你电脑的IP地址):8080(tomcat端口号)/MyMapTest(新建web project的工程名)/arcgis_js_api/3.9/js/dojo/dojo"

    (6)编写测试demo,在web工程的WebRoot目录下新建index.html文件,编写一个显示地图的例子,其代码如下:

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Simple Map</title> <link rel="stylesheet" type="text/css" href="http://192.168.1.108:8080/MyMapTest/arcgis_js_api/3.9/js/dojo/dijit/themes/tundra/tundra.css" /> <link rel="stylesheet" type="text/css" href="http://192.168.1.108:8080/MyMapTest/arcgis_js_api/3.9/js/esri/css/esri.css" /> <script type="text/javascript" src="http://192.168.1.108:8080/MyMapTest/arcgis_js_api/3.9/init.js"></script> <script type="text/javascript"> dojo.require("esri.map"); function init() { var myMap = new esri.Map("mapDiv"); var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer"); myMap.addLayer(myTiledMapServiceLayer); } dojo.addOnLoad(init); </script> </head> <body class="tundra"> <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div> </body> </html> 123456789101112131415161718192021222324 123456789101112131415161718192021222324

    (7)测试,在浏览器中输入:http://192.168.0.1(IP地址):8080(tomcat端口号)/MyMapTest(工程名)/index.html  若显示出地图,则说明部署成功。 

    转载请注明原文地址: https://ju.6miu.com/read-972047.html

    最新回复(0)