<% ' Map Viewer (Third Edition) by Howie Sternberg at howies@snet.net. ' Map Viewer is placed in the public domain and is "Freeware". ' Map Viewer may be freely used and redistributed, is provided "AS-IS" ' without warranty of any kind, and there is no technical support provided. ' --------------------- ' Map Service variables ' --------------------- Dim objArcIMSConnector ' ActiveX Connector Object Dim strRequestAXL ' ArcIMS Request Dim strResponseAXL ' ArcIMS Response Dim aServiceLayerId ' Array of LAYER id values Dim aServiceLayerName ' Array of LAYER name values Dim aServiceLayerMinScale ' Array of LAYER minscale values (map units per pixel) Dim aServiceLayerMaxScale ' Array of LAYER maxscale values (map units per pixel) Dim aServiceLayerType ' Array of LAYER type values(featureclass, image, acetate) Dim aServiceLayerFclass ' Array of DATASET type values (point, line, polygon) Dim aServiceLayerRowId ' Array of LAYER Row Id field names - field type = 99 (#ID# or x.y.OBJECTID) Dim aServiceLayerDateFields ' Array of LAYER Date field names - field type = 91 Dim aLayersForm ' Array of layers for Layers function Dim aLayersFormCanDoVisible ' Array of layers for Layers form saying if visiblity can be changed: true|false... Dim aLayersFormCanDoLegend ' Array of layers for Layers form saying if legend can be controlled can be changed: true|false... Dim aLayersFormCanDoIdentify ' Array of layers for Layers form saying if layer can be identified: true|false... Dim aLayersFormCanDoSelect ' Array of layers for Layers form saying if layer can be selected: true|false... Dim aLayersVisible ' Array of current state of layer visibility: true|false... Dim aLayersLegend ' Array of current state of layers to show legend: true|false... Dim aLayersIdentify ' Array of current state of layers to identify: true|false... Dim strActiveLayerId ' Layer Id of the feature layer map service that can be selected ' ------------------------------ ' Map Service Functions and Subs ' ------------------------------ Sub setLayerArrays(sOpt1,sOpt2,sOpt3) ' Populate arrays describing map service layers, layers currently visible, in legend, to identify, etc. aServiceLayerId = split(strServiceLayerId,"|") aLayersVisible = split(strLayersVisible,"|") ' Required for map optionlevel1, level2, and level3 If (sOpt1 = "identify") Then ' Setup layers to Identify aServiceLayerName = split(strServiceLayerName,"|") aServiceLayerFclass = split(strServiceLayerFclass,"|") aServiceLayerRowId = split(strServiceLayerRowId,"|") aServiceLayerDateFields = split(strServiceLayerDateFields,"|") aServiceLayerMinScale = split(strServiceLayerMinScale,"|") aServiceLayerMaxScale = split(strServiceLayerMaxScale,"|") aLayersIdentify = split(strLayersIdentify,"|") ElseIf (sOpt2 = "layers") Then ' Setup layers to control with Layers function aServiceLayerName = split(strServiceLayerName,"|") aServiceLayerType = split(strServiceLayerType,"|") aServiceLayerFclass = split(strServiceLayerFclass,"|") aServiceLayerRowId = split(strServiceLayerRowId,"|") aServiceLayerMinScale = split(strServiceLayerMinScale,"|") aServiceLayerMaxScale = split(strServiceLayerMaxScale,"|") aLayersForm = split(strLayersForm,"|") aLayersFormCanDoVisible = split(strLayersFormCanDoVisible,"|") aLayersFormCanDoLegend = split(strLayersFormCanDoLegend,"|") aLayersFormCanDoIdentify = split(strLayersFormCanDoIdentify,"|") aLayersFormCanDoSelect = split(strLayersFormCanDoSelect,"|") aLayersLegend = split(strLayersLegend,"|") aLayersIdentify = split(strLayersIdentify,"|") Elseif (sOpt2 = "legend") Then ' Setup layers to include in Legend aLayersLegend = split(strLayersLegend,"|") End If If ((sOpt3 = "select") or (sOpt3 = "autoselect")) Then ' Selected features. Need to do getfeaturesAXL and/or getHighlightLayerAXL If (not isArray("aServiceLayerName")) Then aServiceLayerName = split(strServiceLayerName,"|") End If If (not isArray("aServiceLayerType")) Then aServiceLayerType = split(strServiceLayerType,"|") End If If (not isArray("aServiceLayerFclass")) Then aServiceLayerFclass = split(strServiceLayerFclass,"|") End If If (not isArray("aServiceLayerRowId")) Then aServiceLayerRowId = split(strServiceLayerRowId,"|") End If If (not isArray("aServiceLayerMinScale")) Then aServiceLayerMinScale = split(strServiceLayerMinScale,"|") End If If (not isArray("aServiceLayerMaxScale")) Then aServiceLayerMaxScale = split(strServiceLayerMaxScale,"|") End If End If End Sub Sub setDefaultMapProperties() ' get defaults from properties.xml Dim sList, aList sList = transformXMLfromFile("xml\properties.xml","xsl\propertiesdefault.xsl") aList = Split(sList,"|") 'response.write sList 'response.end strPropertyMapScaleAppliesToPrint = aList(0) dblPropertyScreenWidthInch = Cdbl(aList(1)) intPropertyImgWidth = Cint(aList(2)) intPropertyImgHeight = Cint(aList(3)) strPropertyImgPreserveView = aList(4) dblPropertyNavigateMaxScale = aList(5) dblPropertyFeatureMaxScale = aList(6) strPropertyFeatureMinMax = aList(7) strPropertyFeatureColor = aList(8) strPropertyFeatureLimitList = aList(9) strPropertyFeaturePointType = aList(10) intPropertyFeaturePointWidth = Cint(aList(11)) strPropertyFeatureLineType = aList(12) intPropertyFeatureLineWidth = Cint(aList(13)) strPropertyFeaturePolygonBoundary = aList(14) strPropertyFeaturePolygonFillType = aList(15) dblPropertyFeaturePolygonFillTransparency = aList(16) strPropertyLabelTextFont = aList(17) strPropertyLabelTextFontStyle = aList(18) intPropertyLabelTextFontSize = Cint(aList(19)) strPropertyLabelTextFontColor = aList(20) strPropertyLabelTextPrintmode = aList(21) strPropertyLabelHowMany = aList(22) strPropertyLabelMinMax = aList(23) dblPropertyPanFactor = Cdbl(aList(24)) intPropertyZoomFactor = Cint(aList(25)) strPropertyScaleUnits = aList(26) ' copy image width and height values to second set of variables to compare with if user resizes image intMapImgWidth = intPropertyImgWidth intMapImgHeight = intPropertyImgHeight ' initialize scale variables dblPropertyMapScaleDenominator = 0 dblMapScaleDenominator = 0 intPropertyScreenWidthPixel = 0 End Sub Sub setDefaultMapTools() ' get default tool from mapviewer.xml Dim sList, aList sList = transformXMLfromFile("xml\mapviewer.xml","xsl\mapviewertool.xsl") aList = Split(sList,"|") 'response.write sList 'response.end strMapTool = aList(0) strMapOptionLevel1 = "none" strMapOptionLevel2 = aList(1) strMapOptionLevel3 = "none" End Sub Sub setDefaultMapService() ' get default map service from mapviewer.xml Dim sList, aList sList = transformXMLfromFile("xml/mapviewer.xml","xsl/mapviewermapservicedefault.xsl") 'response.write sList 'response.end ' Get info for first element in mapviewer.xml with default="true" (delimiter is *) ' This is a safety precaution in case there is more than one default map specified in the ' mapviewer.xml file. aList = split(sList,"*") sList = aList(0) 'response.write sList 'response.end ' Convert list of info to array (delimiter is |) aList = split(sList,"|") strMapServerURL = aList(0) strMapService = aList(1) strMapTitle = aList(2) End Sub Sub setMapService(sMapServerURL,sMapService) If ((strComp(sMapServerURL,strMapServerURLPrevious,1) <> 0) or (strComp(sMapService,strMapServicePrevious,1) <> 0)) Then strMapServerURLPrevious = sMapServerURL strMapServicePrevious = sMapService ' Dim locals Dim sAXL, responseAXL, i, sList, aList, aLayer, delimiter ' Get service info sAXL = getServiceInfoAXL("false","true","true","false") call objArcIMSConnector.SendAxlRequest (sMapService, sAXL) responseAXL = objArcIMSConnector.ResponseAXL 'response.write responseAXL 'response.end ' Transform service info into lists of values sList = transformXML(responseAXL,"xsl\serviceinfolayerinfo.xsl") 'response.write sList 'response.end sList = Left(sList,Len(sList) - 1) aList = Split(sList,"|") ' Populate map service and layers variables with service info stuff strServiceLayerId = "" strServiceLayerName = "" strServiceLayerVisible = "" strServiceLayerMinScale = "" strServiceLayerMaxScale = "" strServiceLayerType = "" strServiceLayerFclass = "" delimiter = "" For i = 0 to UBound(aList) aLayer = split(aList(i),",") strServiceLayerId = strServiceLayerId & delimiter & aLayer(0) strServiceLayerName = strServiceLayerName & delimiter & aLayer(1) strServiceLayerVisible = strServiceLayerVisible & delimiter & aLayer(2) If Len(aLayer(3)) > 0 Then strServiceLayerMinScale = strServiceLayerMinScale & delimiter & aLayer(3) Else strServiceLayerMinScale = strServiceLayerMinScale & delimiter & "0" End If If Len(aLayer(4)) > 0 Then strServiceLayerMaxScale = strServiceLayerMaxScale & delimiter & aLayer(4) Else strServiceLayerMaxScale = strServiceLayerMaxScale & delimiter & "99999" End If strServiceLayerType = strServiceLayerType & delimiter & aLayer(5) strServiceLayerFclass = strServiceLayerFclass & delimiter & aLayer(6) delimiter = "|" Next ' Get ordered list of the name of the rowid field in each layer sList = transformXML(responseAXL,"xsl\serviceinforowid.xsl") strServiceLayerRowId = Left(sList,Len(sList) - 1) 'response.write strServiceLayerRowId 'response.end ' Get ordered list of the name of date field in each layer and store in array ' Note, [ ] brackes are appended to the begining and end of each date field name ' in order to make each one easily retrievable in the featurefind.xsl and ' featureselect.xsl stylesheets, which sets their css class to "mapDateField" ' so that the formatDates() onload JavaScript function can find these values ' in milliseconds and format them to a readable date such as "31 Dec 1901". sList = transformXML(responseAXL,"xsl\serviceinfodatefields.xsl") strServiceLayerDateFields = Left(sList,Len(sList) - 1) 'response.write strServiceLayerDateFields 'response.end ' Get the map service screen DPI, extent and map units sList = transformXML(responseAXL,"xsl\serviceinfo.xsl") 'response.write sList 'response.end aList = Split(sList,"|") strServiceType = aList(0) ' either imagemapserver or arcmapserver strServiceCoordsSeparator = aList(1) strServiceTupleSeparator = aList(2) strServiceScreenDpi = aList(3) strServiceImageLimitPixelCount = aList(4) dblServiceMinX = Cdbl(aList(5)) dblServiceMinY = Cdbl(aList(6)) dblServiceMaxX = Cdbl(aList(7)) dblServiceMaxY = Cdbl(aList(8)) strServiceMapUnits = aList(9) End If End Sub Sub setMap(sMapServerURL,sMapService,sMapTitle) ' set the map using info from mapviewer.xml file strMapTitlePrevious = sMapTitle ' Dim locals Dim sAXL, responseAXL, i, j, sList, aList, aLayer, delimiter, sTrue, sFalse Dim sLayersFormIsVisible, sLayersFormIsLegend, sLayersFormIsIdentify Dim aLayersFormIsVisible, aLayersFormIsLegend, aLayersFormIsIdentify Dim aServiceLayerMinScale, aServiceLayerMaxScale ' Initialize globals for Layers function strLayersForm = "" strLayersFormCanDoVisible = "" strLayersFormCanDoLegend = "" strLayersFormCanDoIdentify = "" strLayersFormCanDoSelect = "" strLayersVisible = strServiceLayerVisible strLayersLegend = "" strLayersIdentify = "" ' Arrays of map service info, including default layer visibility state for all layers in map service aServiceLayerId = Split(strServiceLayerId,"|") aServiceLayerType = split(strServiceLayerType,"|") aServiceLayerMinScale = Split(strServiceLayerMinScale,"|") aServiceLayerMaxScale = Split(strServiceLayerMaxScale,"|") aLayersVisible = Split(strLayersVisible,"|") ' Populate map service and layers variables with service info stuff delimiter = "" For i = 0 to UBound(aServiceLayerId) strLayersForm = aServiceLayerId(i) & delimiter & strLayersForm sTrue = sTrue & delimiter & "true" sFalse = sFalse & delimiter & "false" delimiter = "|" Next ' Place map service url and name in an array that is passed as parameter to ' mapviewermapservicelayersdefault.xsl and later to mapviewercando.xsl. Dim aMapParams(4) aMapParams(0) = Array("currentMapServerUrl", sMapServerURL) aMapParams(1) = Array("currentMapService", sMapService) aMapParams(2) = Array("currentMapTitle", sMapTitle) aMapParams(3) = Array("defaultMapTool",strMapTool) aMapParams(4) = Array("defaultMapOptionLevel2", strMapOptionLevel2) ' Get info describing how to setup Layers function from mapviewer.xml sList = transformXMLfromFileWithParameters("xml\mapviewer.xml","xsl\mapviewermapservicelayersdefault.xsl",aMapParams) 'response.write sList 'response.end ' Test if info about how to setup Layers function exists in mapviewer.xml. If so, do Customized Layers Settings. Otherwise, do Default Layers Settings. If (Len(sList) > 0) then ' *** Customized Layer Settings (map service listed in mapviewer.xml) *** sList = Left(sList,Len(sList) - 1) aList = Split(sList,"|") delimiter = "" strLayersForm = "" ' Create deliminated strings of the various settings for layers listed in mapviewer.xml file For i = 0 to UBound(aList) aLayer = Split(aList(i),",") strLayersForm = strLayersForm & delimiter & aLayer(0) strLayersFormCanDoVisible = strLayersFormCanDoVisible & delimiter & aLayer(1) strLayersFormCanDoLegend = strLayersFormCanDoLegend & delimiter & aLayer(2) strLayersFormCanDoIdentify = strLayersFormCanDoIdentify & delimiter & aLayer(3) strLayersFormCanDoSelect = strLayersFormCanDoSelect & delimiter & aLayer(4) sLayersFormIsVisible = sLayersFormIsVisible & delimiter & aLayer(5) sLayersFormIsLegend = sLayersFormIsLegend & delimiter & aLayer(6) sLayersFormIsIdentify = sLayersFormIsIdentify & delimiter & aLayer(7) delimiter = "|" If (Cbool(aLayer(8))) Then intActiveLayerIndex = getLayerIndex(aLayer(0), aServiceLayerId) strActiveLayerId = aLayer(0) End If Next ' Legend On/Off - By default Legend is off for all layers strLayersLegend = sFalse ' Identify On/Off - By default Identify is Off for all layers strLayersIdentify = sFalse ' Arrays describing default Legend and Identify states for all layers in map service aLayersLegend = Split(strLayersLegend,"|") aLayersIdentify = Split(strLayersIdentify,"|") ' Arrays describing how user can control layer with Layers function. Arrays may not include all layers in map service. Based on layers listed in mapviewer.xml file. aLayersForm = Split(strLayersForm,"|") aLayersFormCanDoVisible = Split(strLayersFormCanDoVisible,"|") aLayersFormCanDoLegend = Split(strLayersFormCanDoLegend,"|") aLayersFormCanDoIdentify = Split(strLayersFormCanDoIdentify,"|") aLayersFormCanDoSelect = Split(strLayersFormCanDoSelect,"|") ' Arrays describing default state of layers controlled with Layers function. Arrays may not include all layers in map service. Based on layers listed in mapviewer.xml file. aLayersFormIsVisible = Split(sLayersFormIsVisible,"|") aLayersFormIsLegend = Split(sLayersFormIsLegend,"|") aLayersFormIsIdentify = Split(sLayersFormIsIdentify,"|") ' Convert Layer Id values to index number values in aLayersForm array. Return error message if a Layer Id used in mapviewer.xml file is invalid (not included in) map service For i = 0 to UBound(aLayersForm) j = getLayerIndex(aLayersForm(i), aServiceLayerId) If j = -1 Then response.write "Error: The mapviewer.xml file references an invalid layer id.

<layer id=""" & aLayersForm(i) & """> is NOT in the """ & sMapService & """ map service.

Fix error in the mapviewer.xml file." response.end End If aLayersForm(i) = j Next ' Layer visibilty - Change default layer visibility by resetting values in aLayersVisible with values from aLayersFormIsVisible For i = 0 to UBound(aLayersForm) aLayersVisible(aLayersForm(i)) = aLayersFormIsVisible(i) Next ' Disable Legend, Identify, and Select functions if layer type is not featureclass For i = 0 to UBound(aLayersForm) If ( (strComp(aServiceLayerType(aLayersForm(i)),"featureclass",1) <> 0) )Then aLayersFormCanDoLegend(i) = "false" aLayersFormCanDoIdentify(i) = "false" aLayersFormCanDoSelect(i) = "false" aLayersFormIsLegend(i) = "false" aLayersFormIsIdentify(i) = "false" End If Next ' Legend - Enable Legend function if Layer is visible or if Layer visibility can be controlled For i = 0 to UBound(aLayersForm) If ( (not Cbool(aLayersVisible(aLayersForm(i)))) and (not Cbool(aLayersFormCanDoVisible(i))) and (Cbool(aLayersFormCanDoLegend(i))) )Then aLayersFormCanDoLegend(i) = "false" aLayersLegend(aLayersForm(i)) = "false" End If Next ' Identify - Enable Identify function if Layer is visible or if Layer visibility can be controlled For i = 0 to UBound(aLayersForm) If ( (not Cbool(aLayersVisible(aLayersForm(i)))) and (not Cbool(aLayersFormCanDoVisible(i))) and (Cbool(aLayersFormCanDoIdentify(i))) )Then aLayersFormCanDoIdentify(i) = "false" aLayersIdentify(aLayersForm(i)) = "false" End If Next ' Select - Enable Select function if Layer is visible or if Layer visibility can be controlled For i = 0 to UBound(aLayersForm) If ( (not Cbool(aLayersVisible(aLayersForm(i)))) and (not Cbool(aLayersFormCanDoVisible(i))) and (Cbool(aLayersFormCanDoSelect(i))) )Then aLayersFormCanDoSelect(i) = "false" 'aLayersSelect(aLayersForm(i)) = "false" End If Next ' Legend On/Off - Set Legend On only if layer is visible by resetting values in aLayersLegend with values from aLayersFormIsLegend For i = 0 to UBound(aLayersForm) If (Cbool(aLayersVisible(aLayersForm(i)))) Then aLayersLegend(aLayersForm(i)) = aLayersFormIsLegend(i) End If Next ' Identify On/Off - Set Identify On only if Layer is visible by resetting values in aLayersIdentify with values from aLayersFormIsIdentify For i = 0 to UBound(aLayersForm) If (Cbool(aLayersVisible(aLayersForm(i)))) Then aLayersIdentify(aLayersForm(i)) = aLayersFormIsIdentify(i) End If Next ' Reset strLayersForm based on aLayersForm array values, converted from Layer Ids to a 0-based index number delimiter = "" strLayersForm = "" For i = 0 to UBound(aLayersForm) strLayersForm = strLayersForm & delimiter & aLayersForm(i) delimiter = "|" Next ' Reset strLayersVisible based on aLayersVisible array values delimiter = "" strLayersVisible = "" For i = 0 to UBound(aLayersVisible) strLayersVisible = strLayersVisible & delimiter & aLayersVisible(i) delimiter = "|" Next ' Reset strLayersLegend based on aLayersLegend array values delimiter = "" strLayersLegend = "" For i = 0 to UBound(aLayersLegend) strLayersLegend = strLayersLegend & delimiter & aLayersLegend(i) delimiter = "|" Next ' Reset strLayersIdentify based on aLayersIdentify array values delimiter = "" strLayersIdentify = "" For i = 0 to UBound(aLayersIdentify) strLayersIdentify = strLayersIdentify & delimiter & aLayersIdentify(i) delimiter = "|" Next Else ' *** Default Layers Settings (map service not listed in mapviewer.xml) *** ' Enable Visible, Legend, Identify and Select functions for all layers. By default, show legend for visible layers, but do not identify. strLayersFormCanDoVisible = sTrue strLayersFormCanDoLegend = sTrue strLayersFormCanDoIdentify = sTrue strLayersFormCanDoSelect = sTrue strLayersLegend = strLayersVisible strLayersIdentify = sFalse ' option - Identify all visible layers. Caution, this can be slow ' strLayersIdentify = strLayersVisible dblIdentifyMinScale = 0 dblIdentifyMaxScale = 0 ' Arrays describing default Legend and Identify states for all layers in map service 'aLayersLegend = Split(strLayersLegend,"|") aLayersIdentify = Split(strLayersIdentify,"|") ' Arrays describing how user can control layer with Layers function. Arrays include all layers in map service. aLayersForm = Split(strLayersForm,"|") aLayersFormCanDoLegend = Split(strLayersFormCanDoLegend,"|") aLayersFormCanDoIdentify = Split(strLayersFormCanDoIdentify,"|") aLayersFormCanDoSelect = Split(strLayersFormCanDoSelect,"|") ' Convert Layer Id values to index number values in aLayersForm array For i = 0 to UBound(aLayersForm) j = getLayerIndex(aLayersForm(i), aServiceLayerId) aLayersForm(i) = j Next ' Reset strLayersForm based on modified array delimiter = "" strLayersForm = "" For i = 0 to UBound(aLayersForm) strLayersForm = strLayersForm & delimiter & aLayersForm(i) delimiter = "|" Next ' Disable Legend, Identify, and Select functions if layer type is not featureclass For i = 0 to UBound(aLayersForm) If ( (strComp(aServiceLayerType(aLayersForm(i)),"featureclass",1) <> 0) )Then aLayersFormCanDoLegend(i) = "false" aLayersFormCanDoIdentify(i) = "false" aLayersFormCanDoSelect(i) = "false" End If Next End If ' Reset strLayersFormCanDoLegend based on aLayersFormCanDoLegend array values delimiter = "" strLayersFormCanDoLegend = "" For i = 0 to UBound(aLayersFormCanDoLegend) strLayersFormCanDoLegend = strLayersFormCanDoLegend & delimiter & aLayersFormCanDoLegend(i) delimiter = "|" Next ' Reset strLayersFormCanDoIdentify based on aLayersFormCanDoIdentify array values delimiter = "" strLayersFormCanDoIdentify = "" For i = 0 to UBound(aLayersFormCanDoIdentify) strLayersFormCanDoIdentify = strLayersFormCanDoIdentify & delimiter & aLayersFormCanDoIdentify(i) delimiter = "|" Next ' Reset strLayersFormCanDoSelect based on aLayersFormCanDoSelect array that values delimiter = "" strLayersFormCanDoSelect = "" For i = 0 to UBound(aLayersFormCanDoSelect) strLayersFormCanDoSelect = strLayersFormCanDoSelect & delimiter & aLayersFormCanDoSelect(i) delimiter = "|" Next ' Set identify min and max scales dblIdentifyMinScale = getIdentifyMinScale() dblIdentifyMaxScale = getIdentifyMaxScale() ' Initialize Find Feature function variables intSearchOptionPrevious = -1 intSearchOption = 0 strSearchFeatureLimit = "25" strSearchBeginRecord = "1" strSearchListFeatureLimit = "25" strSearchListBeginRecord = "1" intSearchLayerIndex = 0 strSearchFclass = "" strSearchFields = "" strSearchFieldsType = "" strSearchField = "" strSearchFieldVal = "" strSearchFieldDataType = "" strSearchOperator = "like" strSearchSortField = "" strSearchSortOrder = "" ' Initialize navigate map variables intNavigateLayerIndex = -1 strNavigateLayerField = "" strNavigateLayerFieldVal = "" strNavigateLayerFieldDataType = "" ' Get info indicating the default map tool and map function for this map and whether specific ' Map Viewer functions are enabled for this map based on settings in the mapviewer.xml. strEnableLayers = "true" strEnableSearch = "false" strEnableLegend = "true" strEnableProperties = "true" strEnablePrint = "true" strEnableAddNewMap = "true" strEnableAbout = "true" sList = transformXMLfromFileWithParameters("xml\mapviewer.xml","xsl\mapviewerenablefunction.xsl",aMapParams) 'response.write sList 'response.end If (Len(sList) > 0) then aList = Split(sList,"|") strMapTool = aList(0) strMapOptionLevel1 = "none" strMapOptionLevel2 = aList(1) strMapOptionLevel3 = "none" strEnableLayers = aList(2) ' true or false strEnableSearch = aList(3) ' true of false strEnableLegend = aList(4) ' true of false strEnableProperties = aList(5) ' true of false strEnablePrint = aList(6) ' true of false strEnableAddNewMap = aList(7) ' true of false strEnableAbout = aList(8) ' true of false If Cbool(strEnableSearch) Then ' If Search (Find Feature) function is defined in mapviewer.xml, then set variable to enable function in client sList = transformXMLfromFileWithParameters("xml\mapviewer.xml","xsl\mapviewersearch.xsl",aMapParams) 'response.write sList 'response.end If (Len(sList) = 0) then strEnableSearch = "false" End If End If End If End Sub Function setActiveLayer(iLayerIndex, iLayerIndexPrev) ' Set active layer variables If (iLayerIndex = -1) Then ' no active layer: intActiveLayerIndexPrevious = -2 intActiveLayerIndex = -1 strActiveFclass = "" dblActiveMinScale = 0 dblActiveMaxScale = 0 strActiveFields = "" strActiveFieldsType = "" strActiveSortField = "" strActiveSortFieldDataType = "" strActiveSortFieldDataTypeSort = "" strActiveSortOrder = "ascending" strActiveLabelField = "" strActiveField = "" strActiveFieldVal = "" strActiveFieldDataType = "" strActiveOperator = "" strActiveLogicalOperator = "" strActiveFeatureLimit = "All" strActiveBeginRecord = "1" strActiveListBeginRecord = "1" dblActiveFilterMinX = 0 dblActiveFilterMinY = 0 dblActiveFilterMaxX = 0 dblActiveFilterMaxY = 0 intActiveFeatureCount = 0 Else ' active layer: intActiveLayerIndex = iLayerIndex intActiveLayerIndexPrevious = iLayerIndex aServiceLayerId = split(strServiceLayerId,"|") aServiceLayerType = split(strServiceLayerType,"|") aServiceLayerFclass = split(strServiceLayerFclass,"|") aServiceLayerRowId = split(strServiceLayerRowId,"|") aServiceLayerMinScale = split(strServiceLayerMinScale,"|") aServiceLayerMaxScale = split(strServiceLayerMaxScale,"|") ' Set feature type strActiveFclass = getLayerFclass(intActiveLayerIndex, aServiceLayerType, aServiceLayerFclass) ' Set Active Layer minscale and maxscale dblActiveMinScale = Cdbl(aServiceLayerMinScale(intActiveLayerIndex)) dblActiveMaxScale = Cdbl(aServiceLayerMaxScale(intActiveLayerIndex)) ' Get more information about the active layer strRequestAXL = getServiceInfoAXL("false","false","true","false") 'response.write strRequestAXL 'response.end call objArcIMSConnector.SendAxlRequest (strMapService, strRequestAXL) strResponseAXL = objArcIMSConnector.ResponseAXL 'response.write strResponseAXL 'response.end strActiveLayerId = aServiceLayerId(intActiveLayerIndex) Dim aActiveLayerIdParams(0) aActiveLayerIdParams(0) = Array("layerId",strActiveLayerId) ' Make list of fields in active layer strActiveFields = transformXMLWithParameters(strResponseAXL,"xsl\layerinfofieldname.xsl",aActiveLayerIdParams) strActiveFields = Left(strActiveFields,Len(strActiveFields) - 1) ' Make list of field types in active layer strActiveFieldsType = transformXMLWithParameters(strResponseAXL,"xsl\layerinfofieldtype.xsl",aActiveLayerIdParams) strActiveFieldsType = Left(strActiveFieldsType,Len(strActiveFieldsType) - 1) ' Set default sort field to be the row id field strActiveSortField = getLayerRowId(intActiveLayerIndex, aServiceLayerType, aServiceLayerRowId) ' Sorted fields can be queried by clicking on their values in the data table so ' get field type used to construct syntax for the query (number, text, date, boolean). strActiveSortFieldDataType = getFieldDataType(strActiveSortField,strActiveFields,strActiveFieldsType,strServiceType) ' Get data-type used for sorting values in stylesheet (number or text). strActiveSortFieldDataTypeSort = getFieldDataTypeSort(strActiveSortField,strActiveFields,strActiveFieldsType) ' Set default sort order strActiveSortOrder = "ascending" ' Set default label field to nothing (no features are labeled until user chooses label field) strActiveLabelField = "" ' Set other defaults If (iLayerIndexPrev <> -1) Then ' If iLayerIndexPrev = -1, then zooming to a feature listed in identify results so form element values ' such as strActiveField and strActiveFieldValue need to be preserved in order to switch to a different ' active layer without loosing the name of the rowid field and rowid value used to perform subsequent queries. ' This also happens when zooming to features in the Find Feature results list. Otherwise, initialize these ' values in situations when user simply changes active layer in the Layers form or when setting the default ' active layer for the map before features are selected by user. strActiveField = "" strActiveFieldVal = "" strActiveFieldDataType = "" strActiveOperator = "" strActiveLogicalOperator = "" End If strActiveFeatureLimit = "All" strActiveBeginRecord = "1" strActiveListBeginRecord = "1" dblActiveFilterMinX = 0 dblActiveFilterMinY = 0 dblActiveFilterMaxX = 0 dblActiveFilterMaxY = 0 intActiveFeatureCount = 0 ' Make the previous Layer Index equal to the current layer index in order to bypass the setActiveLayer function ' until they differ because changes layer that can be selected, user identifies and zooms to features in a different ' layer, or user finds features in a different layer and zooms to them. intActiveLayerIndexPrevious = intActiveLayerIndex End If End Function Function getIdentifyMinScale() ' Return Min Identify Scale Threshold among all layers that can be identified aLayersIdentify = split(strLayersIdentify,"|") aServiceLayerMinScale = split(strServiceLayerMinScale,"|") getIdentifyMinScale = 9999999999 For i = 0 to UBound(aLayersIdentify) If ( aLayersIdentify(i) = "true" ) Then If ( Cdbl(aServiceLayerMinScale(i)) < Cdbl(getIdentifyMinScale) ) Then getIdentifyMinScale = Cdbl(aServiceLayerMinScale(i)) End If End If Next If ( getIdentifyMinScale = 9999999999 ) Then getIdentifyMinScale = 0 End If End Function Function getIdentifyMaxScale() ' Return Max Identify Scale Threshold among all layers that can be identified aLayersIdentify = split(strLayersIdentify,"|") aServiceLayerMaxScale = split(strServiceLayerMaxScale,"|") getIdentifyMaxScale = 0 For i = 0 to UBound(aLayersIdentify) If ( aLayersIdentify(i) = "true" ) Then If ( Cdbl(aServiceLayerMaxScale(i)) > Cdbl(getIdentifyMaxScale) ) Then getIdentifyMaxScale = Cdbl(aServiceLayerMaxScale(i)) End If End If Next End Function Function getLayerIndex(sId, aId) ' Return Layer Index for specified Layer Id Dim i getLayerIndex = -1 For i = 0 to Ubound(aId) If (strComp(sId,aId(i),1) = 0) Then getLayerIndex = i End If Next End Function Function getLayerName(sId, aId, aName) ' Return Layer name for specified Layer Id Dim i getLayerName = "invalid" For i = 0 to Ubound(aId) If (strComp(sId,aId(i),1) = 0) Then getLayerName = aName(i) End If Next End Function Function getLayerFclass(iId, aType, aFclass) ' YES Return feature class for specified Layer Id Index Dim i getLayerFclass = "invalid" For i = 0 to Ubound(aType) If (strComp(iId,i,1) = 0) Then If (strComp("featureclass",aType(i),1) = 0) Then getLayerFclass = aFclass(i) End If End If Next End Function Function getLayerRowId(iId, aType, aRowId) ' Return row id for specified Layer Id Index Dim i getLayerRowId = "invalid" For i = 0 to Ubound(aType) If (strComp(iId,i,1) = 0) Then If (strComp("featureclass",aType(i),1) = 0) Then getLayerRowId = aRowId(i) End If End If Next End Function Function getFieldDataType(sField, sFields, sFieldTypes, sServiceType) ' Return general field type for specified field. Used to determine ' how to construct the QUERY Where clause in getFeaturesAXL() ' and getHighlightLayerAXL() Functions. Dim i, aFields, aFieldTypes, dblType aFields = split(sFields,"|") aFieldTypes = split(sFieldTypes,"|") getFieldDataType = "number" For i = 0 to Ubound(aFields) If (strComp(sField,aFields(i),1) = 0) Then dblType = Cdbl(aFieldTypes(i)) If ((dblType = 1) or (dblType = 12)) Then getFieldDataType = "text" Elseif (dblType = -7) Then If (strComp(sServiceType,"imagemapserver",1) = 0) Then getFieldDataType = "boolean" Else getFieldDataType = "number" End If Elseif (dblType = 91) Then getFieldDataType = "date" Elseif ((dblType = 13) or (dblType = 14) or (dblType = 15)) Then getFieldDataType = "other" End If End If Next End Function Function getFieldDataTypeSort(sField, sFields, sFieldTypes) ' Based on field type, specifies the value of the sortFieldDataTypeSort ' argument for the featureselect.xsl and featurefind.xsl stylesheets, ' indicating whether data-type values are "numeric" or "text". ' Dim i, aFields, aFieldTypes, dblType aFields = split(sFields,"|") aFieldTypes = split(sFieldTypes,"|") getFieldDataTypeSort = "number" For i = 0 to Ubound(aFields) If (strComp(sField,aFields(i),1) = 0) Then dblType = Cdbl(aFieldTypes(i)) If ((dblType = 1) or (dblType = 12)) Then getFieldDataTypeSort = "text" Elseif (dblType = -7) Then getFieldDataTypeSort = "text" Elseif (dblType = 91) Then getFieldDataTypeSort = "number" Elseif ((dblType = 13) or (dblType = 14) or (dblType = 15)) Then getFieldDataTypeSort = "text" End If End If Next End Function Function getRowIdField(sFields, sFieldTypes) ' Return row id field Dim i, aFields, aFieldTypes aFields = split(sFields,"|") aFieldTypes = split(sFieldTypes,"|") getRowIdField = "invalid" For i = 0 to Ubound(aFieldTypes) If (Cdbl(aFieldTypes(i)) = -99) Then getRowIdField = aFields(i) End If Next End Function Function getDateFieldList(sFields, sFieldTypes) ' Return a list of date fields, each one enclosed with []. ' For example, [DATE_PURCHASED] [DATE_SHIPPED] [DATE_DELIVERED]. ' Note, [] are appended to the begining and end of each date field name ' in order to make each one easily retrievable in the featurefind.xsl and ' featureselect.xsl stylesheets, which sets their css class to "mapDateField" ' so that the formatDates() onload JavaScript function can find these values ' in milliseconds and format them to a readable date such as "31 Dec 1901". Dim i, aFields, aFieldTypes aFields = split(sFields,"|") aFieldTypes = split(sFieldTypes,"|") getDateFieldList = "" For i = 0 to Ubound(aFieldTypes) If (Cdbl(aFieldTypes(i)) = 91) Then getDateFieldList = getDateFieldList & "[" & aFields(i) & "] " End If Next End Function Function getDateFormatForQuery(sDate,sServiceType) ' Return format for querying a date field in any type of layer in an imagemapserver ' or a personal geodatabase layer in an arcmapserver based map service. dim mDate mDate = CDbl(sDate) mDate = DateAdd("s", (mDate/1000), "01-Jan-70") Select Case sServiceType Case "imagemapserver" If (Cint(Year(mDate)) < 10) Then getDateFormatForQuery = "{ts '000" & Year(mDate) Elseif (Cint(Year(mDate)) < 100) Then getDateFormatForQuery = "{ts '00" & Year(mDate) Elseif (Cint(Year(mDate)) < 1000) Then getDateFormatForQuery = "{ts '0" & Year(mDate) Else getDateFormatForQuery = "{ts '" & Year(mDate) End If If (Cint(Month(mDate)) < 10) Then getDateFormatForQuery = getDateFormatForQuery & "-0" & Month(mDate) Else getDateFormatForQuery = getDateFormatForQuery & "-" & Month(mDate) End If If (Cint(Day(mDate)) < 10) Then getDateFormatForQuery = getDateFormatForQuery & "-0" & Day(mDate) & "'}" Else getDateFormatForQuery = getDateFormatForQuery & "-" & Day(mDate) & "'}" End If 'If (Cint(Hour(mDate)) < 10) Then 'getDateFormatForQuery = getDateFormatForQuery & " 0" & Hour(mDate) 'Else 'getDateFormatForQuery = getDateFormatForQuery & " " & Hour(mDate) 'End If 'If (Cint(Minute(mDate)) < 10) Then 'getDateFormatForQuery = getDateFormatForQuery & ":0" & Minute(mDate) 'Else 'getDateFormatForQuery = getDateFormatForQuery & ":" & Minute(mDate) 'End If 'If (Cint(Second(mDate)) < 10) Then 'getDateFormatForQuery = getDateFormatForQuery & ":0" & Second(mDate) & "'}" 'Else 'getDateFormatForQuery = getDateFormatForQuery & ":" & Second(mDate) & "'}" 'End If Case "arcmapserver" ' as getDateFormatForQuery = "#" & Year(mDate) If (Cint(Month(mDate)) < 10) Then getDateFormatForQuery = getDateFormatForQuery & "-0" & Month(mDate) Else getDateFormatForQuery = getDateFormatForQuery & "-" & Month(mDate) End If If (Cint(Day(mDate)) < 10) Then getDateFormatForQuery = getDateFormatForQuery & "-0" & Day(mDate) & "#" Else getDateFormatForQuery = getDateFormatForQuery & "-" & Day(mDate) & "#" End If End Select End Function Function getServiceInfoAXL(sDoEnv, sDoExt, sDoFld, sDoRnd) ' Return GET_SERVICE_INFO AXL Dim sAXL sAXL = "" sAXL = sAXL & "" sAXL = sAXL & "" sAXL = sAXL & "" sAXL = sAXL & "" sAXL = sAXL & "" getServiceInfoAXL = sAXL End Function %>