FLEX api for ArcGIS Server released
"Develop rich internet applications with ArcGIS services using the Flex framework. The API enables creating applications with intuitive, visually rich and responsive user interface. The ArcGIS API for Flex takes full advantage of the powerful mapping, geocoding, and geoprocessing capabilities of ArcGIS services."
Check it out here
Simple ArcGIS Server Layer list - Pure Javascript Example
Check it out here:
http://maps.roktech.net/demo/layerlist_js.html
Creating a Simple Layer List With The ArcGIS Server Javascript / REST api
In my example, I use Coldfusion, but you could easily adapt this to your langauge of choice. Actually, you could do this with pure javascript, but using something like Coldfusion just makes sense to me - as you will see from this example. Also, lets be clear - I am terrible with javascript - and I'll be the first to admit that. However, there are thousands and thousands of examples out there to help you along.
I'll show you the important parts here, but essentially its broken down into 3 parts. 1. Make a simple REST call to get a list of all the layers in the map service 2. Loop over the results to display the Layer name and a simple check box (with a onclick event) 3. Create the javascript that turns on and off the layers and then refreshes the map
The simple REST call:
are comfortable with. Coldfusion I find to be the most straightforward. --->
<cfset esri = createObject("component","esri")>
<cfset LayerInfo = esri.ServiceInfo('http://snake/ArcGIS/rest/services/pickenscounty/MapServer?f=json')>
<!--- Create the initial list of layers that should be turned on --->
<cfset LayerVisible = ''>
<cfloop query="LayerInfo">
<cfif DEFAULTVISIBILITY eq 'YES'>
<cfset LayerVisible = listAppend(LayerVisible,#ID#)>
</cfif>
</cfloop>
Now display the results of the REST call:
<input type="checkbox" id="#id#" onclick="toggleDynamicVisibility(#id#);"<cfif DEFAULTVISIBILITY eq 'YES'>checked</cfif>>#Name#<br>
</cfoutput>
Lastly, add some javascript functions that will keep track of the layers to turn on and off and then refresh the map:
//I am using a coldfusion variable to populate this array. again, any language can be used here. var dynamiclayerlist = new Array(#LayerVisible#);
function removeItems(array, item) {
var i = 0;
while (i < array.length) {
if (array[i] == item) {
array.splice(i, 1);
} else {
i++;
}
}
return array;
}
function addItems(array, item) {
array.push(item);
}
function toggleDynamicVisibility(layerid) {
if (dynamiclayerlist.indexOf(layerid) != -1){
removeItems(dynamiclayerlist,layerid);
}else{
addItems(dynamiclayerlist,layerid);
}
dynamiclayer.setVisibleLayers([dynamiclayerlist]);
}
</script>
Note that when I make the REST call, I am using a Coldfusion component (CFC). I have included that cfc in the code download (see below for the link or get it here). So, hopefully when you see the finished code you see just how easy it really is.
This simple demo is available to actually try and view here: http://maps.roktech.net/demo/layerlist.cfm. Hopefully I can get some kind of regular series of simple ArcGIS Server javascript and REST api demos going...
The unexpected surprise...
For you ArcIMS veterans, you know that it can be very, er, temperamental at times. If you are responsible for a high volume site, you dont just know it, you live it. You've written scripts to start and stop it. You've written scripts to ping your mapserver. You can refresh your services via the cmd line. You have full logging on more than you'd like too. Heck we have a utility that we wrote to send us a text message if a service comes back as unresponsive.
I really wasnt looking forward to the management of a production ArcGIS server. We have been using it since its inception at version 9, and have always found it to be temperamental as well. However, with the advent of the REST api (plus its Javascript wrapper), and the extensive use of tile caching, we have found an most unexpected benefit. ArcGIS Server, when utilizing REST & JS, is very easy to manage. No more corrupted sez files. No more runaway aimserver.exe's. Strange. I'm not used to it yet.
Of course, there are some obvious reasons for this - which I would say is mainly due to heavy use of caches and client side code. Granted, these apps are simple in comparison (lets say vs a heavy duty ArcIMS site). My hope is that as these new API's continue to evolve and our apps increase in complexity, that the management of the server remains to be straightforward as it is now.
Installing the WMS Connector with Coldfusion, Jrun, and Tomcat
Step 1:
If you already have ArcIMS installed, uninstall it.
Step 2:
Follow the instructions located here. An important piece of the instructions from that link that is misleading comes in to play when you are installing Tomcat. It says you can install it to C:\Program Files\Apache Software Foundation\Tomcat 5.5 or C:\Tomcat5.5. I highly recommend installing to C:\Tomcat5.5, I was unable to get the redirect working with it installed to C:\Program Files\Apache Software Foundation\Tomcat 5.5. When installing ArcIMS: at the Web Server-Servlet Engine Configuration dialog box, select 'IIS with Tomcat 5.5'. You will still need to follow the instructions for configuring CF and ArcIMS, found here. This is so CF and ArcIMS can still communicate.
Step 3:
Now we need to test to see if the WMS connector is configured correctly. http://
ArcGIS Server 9.3 WebADF
To start off, I created a standard out of the box application via Visual Studio. The first change I noticed was in the MapResourceManager. There is a new section called LayerDefintions.
The LayerDefinitions section is a very helpful addition. It lets you choose symbology for search and identify results. In addition, it lets you fully customize the attribute table that is returned with the results. By the way, the attribute results are now displayed like map tips for points, lines, and polygons.
Next I wanted to take a look at performance. From a quick test, the application seemed to load faster than 9.2. The page_load event is called on 4 times in the initial startup, which is better than the 6 to 8 times I have seen in 9.2 As the map is loading, a progress bar has been added to map which is much better than waiting on a blank white map.
Here are a few very noticeable changes in the Web Mapping Application: - Task Items are displayed across the top of the map where the standard toolbar used to be. (Visually, I like the change. However, I can see this becoming a problem if you have a lot of tasks or tasks with long names)
- The standard toolbar is now positioned on the right side above the map.
- The ZoomLevel control is now visible even with non-cached maps and is displayed above the map with the Navigation control.
- The overview map has been added to the standard toolbar and can be turned on and off.
- There are zoom to previous and zoom forward extent buttons on the standard toolbar
I am very eager to see how much effort will go into migrating my customized 9.2 applications to 9.3.
Trent Tinker
GIS Application Developer
ROK Technologies