Monday, June 1, 2009

ArcGIS Server Sample Flex Viewer: Adding ArcIMS Image Map Service Support

Adding ArcIMS image map service support to the Sample Flex Viewer (SFV) is rather simple and handy for those of you who might have loads of legacy services that might not make the AGS migration any time soon. It is simply a matter of extending the ConfigManager class and MapManager class. You will then need to make a slight modification to any ArcIMS elements in the config.xml file.



Extend the ConfigManager class by adding the following:



//map

var configMap:Array = [];

var mapserviceList:XMLList = configXML..mapservice;

for (i = 0; i < mapserviceList.length(); i++)

{



var msLabel:String = mapserviceList[i].@label;

var msType:String = mapserviceList[i].@type;

var msVisible:Boolean = true;

if (mapserviceList[i].@visible == "false")

msVisible = false;

var msAlpha:Number = 1;

if (!isNaN(mapserviceList[i].@alpha))

msAlpha = Number(mapserviceList[i].@alpha);


//retrieve newly added arcims service host attribute from map service entry

var msHost:String = mapserviceList[i].@host;

var msURL:String = mapserviceList[i];


var mapservice:Object =

{



label: msLabel,

type: msType,

visible: msVisible,

alpha: msAlpha,

url: msURL,



//add newly added host attribute to mapservice object for ArcIMS Map Services

host: msHost



}


configMap.push(mapservice);



}


Continue by extending the MapManager class as follows:


for (i = 0; i < configData.configMap.length; i++)

{



var label:String = configData.configMap[i].label;

var type:String = configData.configMap[i].type;

var url:String = configData.configMap[i].url;

var visible:Boolean = configData.configMap[i].visible;

var alpha:Number = Number(configData.configMap[i].alpha);



//new variable for collecting host attribute for arcims services

var host:String = configData.configMap[i].host;



switch (type.toLowerCase())

{



case "tiled":

{



var tiledlayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer(url);

tiledlayer.id = label;

tiledlayer.visible = visible;

tiledlayer.alpha = alpha;

map.addLayer(tiledlayer);

break;



}

case "dynamic":

{



var dynlayer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(url);

dynlayer.id = label;

dynlayer.visible = visible;

dynlayer.alpha = alpha;

map.addLayer(dynlayer);

break;



}

case "arcims":

{



var arcimslayer:ArcIMSMapServiceLayer = new ArcIMSMapServiceLayer(host,url)

arcimslayer.id = label;

arcimslayer.visible = visible;

arcimslayer.alpha = alpha;

arcimslayer.imageFormat = "jpg"

map.addLayer(arcimslayer);

break;



}



}

}

The entry for the config.xml file would then be something like this:

<mapservice label="2008 Province 31 Assessment" type="arcims" visible="false" alpha="0.7" host="http://certmapper.cr.usgs.gov">prov31_2000</mapservice>

where the value of the element is the map service name. One thing to keep in mind with this is that some of the FLEX api features are not supported for ArcIMS image map services including the identify task. There is also some info on this in the ESRI user forums that may also be helpful.



No comments: