ArcIMS学习之 定制HTML VIEWER笔记

一、HTML VIEWER简介:
 1。默认的HTML VIEWER由一组HTML页和JS文件(JavaScript)组成,这些HTML页和JS文件由ArcIMS Designer定制生成。
 2。对于HTML Viewer,我们所做的功能扩展可以包括:

  * 改变框架布局
  * 修改工具条
  * 增加自己的功能
  * 改变图形外观
  * 插入自己的图标
 3。ArcIMS Designer定制的网站默认在Web容器的home目录的\default-web-app\Website 目录下

二、HTML Viewer文件结构:
 1。由一组HTML文件,一个参数文件ArcIMSparam.js及两个目录--JavaScript和images组成。

站点目录
    |
    | HTML Pages
    | ArcIMSparam.js
    |
    |---- JavaScript目录//包含JavaScript函数库,定义了用户可操作的地图功能,包括了HTML Viewer的大部分操作。
    |    //可以通过定制这些JavaScript程序为自己的工具按扭增加功能。如热连接等。
    |---- images 目录 //包含用于页面上按钮,图标及标记的显示。当新建站点时,可以用自己的标志代替这些原有的影像


 2。ArcIMSparam.js与HTML Pages
 HTML Viewer的一个重要的参数文件是位于站点目录下的ArcIMSparam.js文件。这个文件包含了一组影响站点外观和工作方式的JavaScript变量。对HTML Viewer大部分的定制都可以通过改变这些变量的值来完成。ArcIMSparam.js包含的主要变量可以用来

 * 改变所用的地图服务和地图范围
 * 设置图例的初始化显示
 * 定义acetate层的指北针,版权文字
 * 定义属性字段的显示
 * 改变工具和工具条

 HTML Viewer默认入口是Default.htm。它的处理了四个任务
  1>创建页面标题,
  2>确定所用的浏览器类型,
  3>建立URL解析规则
  4>生成用于定义页面布局框架的viewer.htm文件。

 Viewer.htm定义了HTML Viewer的结构,而不是内容,他将浏览器划分为多个区域。每个区域通过HTML文件获得内容。其他的HTML文件则为框架添加内容。

一般关系如下:
先装入MapFrame.html于MapFrame中,再由MapFrame打开TocFrame其中装入toc.htm,所以在toc.htm用MapFrame的内容时,
 var t;
 if(opener){
 t=opener.parent.MapFrame;
 }else{
 t=parent.MapFrame;
 }
因为,MapFrame.html包含了aimsCustom.js、aimsXML.js、ArcIMSparam.js,因而将添加的函数放入aimsCustom.js(包括构造发送XML的函数和处理XML的函数useCustomFunction)后在各自框架中调用MapFrame中新加的函数!

以添加定位功能为例,一般是在aimsCustom.js中加入函数,如function addressLocation(x,y,name)
其中先保存上一幅地图的范围,再调用sendMapXML()获得新地图

发送request
saveLastExtent()

Arguments:
None

Returned Value:
None

Description:
Function that saves the last map extent.

Uses: eLeft, eRight, eTop, and eBottom.

Called by: displayAttributeData in aimsIDentify.js; fullExtent, startExtent, zoomToPoint,
zoomToEnvelope, zoomScale, zoomButton, and panButton in aimsMap.js;
ovMapClick, zoomin, zoomout, stopZoomBox, stopZoomOutBox, stopPan, and pan in
aimsNavigation.js; and showHighlight in aimsSelect.js.
Sets: lastLeft, lastRight, lastTop, and lastBottom.

File:
aimsMap.js
Syntax:


sendMapXML()
Arguments:
None
Returned Value:
None

Description:
Sends an ArcXML request to obtain a new map image to the MapServer.

会用到的变量为: debugOn and imsURL.

Calls: beforeMapRefresh and showRetrieveMap in aimsMap.js and writeXML and sendToServer in
aimsXML.js.

Called by: bufferIt in aimsBuffer.js; clickFunction in aimsClick.js; processStartExtent in
aimsCommon.js; parseGeocodeResults in aimsGeocode; displayAttributeData in
aimsIDentify.js; fullExtent, startExtent, zoomBack, zoomToPoint, zoomToEnvelope,
zoomScale, zoomButton, and panButton in aimsMap.js; ovMapClick, zoomin, zoomout,
stopZoomBox, stopZoomOutBox, stopPan, and pan in aimsNavigation.js; showHighlight
in aimsSelect.js; and process XML in aimsXML.js.

在aimsXML.js文件中的sendMapXML()函数内容为:

function sendMapXML() {

 beforeMapRefresh();
 showRetrieveMap();
 var theText = writeXML();
 if (debugOn==2) alert(msgList[12] + theText);
 
 sendToServer(imsURL,theText,1);

}

其中:writeXML()写出对新地图的request XML,要修改就对writeXML()进行修改

writeXML()

Arguments:
None

Returned Value:
String ArcXML request string to be sent to the ImageServer.

Description:
Writes an ArcXML request for a new map image. This is the default request sent for a main map display image.

用到的变量为: eLeft, eRight, eTop, eBottom, iHeight, iWidth, aimsLayersPresent, toggleVisible, layerCount,
aimsClassRenderPresent, mapBackColor, aimsLegendPresent, legendVisible, aimsBufferPresent,
showBuffer, aimsSelectPresent, showGeocode, geocodeX, geocodeY, geocodePointColor,
geocodePointSize, geocodeLabel, aimsClickPresent, clickCount, selectColor, clickType,
clickMarkerColor, clickMarkerType, clickMarkerSize, aimsCustomPresent, drawCopyright,
CopyrightCoords, CopyrightText, CopyrightStyle, CopyrightSize, CopyrightFont, CopyrightColor,
CopyrightBackground, CopyrightBGColor, CopyrightGlow, CopyrightGlowColor, drawNorthArrow,
NorthArrowType, NorthArrowSize, NorthArrowCoords, NorthArrowAngle, drawScaleBar,
ScaleBarbackColor, ScaleBarFont, ScaleBarStyle, ScaleBarColor, MapUnits, scalebarFontColor,
ScaleBarUnits, ScaleBarPrecision, ScaleBarSize, ScaleBarWidth, drawModeOnMap, modeBlurb,
modeMapColor, and modeMapGlow and LayerVisible, LayerID, clickPointX, and clickPointY arrays.
Calls: addSpecialRenderToMap in aimsClassRender.js (custom sample); addBufferToMap in aimsBuffer.js;
addLegendToMap in aimsLegend.js; addCustomToMap1, addCustomToMap2, addCustomToMap3,
and addCustomToMap4 in aimsCustom.js; addSelectToMap in aimsSelect.js; and getScaleBarDistance
in aimsMap.js.

Called by: clickAddPoint, resetClick, and deleteClick in aimsClick.js; getLegend in
aimsLegend.js; getPrintMap in aimsPrint.js; clearSelection in aimsSelect.js; and
sendMapXML and justGetMap in aimsXML.js.

File:
aimsXML.js

其中sendMapXML()函数最后调用:

sendToServer(URLString,XMLRequest,theType)

Arguments:
URLString -- String containing service URL for request.
XMLRequest -- String containing ArcXML request.
theType -- Numeric representing mode number to be passed to XMLMode. Used by processXML in passing ArcXML response to appropriate function for processing.

Returned Value:
None

Description:
Used to pass ArcXML requests on to the server(s). This function updates the form in the PostFrame page
(jsForm.htm) with the current request and processing function name.

Calls: showRetrieveMap, hideRetrieveMap, and hideRetrieveData in aimsMap.js.
Called by: functions sending ArcXML requests to the server(s).

File:
aimsXML.js



// aimsCustom.js
// 缺省生成的aimsCustom.js是添加用于定制函数的模版

//***************************************地址匹配函数******************************************
/*
 *    函数名       addressLocation     
 *    描 述       在地图上显示地址匹配坐标点          
 *   参数说明      x,y:地址匹配坐标点的地图坐标
 *                 name :地址匹配点的地图标识   
 *   返回结果      无    
 *   使用的公共变量 limitRight limitLeft limitTop limitBottom selectPointMargin
 *   
 *   aimsMap.js中的
 *   eLeft (Numeric/Dynamic) Current extent left (minimum x-coordinate).
 *      Formerly called left.
 *   eRight (Numeric/Dynamic) Current extent right (maximum x-coordinate).
 *      Formerly called right.
 *   eTop (Numeric/Dynamic) Current extent top (maximum y-coordinate).
 *      Formerly called top.
 *   eBottom (Numeric/Dynamic) Current extent bottom (minimum y-coordinate).
 *      Formerly called bottom.
 *   showGeocode (Boolean/Dynamic) If true, map request will include
 *      command to draw point at geocodeX, geocodeY
 *      with an optional label. Updated by viewer on
 *      response of address match request or
 *      zoomToPoint() function.
 *   geocodeX (Numeric/Dynamic) Geocode point x-coordinate. Updated by
 *      viewer on address match response or
 *      by zoomToPoint().
 *   geocodeY (Numeric/Dynamic) Geocode point y-coordinate. Updated by
 *      viewer on address match response or
 *      by zoomToPoint().
 *   调   用       sendMapXML(aimsXML.js)     
 *   被调用             
*/
function addressLocation(x,y,name){
 legendVisible=false;
 hasTOC=false;

 var mWMargin = 0;
 var mHMargin = 0;
 mWMargin = Math.abs(limitRight-limitLeft) * (selectPointMargin/10);
 mHMargin = Math.abs(limitTop-limitBottom) * (selectPointMargin/10);
 saveLastExtent();
 eLeft = parseFloat(x) - parseFloat(mWMargin);
 eRight = parseFloat(x) + parseFloat(mWMargin);
 eTop = parseFloat(y) + parseFloat(mHMargin);
 eBottom = parseFloat(y) - parseFloat(mHMargin);
 showGeocode=true;
 geocodeX=x;
 geocodeY=y;
 geocodeLabel=name;
 sendMapXML();
}
/*****************************************************************************
 * aimsXML.js
 * send the created xml request to map server
 */
function sendMapXML() {
 // ask for the Main map
 //window.οnerrοr=clearError;
 beforeMapRefresh();
 //window.οnerrοr=resetError;
 showRetrieveMap();

 var theText = writeXML();

 if (debugOn==2) alert(msgList[12] + theText);
 //alert(theText);
 //hasTOC=false;
 sendToServer(imsURL,theText,1);
}
/*****************************************************************************
 *function writeXML()


接收response


processXML(theReplyIn)

Arguments:
theReplyIn--String containing returned ArcXML response.

Returned Value:
None

Description:
Passes the ArcXML response to the appropriate function for processing. The key global is XMLMode,which determines which function to call,即设定XMLMode就可以决定processXML(theReplyIn)调用哪个分析response XML的函数。

Calls: appropriate function to parse ArcXML response.

Called by: passXML in dynamic connector-created page in PostFrame on loading.

File:
aimsXML.js

 全局变量XMLMode的值<1000,由processXML(theReplyIn)调用其默认函数,>1000即用户自定义时,processXML(theReplyIn)调用useCustomFunction()函数。全局变量XMLMode在aimsXML.js中定义(见Customizing ArcIMS: HTML Viewer第308<315>页)。


useCustomFunction(theReply)

Arguments:
theReply String containing returned ArcXML response.

Returned Value:
None

Description:
Available for custom processing of returned ArcXML responses. The function processXML will call this function if the value of the global XMLMode is 1,000 or greater.

Uses: XMLMode.

Calls: hideLayer in aimsDHTML.js.

Called by: processXML in aimsXML.js.

File:
aimsCustom.js

 

ArcIMS学习之 HTML Viewer定制笔记 续一(1.概要&流程)

1.当使用ArcIMS Designer创建一个Web Site后,就会自动生成此网站的HTML Viewer,ArcIMS Designer生成网站的地点就在Posr Installation定义的 Website directory
问题是可不可以把 JSP应用服务器 和 ArcIMS Server 分别放在两台服务器上?

2.选择HTML Viewer的理由是,用户不需要自己给地图添加数据,而且只使用并只使用一个Image Service。

3.HTML Viewer文件组织:
 
ArcIMSparam.js包含了一系列JavaScript变量定义网站的外观和行为,大量定制在这里进行;

HTML网页
流程:
 Default.htm - 为网站入口(检查browser版本,IE、NetScape 4.0以上)如不支持的浏览器,转入
  CannotRun.htm,如支持转入

 Run.htm - 定义了两个Frame:
  MapFrame (Authorize.htm)
  PostFrame (jsForm.htm) //本 Frame 的Size为零,隐含

  定义两个Frame的同时,onload检查权限、发送请求 Request AXL
  Authorize.htm中的Response AXL的处理函数
 在此定义的主要是授权用!
  processAuthorization()对于response如果没有错的话,就不管了,直接进入viewer.htm
 
 viewer.htm - 定义了程序主框架 

 

 


                   
 
 jsForm.htm - 定义了Form name="theForm" ,以type="post",发送用于请求的Request AXL
  INPUT NAME="ArcXMLRequest" 放置Request AXL
 **> jsForm.htm 文件包含有一个函数passXML(),在提交请求时为空,在Servlet响应返回后,由Servlet生成返回页插入PostFrame 文件包含的一个函数passXML()其有变量 var XMLResponse包含服务器响应的Response AXL;同时函数还调用MapFrame的processXML()处理 Response AXL。
 function passXML() {
  var XMLResponse='<?xml version="1.0"。。。。</ARCXML>';
  parent.MapFrame.processXML(XMLResponse);
 }

 

 

 ArcIMS学习之 HTML Viewer定制笔记 续二(2.Servlet与请求响应过程)

4. Servlet Connector的入口Servlet:
 com.esri.esrimap.Esrimap 参数
ServiceName  ArcIMS 服务名
ClientVersion  ArcIMS 版本号
Form    true请求来自HTML的Form
Encode  

* 请求重定向 CustomService 参数
原因:
 影像虚拟服务(Image MapService) 不提供"属性信息","几何信息","地理编码"等的功能,所以请求被重定向到其它的虚拟服务。
即:
 When sending a request other than GET_IMAGE to an image MapService,redirection is required;
 Redirection is achieved in action attribute of the PostForm:
GET_FEATURES 
 CustomService = Query
GET_GEOCODE
 CustomService = Geocode
GET_EXTRACT
 CustomService = Extract
Http://caesar1:8888/servlet/com.esri.esrimap.Esrimap?ServiceName=Beijing&CustomService=Query&ClientVersion=3.1&Form=true

5.PostForm
ArcXMLRequest(required) ArcXML request being sent to the server
JavaScriptFunction(optional) 指定 jsForm.htm 中的处理response 函数名,默认为passXML()
RedireURL(optional)
BgColor(optional)
FormCharset(optional)

6.请求与响应的过程:
 1>Request --> Servlet Connector -->Application Server
 Servlet Connector对传来的Request进行解析,只传给Application Server :
  * ServiceName
  * ArcXMLRequest
 其余参数由Servlet Connector保留对响应(Response)的格式设置

 2>对Servlet Connector的调用为:
  http://hostName/servlet/com.esri.esrimap.Esrimap

 3>响应:Application Server将参数传递给 Spatial Server,Spatial Server将响应
 (Response)返回给 Application Server,所有的 Response只有两种:
 * ArcXML  包含属性信息、图片的URL(HTML Viewer只能处理这一种)
 * Feature Stream 二进制压缩要素流
 
 4>the Servlet Connector Creates a new HTML page based on
 * Value of the input elements specified in the request
 * Default values of the input elements
 * The Response ArcXML

 

 

 ArcIMS学习之 HTML Viewer定制笔记 续三(3.请求&响应)

请求
一、最基本函数:
 sendToServer --> htmlSendToServer
 提交表单 PostForm
(aimsXML.js)
 参数:
  URLString 
  XMLRequest Request ArcXML
  theType  XMLMode的值,默认为1,GET_IMAGE
sendToServer将 theType 赋给XMLMode,然后调用htmlSendToServer提交表单。

二、GET_SERVICE_INFO
 由 getStartExtent()构造,并调用sendToServer(imsURL,theString,3);(aimsCommon.js)
 具体调用关系为:
 viewer.htm在所有Frame装完后,onload一个doIt()--> checkParams --> startMap -->startUp -->getStartExtent
 (startMap、startUp、getStartExtent都在aimsCommon.js)

三、GET_IMAGE
 首次的 GET_IMAGE 是在对GET_SERVICE_INFO的响应中调用的(case 3);
 sendMapXML()
 writeXML()构造得到 Map 图的 ArcXML

响应
一、处理响应最基本函数:
aimsXML.js中的:
    processXML(XMLResponse)根据 XMLMode 处理相关 Response
 function processXML(theReplyIn) {
  ...
  switch(XMLMode) {
   case 1: //得到地图GET_IMAGE
   ...
   default: //XMLMode >= 1000交给用户定制处理
    if (XMLMode >= 1000) {
     useCustomFunction(theReply); 
    } else {
     alert(theReply + msgList[19]);
    } 
 }

二、
case 3: GET_SERVICE_INFO
保存查到的地图最大值,调用 ProcessStartExtent(theReply) (aimsCommon.js)
 -->sendMapXML(){
   writeXML();
   sendToServer(,,1);
  }
三、用户定制:
processXML 中当 XMLMode大于1000时,为用户定制处理:
  default://XMLMode >= 1000交给用户定制处理
   // send any responses to custom requests off to the custom handler
   // XMLMode >= 1000 are reserved for custom requests/responses
   if (XMLMode >= 1000) {
    useCustomFunction(theReply); 
 useCustomFunction(theReply)在aimsCustom.js中
 
 接收的Servlet为com.esri.esrimap.Esrimap

ArcIMS学习之 HTML Viewer定制笔记 续四(4.动态效果DHTML

一、CSS基础:
Html:
<DIV id="xxx"    style="background-color:blue;
    left:20px;top:20px;
    position:absolute;
    visibility:visible;
    z-index:0">
</DIV>
Javascript:
 document.getElementById("xxx").style.visibility="hidden";

参数说明:
 <DIV id="xxx"></DIV> 
  将其包括的其他HTML元素或文本应用到指定的样式规则(CSS)中,也称“容器”。
 background-color 背景色,Javascript为:xxx.style.backgroundColor
 clip   剪切指定部分来显示;其语法为:
     .style.clip="rect(top,right,bottom,left)";
     注意此参数的顺序不寻常;
     例:style.clip='rect(20 400 500 30)';
 left、top  与容器的相对位置
 position  指定位置规则如何使用,多个元素设绝对位置(absolute)可实现重叠
 visibility  CSS图层是否可见,有二值:visible 和 hidden
 z-index  指定元素重叠顺序,0位最底层,大于0的整数为上层,默认都为0层

二、ArcIMS使用(aimsDHTML.js)

 1.创建CSS层:
 function createLayer(name, inleft, intop, width, height, visible, content) {
   var layer;
   if (isNav4) {
     document.writeln('<layer name="' + name + '" left=' + inleft + ' top=' + intop + ' width=' + width + ' height=' + height +  ' visibility=' + (visible ? '"show"' : '"hide"') +  '>');
     document.writeln(content);
     document.writeln('</layer>');
   } else {
     document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + inleft + 'px; top:' + intop + 'px; width:' + width + 'px; height:' + height + 'px;' + '; z-index:1; visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
     document.writeln(content);
     document.writeln('</div>');
   }
}
 只要将要放入层内的内容写好调用createLayer即可;

 2.显示、隐藏层
 2.1辅助函数:
 得到层:
 function getLayer(name) {
   if (isNav4)
     return(document.layers[name]);
   else if (isIE4) {
     layer = eval('document.all.' + name + '.style');
     return(layer);
   } else if (is5up) {
  var theObj = document.getElementById(name);
  return theObj.style
   }
   else
     return(null);
  }
 2.2显示、隐藏层
 function showLayer(name){
  getLayer(name).visibility="visible";
  }
 function hideLayer(name){
  getLayer(name).visibility="hidden";
  }
 
 先将MapFrame中所有图片<IMG>都创建为层,这样可实现显示和隐藏功能。

ArcIMS学习之 HTML Viewer定制笔记 续五(5.Javascript纪要)

1.另一个Frame中的JavaScript变量:
 var 可在其他框架中使用:
  Frame名.变量名 来调用
2.<Table>中
 <TR> -- Table Row
 <TD> -- Table Data
3.<IMG>元素
  <IMG src="图片路径" alt="提示"> 
4.DOM 模型
        + forms[]
        | images[]
      + frames [] -- document  -| anchors[]
        | document     |  ...
        | navigator    + applets[]
 window --| history
     | status 属性
     + location
5.事件
 1> onClick ,onLoad 等不是 事件处理函数(event handler)而是 事件 (event);
 2> 对照表
 ------------------+------------------------
  Object | Event
 ------------------+------------------------
 window,FrameSet | onLoad
 Frame   | onUnload
 ------------------+------------------------
 Button,IMG,Frame | onClick
    | onMouseDown
    | onMouseUp
    | onMouseMove
 ------------------+------------------------
 3>事件处理函数
  function startUp(){
   document.onmousedown = maptool;//maptool是函数名
   }
  function maptool(){
   ...
   }
  <body onload = "startUp()">
 4>
 event.clientX
 event.clientY 鼠标坐标,相对于包容窗口左上角

 event.offsetX
 event.offsetY 鼠标坐标,相对于源元素位置
 
 5>onUnload事件含义:
 Browser已经离开使用框架、document网页,在转入其它页之前的事件

转载于:https://www.cnblogs.com/njlhb/archive/2007/05/31/766131.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值