一起学arcgis:(一)arcgis for js 基于tomcat搭建离线js API 实现离线js地图

本人接触arcgis不久,现就arcgis 基于tomcat搭建离线argis for js API进行描述,以帮助搭建java工程的朋友。

一、下载离线JS API,本人下载的是arcgis_js_v34_api.zip  可在:http://support.esrichina.com.cn/2011/0223/960.html进行下载 Library | SDK  new

二、下载eclispe for javaee ,并打开eclipse for jee创建web工程(本节基于会javaee开发的人员,不会的可以去找相关javaee开发资料),工程名为arcgis

三、将下载下来的api解压,并将arcgis_js_api文件copy到webContent(或WebRoot)目录下.
如图:[img][/img]请看附件

四、然后照着解压目录下有一个install.htm页面里的配置进行修改。
    Configuration options for normal build:
1、Open C:\Inetpub\wwwroot\arcgis_js_api\library\3.4\3.4\init.js in a text editor and search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace this text with "<myserver>/arcgis_js_api/library/3.4/3.4/"
2、Open C:\Inetpub\wwwroot\arcgis_js_api\library\3.4\3.4\js\dojo\dojo\dojo.js in a text editor and search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace this text with "<myserver>/arcgis_js_api/library/3.4/3.4/"
Configuration options for compact build:
3、Open C:\Inetpub\wwwroot\arcgis_js_api\library\3.4\3.4compact\init.js in a text editor and search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace each instance of this text with "<myserver>/arcgis_js_api/library/3.4/3.4compact/"
4、Open C:\Inetpub\wwwroot\arcgis_js_api\library\3.4\3.4compact\js\dojo\dojo\dojo.js in a text editor and search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace this text with "<myserver>/arcgis_js_api/library/3.4/3.4compact/"

基于tomcat的修改对应:
1、打开刚才copy的文件目录:工程(arcgis)/arcgis_js_api/library/3.4/3.4/init.js
将[HOSTNAME_AND_PATH_TO_JSAPI]修改为(包括中括号)
localhost:8080/arcgis/arcgis_js_api/library/3.4/3.4/init.js
后面3个修改的按上进行修改,

修改完成,然后启动tomcat发布出来就可以访问了
页面的请求离线js api例子:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<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://localhost:8080/arcgis/arcgis_js_api/library/3.4/3.4/js/dojo/dijit/themes/tundra/tundra.css"/>
    <link rel="stylesheet" type="text/css" href="http://localhost:8080/arcgis/arcgis_js_api/library/3.4/3.4/js/esri/css/esri.css" />
    <script type="text/javascript" src="http://localhost:8080/arcgis/arcgis_js_api/library/3.4/3.4/init.js"></script>

    <script type="text/javascript">

      dojo.require("esri.map");

      function init() {
        var myMap = new esri.Map("mapDiv");
        //note that if you do not have public Internet access then you will need to point this url to your own locally accessible cached service.

        var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer");

        myMap.addLayer(myTiledMapServiceLayer);

      }

      dojo.addOnLoad(init);

    </script>

  </head>

  <body class="tundra">
  aaaaaaaa
    <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>

<img alt="log" src="img/login.jpg" width="1024px" height="100px">

  </body>

</html>


由于时间紧迫,未进行细说,请见谅

你可能感兴趣的:(tomcat)