ArcIMS学习之 定制HTML VIEWER笔记

80酷酷网    80kuku.com

  笔记

  一、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.onerror=clearError;
 beforeMapRefresh();
 //window.onerror=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



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: