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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章