Extending the QueryAttributesTask to highlight selected features

Bryan Baker of the .NET SDK team wrote the following great post on extending a task to modify its behavior and then adding that task to the .NET Global Assembly Cache so it can be reused across applications. 

Note: Also see the follow-up to this post from May 3, 2007.

Highlighting all task results

 

With the Web ADF at 9.2, a website can have one or more tasks to allow users to find features or locations on the map. For example, you might add a QueryAttributesTask to the website to allow users to find cities by name, by typing the first few characters in the name.

 

The out-of-the-box tasks at 9.2 do not automatically highlight found features on the map. Instead, the user can highlight features by clicking individual check-boxes of features in the task results (see graphic, with two cities selected).

 

 

What if you want to have all features highlighted immediately when the task runs? There is currently no setting to enable this. But such immediate highlighting is possible through customization. Let’s look at one relatively easy approach for someone with modest programming skills. We’re looking specifically at the Web ADF for the Microsoft .NET Framework here, by the way.

 

We will extend a task control to modify its behavior. The object-oriented nature of .NET allows us to create a new class (a task, in this case) that inherits all of the behavior and properties of the original class. We only need to add or modify the original class where we need it to act differently from the original class (task). Some aspects of tasks may be difficult or impossible to change, but modifying the task results output is not difficult.

 

The approach we’ll look at can apply to any task that produces a task result in the form of a graphics layer, where users can click on feature check-boxes to highlight them on the map. This includes the SearchAttributesTask, FindAddressTask, FindPlaceTask and QueryAttributesTask. We’ll look specifically at the QueryAttributesTask in this example.

Extending an out-of-the-box task

 

First, I open Visual Studio 2005 and create a new project (not a new website), a Class Library project to be specific. One great thing about .NET is that even though the original class was written in C#, we can extend it in any language—we’ll use VB to show this here. We can put our new class library anywhere; it doesn’t have to go into a web folder. I’ll call my project QuerySelectTaskVB. By the way, we could also use either Visual Basic Express or Visual C# Express, but it’s more difficult to debug with a linked web application.

 

Visual Studio creates the project and adds a new class called Class1.vb. I right-clicked on it in the Solution Explorer and renamed it QuerySelectTaskVB. This also renames the class in the code view—nice.

 

We need to add some references to the project to the libraries we’ll be using. I right-click on the project in Solution Explorer, and chose Add Reference, and in the pop up dialog I select these libraries and then click OK:

  • ESRI.ArcGIS.ADF.Tasks
  • ESRI.ArcGIS.ADF.Web
  • ESRI.ArcGIS.ADF.Web.DataSources
  • ESRI.ArcGIS.ADF.Web.UI.WebControls
  • System.Web

 

To start creating our class, we add some Imports statements at the top of the class file so we can use classes without having to type the full path. We’ll also add a Namespace around our class to better identify it.

 

Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Data
Imports System.Web
imports System.Web.UI
Imports ESRI.ArcGIS.ADF.Tasks
Imports ESRI.ArcGIS.ADF.Web.Display.Graphics
Imports ESRI.ArcGIS.ADF.Web.UI.WebControls

 

Namespace QuerySelect
  Public Class QuerySelectTaskVB
  End Class
End Namespace

 

We tell the class to extend (inherit) the existing QueryAttributesTask by adding to the class declaration we’ve already created:

 

Public Class QuerySelectTaskVB
    Inherits QueryAttributesTask

End Class

 

The only thing we want to change in the task is how it outputs the results to the TaskResults control. The task creates this output in the standard task method called ExecuteTask(). We want the QueryAttributesTask to create its output as usual, but we will modify the results once they’re created. So we create our own version of ExecuteTask() that overrides the original. Our version will call the base (parent) class version of the method, then modify the results that have been created. The following code goes inside the Class definition we saw above:

 

    Public Overrides Sub ExecuteTask()
        ' QueryAttributesTask creates its results
  &nbs
p;    
MyBase.ExecuteTask()
        ' We'll modify the Results next
    End Sub

 

Once the parent class has run its ExecuteTask, we can modify the results. The results are stored in a task property object called Results (makes sense, eh?). If the query finds features, those get stored in Results as a standard .NET DataSet, which contains one or more DataTable objects. But if nothing was found, the Results contains a different type, a SimpleTaskResult. Also, if the map service isn’t working right, the results might have a DataSet, but the name (caption) just has an error message. Let’s make sure we have valid results:

 

        ' We'll modify the Results next
        ' Make sure features were found

        If TypeOf Results Is DataSet Then

            Dim resultsDS As DataSet = CType(Results, DataSet)
            ' Check for errors during query

            If resultsDS.DataSetName.IndexOf("Error") > 0 Then
               
Return
           
End If

             ' Next we can get the table of results
       
End If

 

Now we can get the table from the DataSet. With the QueryAttributesTask, only one DataTable will be in the DataSet (other tasks may have multiple tables). One more error check: after the task performs its query using the Web ADF common API, it converts the data table to a GraphicsLayer object, so that it contains rendering (symbology) information. If it had any problems making that conversion, then features can’t be selected on the map.

 

            ' Next we can get the table of results
           
' Get the one table in the QueryAttributesTask result
           
Dim resultsTable As DataTable = resultsDS.Tables(0)
 

            ' Make sure no problems creating a GraphicsLayer from the results
           
If resultsTable Is Nothing OrElse Not TypeOf resultsTable Is GraphicsLayer Then

                Return

            End If

            ' Now we can modify the table results

 

Now we can actually set the selection for the features found! The GraphicsLayer, which extends the DataTable type, will have a Boolean-type column indicating whether the row (map feature) is selected. We can get this column, and use it when looping through the features to set all features as selected:

 

            ' Now we can modify the table results
           
Dim graphicsLayer As GraphicsLayer = _
              CType
(resultsTable, GraphicsLayer)
 

            ' Get the column that holds the selection attribute
           
Dim selectedCol As DataColumn = graphicsLayer.IsSelectedColumn
 

            ' Set each feature to selected
           
For Each row As DataRow In graphicsLayer.Rows
                row(selectedCol) = True

            Next

 

That’s it! Now each feature will be selected in the TaskResults tree and also on the map….that is, once our task is inside a website, which we’ll show shortly.

 

We compile the code by choosing Build—Build Solution f
rom the menu (no errors, of course!). This puts a compiled .dll file into the Bin directory of the project (you can see that by looking at the project folder with Windows Explorer).

 

Adding the task to Visual Studio

The easiest way to add the task to a website is when it’s in the Visual Studio toolbox. It can be added manually to an individual website, but requires more editing of the source of the page. Let’s get the task into Visual Studio. There’s more on this in the Developer Help for ArcGIS Server and ArcIMS, so we’ll go over this quickly.

 

First, in the code for the task itself, we add some information so Visual Studio sets properties for task when we drag it onto the page from the toolbox. This goes just above the class declaration:

 

<ToolboxData("<{0}:QuerySelectTaskVB runat=""server"" Width=""200px"" Transparency=""35""" _

        + "BackColor=""White"" TitleBarColor=""WhiteSmoke"" TitleBarSeparatorLine=""False""" _

        + "TitleBarHeight=""20px"" BorderColor=""LightSteelBlue"" BorderStyle=”Outset”’ _

        + "BorderWidth=""1px"" Font-Names=""Verdana"" Font-Size=""8pt"" ForeColor=""Black"">" _

        + "</{0}: QuerySelectTaskVB >")> _

Public Class QuerySelectTaskVB

    Inherits QueryAttributesTask

 

Next we will add the task to .NET’s Global Assembly Cache. This makes it easier to add the task to various websites. Before we can do this, we must create a strong name to sign the task. We open the .NET command prompt and type:

 

sn –k QuerySelectVB.snk

 

This creates a key file (QuerySelectVB.snk) in the folder indicated by the command prompt (probably C:Program FilesMicrosoft Visual Studio 8SDKv2.0). I moved that file using Windows Explorer to the project directory where my task .vb file is located. I then added that to my project by right-clicking on the project in Visual Studio’s Solution Explorer, choosing Add-Existing Item, changing the type to All Files, and clicking on the .snk file. I used the keypair to sign the assembly by right-clicking on the project and choosing Properties. In the Properties page, I clicked the Signing tab. I checked the box Sign the assembly and clicked my .snk file in the drop-down list. Finally, I recompiled the code (Build-Build Solution).

 

Now we can add the task to the Global Assembly Cache. Here’s the easy way: I opened two Windows Explorer windows, one to my project folder’s bin directory where the .dll is located, the other to C:WindowsAssembly. I dragged the QuerySelectTaskVB.dll into the C:WindowsAssembly window. This doesn’t actually move the file. It just registers the assembly so it’s available to all applications on the system.

 

Finally let’s add the task to Visual Studio. Open Visual Studio and then any .aspx page (you can create a website and page if necessary). Open the toolbox if necessary. Right-click where you want to add the task and click Choose Items (you can also create a new tab with New Tab).  In the Choose Toolbox Items dialog, click Browse, and navigate to your DLL’s location. Highlight it and click Open. This adds the task to the list of available assemblies. Make sure its check box is checked, and click OK. This adds the task to the Visual Studio toolbox.

 

Now the task is available whenever you design an ASP.NET web page. Notice it has an icon—the same one as the QueryAttributesTask. It inherits this along with other properties of the parent task.

Using the custom task in a website

 

We can use the task in any website. I created a new website using the Web Mapping Application template. I could have added this website to the same solution as my task code if I’m using Visual Studio (useful for debugging the task), or in a new instance of Visual Studio. I could also open a website created with ArcGIS Server Manager or ArcIMS Web Manager, and add the task to it.

 

Once we have our web page open in Visual Studio, we can drag our new task from the toolbox into the Task Manager. Once it’s there, we can click its “smart tag” in its upper right to set the task’s properties.

 

 

 

Yet another great thing about extending an existing task: we get its designer tools with no coding required. We can set the Task Results container and use Edit the Query to create the query, exactly the same as with the standard QueryAttributesTask (see the Developer Help for tips on that).

 

The demo site for this page uses this custom task to query a water-well point layer for estimated yield. Choose a value from the drop-down list, and up to 50 features will be found. Notice that all features are immediately highlighted. Our custom task acts like the standard QueryAttributesTask, except that it highlights all features returned.

 

Try it out: http://serverx.esri.com/QuerySelectTaskDemo/.

Discussion

 

You can do other interesting things with the Results of the task. For instance, you could add a hyperlink to the task results output by adding the <a href…> tag to the DataSet’s DataSetName property, or to the DataTable.TableName. The hyperlink is displayed in the tree of the task results. You can also modify the DataTable itself, such as by hiding columns you don’t want displayed. Another example would be to display the results as a table, by creating a GridView from the DataTable and getting the HTML output from the GridView. You’d then create a new TaskResultsNode, add the output to that, and set it as the Results instead of the DataSet.

 

You might be tempted to customize other aspects of tasks, such as modifying
the task’s user interface. Although some customizations are possible, you’ll probably find that in many cases it would be easier to author your own task from scratch. The Developer Help has a good discussion of writing tasks, and the Web ADF has a couple of samples that can help get you started.

 

You might have noticed that the task user interface does not have the look-and-feel of other tasks—the colors, fonts, etc. The standard tasks have properties defined in the Theme of the website, specifically in the Default.skin file. If you want the same look-and-feel of the standard tasks, you can create your own control skin by copying properties from one of the standard tasks in Default.skin.

 

We haven’t discussed how to make our custom task available within Manager, so that non-programmers could use your task. This is a much more complex chore than adding the task to Visual Studio. Tasks are configured in Manager using a separate class called a web configurator. The standard task’s web configurators are hard-coded to output information specifically for that task. It is not possible to easily modify them to instead output tags and properties for tasks that extend them. It would be necessary to rewrite most or all of the web configurator in order for it to properly output your task from Manager. The Developer Help has information on writing web configurators, if you are ambitious.

 

Download the code for this sample:

 

 

 

Posted in Services | Tagged , , | 7 Comments

ArcGIS Server for the Microsoft .Net Framework 9.2 Service Pack 1

Anne Reuland of the Server Development team has contributed the following excellent detailed writeup on what is in service pack 1 for ArcGIS Server for the Microsoft .Net Framework 9.2.

 

There’s a very good overview of
what’s new in ArcGIS Server 9.2 on the ArcGIS
Server Product Documentation
page. Open the
Whats
New In ArcGIS Desktop 9.2
document; you’ll need to enter your ESRI global
account. The Table of Contents has a listing for ArcGIS Server and ArcIMS.

I’ve had several folks
ask for an overview on what’s included in our Service Pack 1 release.
The main purpose of the ArcGIS
Server for the Microsoft .Net Framework 9.2 Service Pack 1 release was to
address support issues with Internet Explorer 7. The problems we saw with ArcGIS
Server 9.2 Final and Internet Explorer 7 were display problems with the map or
Web Mapping Application related to certain tools and changes to the application
layout. We also found formatting problems with buttons and panels in the Web
Mapping Application, Manager, and several samples in our Software Developer Kit.
Here is the full list of bug fixes for Internet Explorer 7 support:

  • NIM005055 – Samples: In IE7, HTML buttons without a
    defined width will span the width of the browser.
  • NIM005056 – Samples: In IE7, resizable divs should not
    define a width or height.
  • NIM005539 – When using the Web Mapping Application in
    Internet Explorer 7, clicking the FullExtent or Magnifier tool causes the
    page to go blank.
  • NIM005540 – When using the Web Mapping Application in
    Internet Explorer 7, docking a floating panel causes the page to go blank.
  • NIM005564 – When running Manager in an Internet
    Explorer 7 browser, the Apply button on the Preview Layers tab may be
    partially obscured or missing completely.
  • NIM005565 – When running Manager in an Internet
    Explorer 7 browser, the ‘Preview Map Service’ panel is excessively wide.
  • NIM005566 – When running Manager in an Internet
    Explorer 7 browser and configuring a task, the message informing the user
    that a supporting service is required does not display.
  • NIM005567 – When running Manager in an Internet
    Explorer 7 browser and editing an existing application, the Configure
    button on the Tasks panel is partially obscured.
  • NIM005569 – After digitizing a new feature with the
    Geoprocessing Task in Internet Explorer 7, the Help button, Submit button
    and selection of features will not work until clicked twice.
  • NIM005602 – Visual Studio 2005 SDK help system
    displays with incorrect style and formatting when viewed on a machine
    with Internet Explorer 7 installed.

Once you install Service Pack 1,
newly created web applications will take advantage of these fixes for Internet
Explorer 7. If you have already built applications with Manager or the Web
Mapping Application template that you would like to update with these fixes, we
have written a migration utility that will make these changes to your Web
Mapping applications. You can download the migration
utility
from our support site.

 

We’re always looking to improve
performance for the web applications and web services. Jeremy has already
posted about the changes to with map cache image formats to support JGP, PNG8,
and PNG32. These changes allow you to choose the image format that works best
for your application’s functionality and performance needs. 

 

Other performance improvements made
at Service Pack 1 affect web service authentication and geocoding with ArcWeb
Services. In the Web Mapping Application, we made improvements on how fast the
map and task results are initialized. These bug fixes are:

  • NIM005590 – Improve Web services authentication
    performance.
  • NIM005598 – Optimize the display of task results when
    using ArcGIS Server Internet resources.
  • NIM005623 – Optimize initialization within the Map
    control
  • NIM005619 – Optimize geocoding with ArcWeb Services
    resources.  

When using caches map services, if
you have secured both your map service and the cache directories that hold your
map tiles, Service Pack 1 includes a fix to allow the Web Mapping Application
to access those secured tile directories without prompting the end-user of the
application for a username and password. Once a username and password has been
specified during creation of the Web Mapping Application, that account will be
used to access the secured map service and the secured tile directories. The
bug fix for this change is:

  • NIM005541 – Use the Identity information provided when
    defining a map resource to access cache directories that have
    been secured.

If you are using ArcWeb Services in
your Web Mapping Application, you may have been affected by this bug fixed at
Service Pack 1:

  • NIM005593 – ArcWeb services randomly return the error
    ‘The underlying connection was closed: A connection that was expected to
    be kept alive was closed by the server’.

We also fixed problems with some of
the query operators for the Query Attributes task at Service Pack 1. :

  • NIM005323 – Web applications containing a Query Task
    expression using either the < or <= operators will fail to build.
  • NIM005571 – Web applications published from Manager
    containing a Query Task expression using the LIKE operator do not return
    the correct results.
  • NIM005572 – Web applications containing a Query Task
    expression using the != operator do not return the correct results.

In the Web Mapping Application,
after running a task to get a list of results, the Zoom To option for point
features was not zooming in far enough. This problem was addressed at Service
Pack 1 by adding a property named ZoomToPointFactor to the Task Results control
to allow you to control the zooming:

  • NIM005594 – Add a ZoomToPointFactor property to the
    TaskResults control to specify the scale change when using the ZoomTo
    context menu option.

Also in the Web Mapping Application,
fixes were made to ensure the scale bar displays in the expected location:

  • NIM005622 – Fix cases where the Scalebar is displayed
    outside the Map control on initial startup of the Web Mapping
    Application.

You can get the full list
of issues
that were addressed on the Service Pack page.

 

Posted in Services | Tagged , | 1 Comment

ArcGIS Server Code Challenge

Hey everyone.  I hope to see you in Palm Springs at the 2007 ESRI Developer's Summit.

If you have not heard already, there is going to be an ArcGIS Server Code Challenge.  Give it a shot and let us know if you have any questions.

Share your development creativity and expertise
with the GIS developer community by submitting your original code sample to the
ArcGIS Server Code Challenge! 
You and your peers will have an opportunity to
review and vote for the top three entries based on originality, creativity,
applicability, and relevance of the code sample. Entries could include a simple
task or tool or an attribute or spatial query. 

Read more on the ArcGIS Server Code Challenge
 

Jeremy 

 

Posted in Services | Tagged | Leave a comment

Antialiasing with multiple cached resources

Combining multiple cached map services is one of the more powerful aspects of the ADF for ArcGIS Server.  High performance mapping applications can be built off of multiple fused cached map services combined within the ADF.  Lets build on the cached aerial photography example from the other day and add a cached dataset of a street network.  In order to get the best performance when combining cached datasets in the Web ADF for the Microsoft .NET Framework you need to ensure that your cache configurations are identical (same scales, projection, tile size, etc) and that the map services share similar dataframe extents.  When building a map cache you have the option of taking advantage of Antialiasing to smooth the edges of labels and lines for improved display quality).  Of course you want to have smooth lines and labels!  So what does antialiasing really do?  Let's look at some comparisons of similar tiles with and without antialiasing.

   

The image on the left is without antialiasing enabled.  The image to the right has been built using antialiasing.  See the difference?  The image with antialiasing of the 2000 Census Roadways dataset looks crisper, not as choppy.   Antialiasing is designed to minimize jagged, blocky aliasing when representing higher resolution data at a lower resolution.  So let's see what happens when we publish the data on top of our ortho cache…

 

 Wait a minute…where did my roads go?  Let's look at the same area without antialiasing…

 

 

That is what I get for implementing something without understanding the logic behind the process!  The way we have implemented antialiasing from ArcGIS server is to generate tiles four times as large as the specified tile size so that we can average the RGB color of the four pixels that intersect the feature or label.   So instead of a tiled pixel being completely black or not, it will be an average of the subpixels contained by the pixel.  What does it average if it is just a line that is either black or not black?  It uses the background color of the dataframe to compute the average pixel value.  The background color is used as the transparent color by cache generation process and if you don't set the background color of your map the default is to set the background equal to 253,253,253 or almost white.  So in my example I have ended up with gray roads (which don't show up well on a dark image) instead of what I originally designed as black roads.  If I rebuild my map cache of my road dataset with a background color set to an average color within the image of the ortho tile (RGB: 129,129,116–pulled from this slick freeware tool) I end up with a tile that looks like this…

  

 

Try the application with each of the antialiasing options here:   http://serverx.esri.com/antialiasingexamples/

Jeremy 

Posted in Services | Tagged , | 1 Comment

Embedding globe services within other globes

James posted a comment regarding publishing Globe services with other embedded Globe services.  This can be done, but it is not the recommended workflow.  Sterling from the Server Dev team wrote up this response.

 

As you create 3D views using ArcGIS Explorer and ArcGlobe, you may want to use a layer from someone else’s globe service in addition to your own. For example, you might want to get your base layers from an ArcGIS Online globe service, and your thematic layers from your own globe service.

Resist the temptation to create a new globe service that embeds one or more other globe services. Your client applications will perform better and you will avoid redundancy of caches on your server if you have the clients connect to the globe services directly. The workflow below explains how you can create an easily-distributable globe that will allow clients to connect directly to all of the globe services it contains. This example uses an ArcGIS Online service, but you could substitute any globe service that you might want to embed in your own globes:

  1. Create a new ArcGIS Explorer map (NMF) or ArcGlobe document (3DD) and add the ArcGIS Online service
  2. Add your local data to a separate ArcGlobe document and publish it as an ArcGIS Server globe service.
  3. Add your globe service to the ArcGIS Explorer map or ArcGlobe document that you created in Step 1.
  4. Distribute the ArcGIS Explorer map or ArcGlobe document. Optionally, you can publish the ArcGlobe document as a PMF file so that clients with ArcReader can view the globe. Both ArcGIS Explorer and ArcReader are available as free downloads from ESRI.


 

 

 

Posted in Services | Tagged , | Leave a comment

ArcGIS Server Service Pack 1

ArcGIS Server Service Pack 1 is out and available for download.  It has many fixes along with some very key enhancements.  One of the biggest enhancements is the ability to create map caches in different image type formats.  At 9.2 final you only had the option of creating PNG24 images for you map cache.  While PNG24 images are visually appealing and work well with images with a lot of vector data they are inefficient for continuous raster images like aerial photography or satellite imagery.  For example here are two tiles of orthophotography in both png (on the left) and jpeg (on the right):

PNG    JPG

 

The JPEG tile is 16.39kb.  The PNG tile is 85.93kb.  That makes the JPEG in this case 1/5 the size of the PNG.  While that does not really make that much difference while you are on an internal network, it makes a big difference for web applications.  It is important to note that JPEGs do not support transparency so PNG images would be ideal for map caches that need to be transparent (a roads cache on top of an ortho cache for example). 

Try out a demo here:  http://serverx.esri.com/dgaerialsws

This example uses 2 meter FSA NAIP color imagery and six inch black and white orthophotos courtesy of the City of Lawrence, Kansas

Jeremy 

 


 

Posted in Services | Tagged , , | 8 Comments

Using the Callback control framework with a map resource

Let's build on the sample that Ryan put together and use the callback control framework to refresh a map control.  In this case we need to send back callback results of the map control to the control being called back to (the callback button).  To illustrate this lets add a map, map control, and a couple of Callback Button controls to the map design time in Microsoft's Visual Studio 2005.  We want to give the user the ability to add and remove a dynamic dataset via the CallbackButtonCustomControl.
 

To do this we need a method that adds a dynamic resource to the MapResourceManagerInstance.
 

private void createAndAddResource(string resourceName, GISResourceItemDefinition definition, bool insertIntoBeginning)

    {

        MapResourceItem resourceItem = new MapResourceItem();

        resourceItem.Definition = definition;

        resourceItem.Name = resourceName;

        resourceItem.DisplaySettings = new ESRI.ArcGIS.ADF.Web.DisplaySettings();

        resourceItem.DisplaySettings.Visible = true;

        resourceItem.DisplaySettings.Transparency = 20;

        resourceItem.DisplaySettings.DisplayInTableOfContents = false;

        resourceItem.DisplaySettings.ImageDescriptor.TransparentBackground = true;

        resourceItem.DisplaySettings.ImageDescriptor.TransparentColor = System.Drawing.Color.FromArgb(1, 2, 3);

        if (insertIntoBeginning)

        {

            Map1.MapResourceManagerInstance.ResourceItems.Insert(0, resourceItem);

        }

        else

        {

            Map1.MapResourceManagerInstance.ResourceItems.Add(resourceItem);

        }

        resourceItem.CreateResource();

        Map1.InitializeFunctionalities();

    }

 

 

Within the CallbackButton1_Clicked event we call the method to create and display the dynamic resource and then use the callback control framework to pass the CallbackResults from the map to the control.
 

  string resourceName = "Dynamic Data";

        GISResourceItemDefinition definition = null;

        definition = new GISResourceItemDefinition();

        definition.ResourceDefinition = "(default)@DGCountyAerialPhotos";

        definition.DataSourceDefinition = "http://localhost/arcgis/services";

        definition.DataSourceType = "ArcGIS Server Internet";

        definition.DataSourceShared = true;

        createAndAddResource(resourceName, definition, false);

        if (Map1.ImageBlendingMode == ImageBlendingMode.WebTier)

        {

            Map1.Refresh();

        }

        else

        {

            Map1.RefreshResource(resourceName);

        }

        CallbackButton1.CallbackResults.CopyFrom(Map1.CallbackResults);

 

So now we can add dynamic data to a map on a callback.

Try the sample app out here:  http://serverx.esri.com/callbackbuttonsample/map.aspx 

Jeremy 

Posted in Services | Tagged , | 2 Comments

Using the Callback control framework

Ryan Olson of the Web ADF development team contributed the following code sample that demonstrates how to use the callback framework from within the ESRI Web ADF for the Microsoft .NET Framework. 

This control is very useful for testing things during the context of a callback.  When called, it fires a server-side event in the context of a page callback so that you can attach to that event at design time or programmatically and act on the event.  You can return "javascript" as the event argument to execute a JavaScript function or you can refresh the contents of a non-AJAX-enabled control (like the Gridview) without having to write a line of JavaScript.  

The code is extremely simple and yet it shows how to use the Web ADF CallbackResults and the WebControl base class Callback implementation.

 

Here is some sample code to execute some javascript

    protected void CallbackButton1_Clicked(object sender, EventArgs args)

    {

        CallbackButton1.CallbackResults.Add(new ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult(CallbackButton1, "javascript", "alert('hello');"));

    }

Here is some sample code to refresh a control that doesn’t inherit from our webcontrols with the CallbackButton (like a gridview):

    protected void CallbackButton1_Clicked(object sender, EventArgs args)

    {

        CallbackButton1.CallbackResults.Add(RefreshControlHtml(GridView1));

    }

    private CallbackResult RefreshControlHtml(Control control)

    {

        System.IO.StringWriter sw = new System.IO.StringWriter();

        HtmlTextWriter writer = new HtmlTextWriter(sw);

        control.RenderControl(writer);

        string htmlContent = sw.ToString();

        sw.Close();

        return new CallbackResult(control, "content", htmlContent);

    }

 

Try out a sample application illustrating the usage here:  http://serverx.esri.com/callbackbuttonSample/ 

 

Posted in Services | Tagged , | 2 Comments

Publishing globe services to enhance your ArcGIS Explorer base map

Sterling Quinn of the ArcGIS Server team contributed the following post.  The ability to publish data as a globe service and to have that data be consumed in a rich client like ArcGIS Explorer is very powerful.
 

As you work on projects with ArcGIS Explorer, you’ll probably want to improve the default image and terrain resolution to create a suitable base map for your area of interest. Globe services are an efficient way to get high-resolution imagery and terrain data to your Explorer maps.

 

If you’ve worked with ArcIMS and ArcGIS Server before, you’re probably familiar with map services, which are two-dimensional. A globe service is three-dimensional, and represents an ArcGlobe document that is being made available to network and Internet clients through an ArcGIS Server system. In fact, the default satellite image you see when you open Explorer is from a globe service hosted by ESRI.  

 

To create a globe service, you need ArcGlobe, some data, and ArcGIS Server. After you create the globe service, you can improve its performance by creating a globe cache. 

 

This example uses two globe services created from publicly-available data:

  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     

  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolutio
    n color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     

To create a globe service like the ones we’ve used in this example, you’ll need to do the following:

 

Add your data to an ArcGlobe document. Symbolize it just the way you want the clients of your globe service to see it. Save the globe document to a location that’s visible to all of the machines in your ArcGIS Server system. If you’re creating a globe service that will just provide elevation measurements, remove all other layers from your globe document.

 

Below are some views of the two globe documents that we'll publish as services to enhance our Explorer base map. The second view shows a wireframe because that service will contain elevation only.

 

 

 

 

 

Use ArcGIS Server to publish the globe document as a globe service. You can easily do this in ArcGIS Server Manage, or you can use ArcCatalog. If you need detailed instructions, consult the Globe Services topic in the ArcGIS Server Help: http://webhelp.esri.com/arcgisserver/9.2/dotNet/index.htm#manager/publishing/globe_service.htm

 

Create a globe cache for the service. A globe cache consists of pre-created globe tiles that exist on the server and can be distributed quickly to clients who request them.

 

When you display the globe service’s properties in ArcCatalog, there’s a Caching tab that contains the tools you need to create globe caches. It's not always practical to generate a full cache for all layers, but generating a cache for as many levels of detail as possible can improve performance for the first users that access the service. If you can’t create a full cache, the tiles that you do not create are created on demand as they are visited by clients. The map imagery cache in this example was cached from State (1:312500) to City Block (1:610) Note: Elevation globe services need the full cache built before you can use the service.

  

Once you’ve created the globe document, published the service, and created the cache, you can add the globe service to your Explorer maps. Below is what our image and elevation globe services look like in Explorer.

 

 

 

 

Of course, the power of Explorer lies in its ability to display your own data and perform GIS analysis on it. A high-resolution base map can enhance the effectiveness of your GIS work. Consider your impressions of the two screen captures below that overlay a geologic fault lines shapefile with the Explorer base map. The first image uses the original Explorer base map, while the second image uses the enhanced base map. Not only does our enhanced base map look more realistic, but specific buildings and streets crossed by the faults are more easily identifiable, providing for clearer analysis.

 

 

 

 

 

Try it out for yourself here:  http://serverx.esri.com/ArcGIS/explorer/maps/bountiful.nmf

 

What do you think?

 

 

Posted in Services | Tagged , | 1 Comment

Querying ArcGIS Server Web Services

One of the ways to connect to ArcGIS Server is through Web services.  When you make an Internet connection to the server, you will use a URL in this format:  http://<server name>/<instance name>/services 

This is an endpoint to your ArcGIS Server service catalog url. 

Where <server name> is the name of your server, which can be an IP address, a domain name (serverx.esri.com), or simply “localhost”.  The <instance name> is the name of your ArcGIS Server instance.  The instance gets defined when you install ArcGIS server.  You can review it by looking at server properties at your root folder in ArcCatalog.
 

So what can I do with this services catalog URL?  This URL can be used to establish an Internet connection to an ArcGIS Server instance in ArcCatalog.  It can be used as a connection in the ArcGIS Server Web ADF.  It can also be used in custom applications that work with Web services.  Today I am going to build a simple web application using the Microsoft .NET Framework in ASP.NET that consumes the catalog URL for my ArcGIS Server instance and lists the services, types, and service URL in a simple web page.

The first step after creating your new web site is to register the services catalog URL for your ArcGIS Server Web service.  To do this you need to add a web reference to your project (in VS2005 right click on the project name and Add Web Reference).  In the web reference dialog enter your server catalog URL. 


 

Once we have registered the Web service we just need to use it. 
 

//Create an instance of the service catalog web service

WebCatalog.Catalog webCat = new WebCatalog.Catalog();

//Set the url to your ArcGIS Server services url

String serverUrl = “http://localhost/arcgis/services”;

webCat.Url = serverUrl;

//Get the all the service descriptions from the Catalog

WebCatalog.ServiceDescription[] sds = webCat.GetServiceDescriptions();

//extract the name, type, and URL for each service in the

//servicedescriptions array

foreach (WebCatalog.ServiceDescription sd in sds)

{

  Response.Write(“<b>Service Name</b> = “ + sd.Name + “<br>”);

  Response.Write(“<b>Service Type = </b>” + sd.Type + “<br>”);

  Response.Write(“<b>Service URL  = </b>” + sd.Name + “<br>”);

  Response.Write(“<br><hr>”);

}

So try it out here:  http://serverx.esri.com/InterrorgateServer 

You can download the Visual Studio project here

Over the next few weeks I will explore working with the Web services for some of the ArcGIS Server service types (MapServer, GPServer).

Jeremy
 

 

 

Posted in Services | Tagged , , | 6 Comments