Welcome to ESRI Blogs

New ESRI white paper discusses ArcGIS Server and virtualization

Virtualization, which allows multiple operating systems and applications to share the resources of a physical machine, is probably a word that you have heard. Many IT departments are adopting virtualization as part of a broader strategy to conserve resources and reduce costs. In fact, maybe you're already running ArcGIS Server on a virtualized environment.

We've recently released a brief white paper with a high level overview of what virtualization is, and why you may want to use it with ArcGIS Server. The paper addresses:

  • Benefits of virtualization
  • Available virtualization technologies
  • How ArcGIS Server supports virtualized environments
  • How ArcGIS Server performance is affected when running on a virtual machine
  • Major design factors for considering virtualization
  • Advantages of deploying ArcGIS Server in a virtualized environment

ArcGIS Server and Virtualization white paper (PDF)

Contributed by Ismael Chivite, ArcGIS Server Product Manager

Posted by sterlingdq | 1 Comments

Introducing the UserControlTask

With version 9.3.1 of the .NET Web ADF you can use the new UserControlTask to streamline the creation of your own custom tasks. Previously, you would need to create your own class that derived from FloatingPanelTask and take care of the creation and placement of your user interface controls, while paying particular attention to the page lifecycle events as they were raised. With the new UserControlTask, you can create your user interface interactively, in the design view of Visual Studio, and then simply assign a link to it using a property of the UserControlTask called TaskControl.

In Visual Studio, the first thing you'll want to do is right-click your project and choose "Add New Item..." from the menu. When the dialog appears, choose "Web User Control". This will create an empty template for your user control so that you can add whatever controls are necessary to your user interface. You will want to wire up any event handlers for the various user interface controls you added, and be sure to add a mechanism to start the execution of your task (typically a button).

Adding a UserControlTask to the page

In the code behind page for your control, you will need to make sure your class derives from the new ADF class called UserControlTaskPanel.

public partial class MyCustomTask : UserControlTaskPanel
{
    protected void btnExecute_Click(object sender, EventArgs e)
    {
        object[] input = new object[] { TextBox1.Text, DropDownList1.SelectedValue };
        this.Start(input);
    }

    public override object ExecuteTask(object input)
    {
        // Extract packaged parameters
        object[] parameters = (object[])input;

        string textBoxValue = (string)parameters[0];
        string selectedValue = (string)parameters[1];

        // Perform your task processing
        DateTime now = DateTime.Now;
        string heading = string.Format("The time on the server is {0}:{1:d2}:{2:d2}", 
            now.Hour, now.Minute, now.Second);
        string detail = string.Format("The value in the text box is {0} and the drop down list is {1}.", 
            textBoxValue, selectedValue);

        // Generate result packaged for task results control
        ESRI.ArcGIS.ADF.Web.UI.WebControls.SimpleTaskResult result = 
            new ESRI.ArcGIS.ADF.Web.UI.WebControls.SimpleTaskResult(heading, detail);
        return result;
    }
}

This will allow your code to access the Start method of the base class to begin execution of your task and supply input parameters to your task execution logic. You will need to extract applicable values from your user interface controls and package them as a single object to be used by your execution code. The final step is to implement the abstract ExecuteTask method. Here you will need to make use of the single input parameter object (which contains your packaged input values you passed into the Start method), execute your particular logic, and return a task result so that it can be displayed in a TaskResults control.

To test your task, you simply add a UserControlTask to your page (typically in a TaskManager control) and configure it appropriately. This includes assigning the TaskControl property to point to the location where your .ascx file is located, and likely assigning a value to the TaskResultsContainers property. When your application runs, your user interface should appear, collect user input, execute, and cause the task results to appear in the task results control.

For further reading, see the UserControlTask control overview in the .NET Web ADF Help.

Contributed by John Donahue of the ArcGIS Server .NET Web ADF development team.

Posted by sterlingdq | 1 Comments
Filed under: , ,

ESRI User Conference will feature a Virtual Map Gallery

This year at the ESRI International User Conference, the popular Map Gallery will include a new "Virtual Map Gallery" area featuring applications made with ESRI's Web mapping API's. Along with the traditional multimedia applications, the Virtual Map Gallery will include interactive Web mapping applications that users have created with the ArcGIS API’s for Flex, JavaScript, .NET, Java, and Silverlight/WPF.

At the Virtual Map Gallery you can navigate Web applications by themes, including the type of API used, the base map, and category of the application. You can also vote for your favorite application as part of the Map Gallery’s People's Choice contest.

If you are registered for the User Conference and have a web application you’d like to include, visit the Virtual Map Gallery Submissions page to submit your entry.

Contributed by Matthew Baker of ESRI Educational Services.

Posted by sterlingdq | 0 Comments

ArcGIS JavaScript API 1.4 released

Versions 1.4 of the ArcGIS JavaScript API and the ArcGIS JavaScript Extension for the Google Maps API have been released. Version 1.4 of the ArcGIS JavaScript Extension for Microsoft Virtual Earth will be available soon. (Update on June 12, 2009: The Virtual Earth extension is now available)

To use the new versions, just update your script reference with "v=1.4", for example: http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.4.

New features in the ArcGIS JavaScript API 1.4 include:

  • Routing with ArcGIS network analysis services
  • Support for Microsoft Virtual Earth maps and geocoding
  • Support for multiple graphics layers
  • Class breaks and unique value renderers
  • Support for Dojo 1.3.1
  • Performance improvements in Internet Explorer
  • Bug fixes

See What's New in Version 1.4 of the ArcGIS JavaScript API for a full list of improvements. There's also a What's New document for the Google Maps API extension. The principal new feature of the 1.4 ArcGIS JavaScript extensions for the Google Maps API and Virtual Earth is routing with ArcGIS network analysis services.

Posted by sterlingdq | 9 Comments
Filed under: ,

An easier way to zoom: A Dojo dijit that zooms to states and counties

This dijit zooms to states and counties. Click to try it.Dijits (Dojo widgets) have been a semi-regular topic on this blog and those posts helped me get up to speed on how to develop my own dijit for use with the ArcGIS JavaScript API. One requirement that has come up a couple of times when I've worked with the JavaScript API is the need to zoom to a state and/or county. Since I figured I'd continue to want this functionality in the future, it seemed like a good idea to spend a little extra time and put together a dijit that can be easily re-used in applications. You can preview what I came up with here: Zoom To State/County Dijit. This dijit is available for download on the Resource Center.

The UI component of the "ZoomTo" dijit is composed of a couple of other standard Dojo form dijits. It's making use of the drop down button (keeps the dijit’s footprint small) and filtering select (two actually, one for states and one for counties). On the back end, the dijit connects to two JSON files. Each JSON file has state or county names, FIPS codes and, most importantly, the extent for each state or county. When a selection is made, the dijit pulls the extent out of a JSON file and then passes it to map.setExtent() to zoom and pan the map to the correct location. The dijit also draws the extent as a graphic, fades the graphic out and removes it from the map's graphics layer as a visual cue to the user.

Some observant readers might be wondering about spatial references. They're taken into consideration too. The dijit will make sure it's sending an extent with the proper spatial reference to the map. The extents in the default JSON file provided are WGS84, but JSON files with extents in Web Mercator (WKID 102113) and NAD83 (WKID 4269) are also included in the dijit's data folder. It's up to you to specify a JSON file that matches the spatial reference of your map, but if the spatial reference of the map doesn't match what's in the JSON file, a request is sent to a geometry service to project the extent before sending it to the map. This is a quick operation and causes only a slight delay in the time it takes to zoom to a state or county.

Please be sure to go through the ReadMe.txt file in the dijit's zip file because some edits are required to get this running on your machine/server. Also, check out the comments in the ZoomTo.js file for more info on how the dijit works.

Contributed by Derek Swingley of the ESRI Applications Prototype team

Posted by sterlingdq | 3 Comments
Filed under: , ,

ArcGIS API for Flex 1.2 Released

Flex API supports multistop routing with barriersWe are pleased to announce the release of ArcGIS API for Flex 1.2. This May 2009 API release corresponds with the recent release of ArcGIS Server 9.3.1. However, the ArcGIS API for Flex 1.2 can also work with services from both ArcGIS Server 9.3 and 9.3 Service Pack 1.

This new version includes

  • Routing using ArcGIS Server 9.3.1.
  • Microsoft Virtual Earth mapping.
  • Microsoft Virtual Earth geocoding.
  • Renderers for simplified thematic mapping.
  • Utils package with useful utility classes for converting between geographic and web mercator projections, as well as an easy way to get the extent for an array of graphics.
  • New properties on TextSymbol to easily display the value of attributes as the actual text.
  • New styles on NavigationSlider to set how tall it should be or how many ticks it should show.
  • Nine new and 10+ updated samples.
  • Several bug fixes reported by users in the forums and through support channels.

You can see a full list of new functionality, changes and bug fixes in the What's New page in the online SDK.

Contributed by Bjorn Svensson of the ArcGIS API for Flex development team.

Posted by sterlingdq | 0 Comments
Filed under:

What's new in the 9.3.1 .NET Web ADF

Here's a brief look at what's new in the ArcGIS Server .NET Web ADF at 9.3.1. This information comes from the What's new in ArcGIS 9.3.1 PDF where you can read about new features in all areas of the product. If you have questions about any of the new features, please leave a comment to this post.

Customizing the look and feel of MapTips

The Web ADF JavaScript Library has been enhanced to provide greater control over customizing the look and feel of MapTips. New examples have been added to the MapTips sample that demonstrate how to leverage this new capability. In addition, a new MapTips custom control template is also available from the ArcGIS Server Resource Center .NET code gallery that enables drag-and-drop configuration of the new customization endpoints.

User control task

A new User Control task has been added to the available Web controls in the Web ADF. This new task is based on the User Control task sample available in the software developer kit (SDK). In addition, you can configure custom User Control tasks in ArcGIS Server Manager and include them in Web mapping applications.

Print task templates

In ArcGIS 9.3.1, a new property called LayoutTemplateFile is available that allows you to define the contents of your printed maps. This file, located at your Web site's default root directory/aspnet_client/ESRI/WebADF/PrintTaskLayoutTemplates/default.htm, is customizable.

The Print task will generate a map layout based on your template. By default, at 9.3.1, this new map template includes the map title, map, and legend information. Task results and copyright text can also be included in the printed map.

Posted by sterlingdq | 4 Comments
Filed under: , , ,

Questions and answers about ArcGIS Server 9.3.1 map services

In a previous post Design patterns for Web maps, we talked about strategies and challenges for displaying different types of map layers on the Web for the best performance. Caching is the fastest way to serve Web maps, but requires an initial time investment for cache creation. Also, datasets that change often and cover a broad extent cannot be cached and require a (typically slower) dynamically drawn service.

ArcGIS Server 9.3.1 addresses some of these performance challenges through a new drawing engine, developed for rendering ESRI map services as fast as possible. The faster dynamic drawing in 9.3.1 can speed up your dynamic map services that cannot be cached due to their oft-changing nature. It can also shorten the tile creation time for cached services.

All map services begin with a map document (MXD) that you create in ArcMap. A new toolbar in ArcMap, the Map Service Publishing Toolbar, does two things to help improve your map’s performance.

Map Service Publishing Toolbar

First, the toolbar helps you analyze your MXD for potential performance issues. At this stage you can identify bottlenecks that may not be directly related to the drawing engine. These could be things such as missing spatial and attribute indexes, or layers projecting on the fly.

Second, the toolbar gives you a way to create a map service definition (MSD), which is a new file type that works with the optimized drawing engine. The diagram below shows that either an MSD or an MXD can be published as a map service. In this post we’ll talk about when you would use each file type.

You can publish a map service from an MXD or MSD

The rest of this article answers common questions about the 9.3.1 MSD-based map service and its related functionality.

What aspects of drawing are improved with the MSD-based map service?

First of all, it’s faster. With MSD-based services, complex symbology does not impose the same performance burden that it does with MXD-based services. Your maps should draw at speeds comparable to or faster than similar ArcIMS maps.

MSD-based services also support anti-aliasing which smoothes the edges of lines and text. This is something that was previously available only in cached map services (with a significant performance cost during cache creation). Anti-aliasing with MSD-based services is available over a range of quality levels, allowing you to get the visual benefits while maintaining control over performance. You also have the option to apply the anti-aliasing to the text only.

The quality of map images return by the MSD-based service is also superior to previous versions. MSD-based services produce less “salt and pepper” dithering because the PNG 8 and GIF palettes are chosen using the 256 most frequently-used colors in the map. Also, with PNG 32 services, true transparent values are used in the anti-aliasing, which means you won’t see artifacts from the background color.

What is the MSD file and can I edit it?

The map service definition (MSD) file is a new file used by the fast map service drawing engine introduced at ArcGIS Server 9.3.1. The MSD file always starts with an MXD map document. You use the Map Service Publishing Toolbar to analyze your MXD in ArcMap. Once you’ve addressed issues returned by the analysis, you use the same toolbar to either publish the service or save the MSD file.

ArcGIS Server is the only application that can read the MSD file.

Where is the MSD file created when I publish a service from the Map Service Publishing Toolbar?

When you publish a service using the Map Service Publishing Toolbar, an MSD file is created in your ArcGIS Server input directory. This is a new directory at 9.3.1 that is registered with ArcGIS Server as the default location of your MSD files. In a one-machine deployment, it’s located by default at c:\arcgisserver\arcgisinput.

The toolbar also allows you to save your MSD file to other locations.

Do I need to be an administrator to publish map services with the Map Service Publishing Toolbar?

You need to be a member of the agsadmin group on the GIS server in order to publish map services from the Map Service Publishing Toolbar. If you’re not a member of agsadmin, you should save the MSD in a location where the server administrator can access and publish it.

If I make changes to the MXD, do I have to create the MSD again?

Yes. Once you save an MSD file, it is no longer connected with its parent MXD. If you edit the MXD, you need to use the Map Service Publishing Toolbar to save an updated MSD. Once you’ve overwritten the old MSD, restart the map service to register the changes.

What capabilities (server object extensions) are supported for MSD-based map services?

The WMS and KML capabilities are available with MSD-based services, as well as the default Mapping capability. Custom server object extensions can also work with MSD-based services but they cannot access fine-grained ArcObjects; they must use the coarse-grained methods on MapServer and its related classes.

At 9.3.1 can I still publish an MXD as a map service?

Yes. You can still publish an ArcMap document (MXD) as a service. The service will not use the new drawing engine introduced at 9.3.1; it will use the traditional drawing engine from ArcGIS Server versions 9.3 and previous.

Can I cache an MSD-based service?

Absolutely. Cache tiles get created more quickly with an MSD-based service. Also, anti-aliasing works better with caching when you use MSD-based services. The anti-aliasing occurs faster than it does with MXD-based services, and you can control the level of anti-aliasing on both features and text.

What layer types are supported by the MSD-based map service?

The MSD-based map service supports the most commonly-used feature layers and rasters. Exceptions, such as CAD layers or TINs, should be placed in a separate, MXD-based map service. The Map Service Publishing Toolbar will log errors for any layers in your map document that would prevent you from publishing an MSD-based service.

What else is available / not available in MSD-based services?

The ArcGIS Server 9.3.1 Help topic Supported functionality in MSD-based map services contains a full list of layers, symbology, and functionality available in MSD-based map services. All symbols are available with the exception of chart symbols, representations, and 3D symbols. The Maplex labeling engine is not available.

How am I supposed to use MSD-based services if Maplex isn’t supported?

Use annotation layers, which are supported in MSD-based map services. Annotation gives you the benefit of the Maplex label placement without the server having to make computationally intensive label placement decisions on every map request. Creating cache tiles from the annotated map will cause the service to run even faster.

If you can’t make annotation and you need Maplex, your next best option for performance is to create a cache from an MXD-based service.

When publishing raster datasets, should I use MSD-based map services or should I use the ArcGIS Server Image extension?

In most circumstances, it’s faster to serve rasters through the ArcGIS Server Image extension instead of through map services (whether cached or dynamic). A cached map service may be a more scalable solution if your service will receive many hits at once, but a cache requires creation and maintenance of tiles. MSD-based services will speed up the tile creation if you decide to use a cached service.

When should I use anti-aliasing?

Choose anti-aliasing when you are creating a production-quality map for an Internet audience. Anti-aliased images have become a standard for Web 2.0 map appearance.

Be aware that high levels of anti-aliasing can slow performance. Use the Preview button on the Map Service Publishing Toolbar to get an idea of the visual and performance effects of the anti-aliasing. If the dynamic anti-aliasing is not fast enough, you can lower the quality of the anti-aliasing or you may consider caching the service.

What licensing do I need in order to use the Map Service Publishing Toolbar?

The Map Service Publishing Toolbar is available at all license levels of ArcGIS Desktop (ArcView, ArcEditor, and ArcInfo). You can use the toolbar to analyze and improve the performance of your map documents even if you won’t be publishing an MSD-based map service.

Contributed by Ty Fitzpatrick and Sterling Quinn of the ESRI software development team

Posted by sterlingdq | 19 Comments
Filed under: , ,

Using detailed logging with ArcGIS Server 9.3

During the initial releases of ArcGIS Server, many users asked for fine-grained logging down to the layer draw level. This functionality was added to ArcGIS Server 9.3 as a new logging level Info:Detailed. The detailed logging is especially helpful when troubleshooting performance. In this post, we’ll consider the scenario that you have a map service that’s not drawing as fast as you’d like.

Here it’s worth noting that before you go to the logs, it may be easier to catch the problem using the popular mxdperfstat tool from ArcScripts or the “Analyze” button on the 9.3.1 Map Service Publishing Toolbar. As ArcGIS Server 9.3.1 becomes available in the next few weeks, we’ll be posting more information about the Map Service Publishing toolbar and how it can quickly point out areas for improvement in your map document. Version 9.3.1 also includes a faster drawing engine for map services that will help improve performance.

When you need more detail about what’s happening during a map draw, you can go to the log files and enable the new detailed logging. This is the workflow you’d follow:

  1. Set the log level to Info:Detailed. If you need help with this step, see Specifying the log file location (skip steps 3 and 4). While you’re looking at the log properties page, note the path to the log file and browse to the log directory in Windows Explorer so you don’t have to hunt around for the file later.
  2. Make a simple request to your map service by zooming or panning. Note the current time so you can find the request in the log.
  3. Examine the log that was created during your request and note the feature count and elapsed draw time of each layer. For this step sometimes it’s helpful to print the log and use a highlighter to note the draw times. You’ll immediately see which layers are taking the longest to draw. Also, keep an eye on the feature count to spot inefficient layers. A layer may take only 0.2 seconds to draw at a particular extent, but if the extent only included 2 features you may have a potential inefficiency.
  4. Repeat this process at several different locations and scales in your map. You want to make sure you analyze a good sample of the symbology and layers in your map.
  5. When you finish, set the log level back to Normal.

The Help topic Map service log codes contains a table of the codes you’ll see when analyzing the detailed logging. If you scroll down the topic you’ll also find an example of the codes returned from a simple ExportMapImage request like the one that happens when you zoom or pan the map.

To learn more about detailed logging and the different log levels, see How log files work.

Contributed by Sterling Quinn of the ArcGIS Server development team

Performance tips for Web applications

How do you get an ArcGIS Server application to run as fast as possible on the Web? This is one of the most common questions we receive, and at version 9.3 we added an ArcGIS Server help topic on this subject called Performance tips for web applications. We've been expanding this topic on the Web Help as we identify more ways to improve performance.

You also might be interested in Optimizing performance in Web ADF applications which deals specifically with .Net ADF development issues.

If you've gathered any ArcGIS Server performance tips from your experiences, please share them as a comment to this post.

Posted by sterlingdq | 4 Comments
Filed under: ,

Parallel processing with ArcGIS Server: A case study with geocoding

You're probably already familiar with creating Web applications and services with ArcGIS Server, but in this blog post we're going to talk about how you can use ArcGIS Server to run very large back-end jobs. We'll also do it in the context of geocoding, which is an aspect of ArcGIS Server that we haven't covered much in this blog yet. We hope this will get you excited about some new possibilities available through ArcGIS Server.

ArcGIS Server is an exceptional framework for running large jobs because it allows you to break them down into smaller chunks of work that can be run simultaneously. This way you can take full advantage of your hardware resources. A good example that you may already be familiar with is map caching. A map caching job is transparently split across all your Server Object Containers. By creatively using ArcGIS Server services, you can work in a similar manner with more specific jobs such as batch geocoding, generation of high quality map series, demographic analysis, simulation, and so on.

Today we'll illustrate this with geocoding, which is the process by which you associate X/Y coordinates with addresses or place names. Imagine that you have a list of 25 million addresses to geocode. How do you effectively run this job?

One idea is to create a geoprocessing service that takes a small subset of these addresses and puts the outputs in a common repository. Once the service is up, you can simultaneously send small chunks of addresses to the service, allowing the geocoding process to occur in parallel until you are done. You can use a simple Python script or executable to span the jobs on the server. A typical locator handles around 2 million addresses per hour per core on a 3Ghz server, so on an eight core server our 25 million addresses would be geocoded in a bit less than a couple of hours.

All right, that is way too much of a high level description! We put together a small document that will disclose how you do this with a practical example. The document is called ArcGIS Server in Practice Series: Large Batch Geocoding and it's available from the ArcGIS Server brochures and white papers page.

Posted by sterlingdq | 4 Comments

Code Assist for the ArcGIS JavaScript API: Aptana Studio plug-in

The ArcGIS JavaScript API provides classes to deliver rich mapping functionality to your applications. The Resource Center has a wealth of information about these classes, their properties and methods. When building your applications, you want this information easily accessible from within your IDE. If you've spent a lot of time creating web mapping applications with the ArcGIS JavaScript API, you've probably been missing this for a while now. Yesterday we uploaded to the Code Gallery a plug-in that provides code assistance for the ArcGIS JavaScript API in the Aptana Studio IDE. The plug-in provides the following context-sensitive information:

  • Auto-completion of source code
  • Summary of classes, constructors, properties, methods and globals
  • Parameter hints for constructors and methods

Example of assistance from plug-in 

 Example of assistance from plug-in

We believe the plug-in will greatly enhance your development experience with the ArcGIS JavaScript API. Moving forward, we intend to provide updates to this plug-in whenever a new version of the API is released. We are also working towards providing IntelliSense bits for Visual Studio. As always, we welcome your feedback.

Contributed by Praveen Ponnusamy of the ArcGIS JavaScript API development team

ArcGIS API for Silverlight/WPF public beta, media galleries released

Try the public beta of the ArcGIS API for Microsoft Silverlight/WPFExciting things are happening on the eve of the 2009 ESRI Developer Summit! Today the ArcGIS API for Microsoft Silverlight/WPF went into a public beta. This API allows you to build interactive Internet and desktop GIS applications using Microsoft's Silverlight and Windows Presentation Foundation (WPF) technologies.

Try out the beta API using the online SDK, where you'll find samples, introductory help, and an API reference. There's also a Silverlight/WPF Code Gallery that already contains a Flickr mashup you can try.

If you encounter a bug when working with the beta, or if you just have a suggestion for improving the usability of the API, please report it to the ArcGIS API for Silverlight forum or the ArcGIS API for WPF forum. We look forward to hearing your feedback as we move the API toward its official release.

The Silverlight/WPF API wasn't the only addition to the ArcGIS Resource Centers today. You may have also noticed some new "Media Gallery" pages in the online SDKs. These contain videos and other presentations to help you learn the APIs using a variety of media. Visit this post on the ArcObjects Development Blog to learn more about the media galleries and how to access them.

Happy coding, and best wishes for your travels if you're joining us in Palm Springs next week!

Contributed by the ArcGIS Server software development team
Posted by sterlingdq | 1 Comments
Filed under: , ,

Creating a reusable task-oriented dijit

In a previous blog post, we learned how to create a simple dijit with the ArcGIS JavaScript API that combines a map with a couple of buttons and an image. Today's post will show how to create a sophisticated task-oriented dijit, which we have uploaded to the ArcGIS JavaScript API Code Gallery. The dijit encapsulates the IdentifyTask to let users identify features on the map and visualize them.

Layout

First, let's look at the layout for this dijit. It consists of a border container with five regions(content panes): top, bottom, left, right and center, laid out in "Headline" pattern. For a detailed account on how to use the border container, read this blog post.

The top region is the the title bar for this dijit with icons, the whole left region is a button to navigate to the list of identified features, and the center region is the body of this dijit. The center region has a stack container that includes three pages (content panes) but shows only one at a time (see screenshots below). The first page contains a grid to display the list of identified features, the second page contains a grid to display the attribute fields, and the third page shows various options.

identify-dijit-features.png
Features
identify-dijit-attributes.png
Attributes
identify-dijit-options.png
Options


Easy to add

As a developer, you can use this dijit to easily add an identify tool to your map. All you need to do is pass a reference to the map when instantiating the dijit and it will let the users identify features on all the map services added as layers to the map. To use the dijit, just click the map to see the list of features identified at that location. Click a feature to see all the attribute field values associated with it. The dijit also has an "Options" panel where end users can select the map services and adjust the tolerance.

Try it live

Customizable

That was quick and easy! But what if you want to customize it? For example, what if you want to

  • Identify features on selected map services and layers within each map service
  • Provide a user-friendly name for a layer
  • Show user-friendly field aliases instead of field names
  • Change the field that determines the title of the features
  • Limit which attributes are shown

You can do all of the above by passing appropriate parameters to the dijit when instantiating it. Documentation for these parameters is available as part of the Code Gallery download, but you can take a quick look here. You can also change the look and feel by modifying the CSS file associated with the dijit.

Try it live

An interesting thing to note about this dijit is that it behaves like an info window. That is, it is associated with a specific location on the map and remains as such when you pan or zoom. It is also possible to detach the dijit from the map and move it anywhere within the page so that the map area is uncluttered. Note, however, that it does not replace the info window that is available out of the box with the ArcGIS JavaScript API. The functionality in this dijit is implemented as a separate dojo class, packaged in a module and imported into the dijit using the dojo.require statement. Documentation for this functionality is available here.

Finally, we recommend that you keep in mind the following points when creating your own dijit:

  • Design the dijit in such a way that it is customizable and reusable as much as possible so that other developers in your organization can easily adapt it for their applications without diving too often into the code.
  • Keep an eye out for functionality that can be spun off into separate modules and reused in other projects.
  • Maintain user documentation for all your dijits and modules.

Related links

Writing your own widget
Lifecycle of a dijit
BorderContainer
StackContainer
ContentPane

Contributed by Praveen Ponnusamy of the ArcGIS JavaScript API development team

Posted by sterlingdq | 2 Comments
Filed under: , , ,

Extending tiled layers in the ArcGIS API for Flex

The ArcGIS API for Flex supports access to layer types not included with the API. Depending on what you are trying to connect to (or do), you might want to extend TiledMapServiceLayer, DynamicMapServiceLayer or Layer.

  • Extend DynamicMapServiceLayer if you want to connect to a service that returns one complete image, usually created on the fly (for example, WMS).
  • Extend TiledMapServiceLayer if you want to connect to some system of (usually pre-created and cached) tiles (for example, an ArcGIS Server virtual cache directory). This is especially useful if you want to access 9.2 services, since 9.2 doesn't have REST support and thus isn't supported using the out-of-the-box ArcGIS API for Flex.

Today I will show how to create an example application that extends TiledMapServiceLayer to access tiles created in either ArcGIS 9.2 or 9.3 and which have been made available on the Web server (usually /arcgiscache/).

 Example Flex application that extends TiledMapServiceLayer

Extending TiledMapServiceLayer follows the same inheritance as the out-of-the-box ArcGISTiledMapServiceLayer.

In Flex API: ArcGISTiledMapServiceLayer -> TiledMapServiceLayer -> Layer -> mx.core.UIComponent

This sample: PortlandTiledMapServiceLayer -> TiledMapServiceLayer -> Layer -> mx.core.UIComponent

For simplicity, in this sample, we will hard-code configuration settings such as extents and spatial reference. This is a little different from the out-of-the-box ArcGIS layers which retrieve these settings from the REST Services Directory.

Tutorial

This tutorial shows how to extend tiled layers in the ArcGIS API for Flex to support tiles available outside the REST endpoint. The live application and its source code are also available.

Follow these three steps in Flex Builder:

  1. Create new ActionScript class to extend the TiledMapServiceLayer class
    • Add a new ActionScript class
    • Set the package to "com.esri.ags.samples"
    • Set the name to "PortlandTiledMapServiceLayer"
    • Set the superclass to "com.esri.ags.layers.TiledMapServiceLayer"
    • Click Finish
    This will create PortlandTiledMapServiceLayer.as in com/esri/ags/samples/.
  2. Edit the new PortlandTiledMapServiceLayer class
    • Override the required TiledMapServiceLayer functions, fullExtent() and tileInfo() and have them return the specified values, for example:
      override public function get fullExtent():Extent
      {
      return new Extent(-123.596895130725,
      44.297575737946,
      -121.553757125519,
      46.3683237161949,
      new SpatialReference(4326));
      }
    • Override the TiledMapServiceLayer getTileURL() function to give us the appropriate tiles and have the map place them in the right place.
      private var _baseURL:String = "http://sampleserver1.arcgisonline.com/arcgiscache/Portland_Portland_ESRI_LandBase_AGO/Portland/_alllayers";
      override protected function getTileURL(level:Number, row:Number, col:Number):URLRequest
      {
      var url:String = _baseURL
      + "/L" + padString(String(level), 2, "0")
      + "/R" + padString(row.toString(16), 8, "0")
      + "/C" + padString(col.toString(16), 8, "0") + ".jpg";
      return new URLRequest(url);
      }
    • Inside the public function PortlandTiledMapServiceLayer(), add
      buildTileInfo(); // to create our hardcoded tileInfo
      setLoaded(true); // Map will only use loaded layers
    • Optionally, as a best practice, similarly override the following properties from the Layer class: initialExtent, spatialReference and units. This is needed if this is the first layer added to the map and the map property hasn't been set yet. For example:
      override public function get initialExtent():Extent
      {
      return new Extent(-122.539, 45.500, -122.540, 45.501, new SpatialReference(4326));
      }
  3. Use it with either MXML or ActionScript.
    <esri:Map id="myMap">
    <samples:PortlandTiledMapServiceLayer id="virtualTiles" fadeInFrameCount="15"/>
    </esri:Map>
    or actionscript
    var myMap:Map = new Map;
    this.addChild(myMap);
    var myLayer:PortlandTiledMapServiceLayer = new PortlandTiledMapServiceLayer();
    myMap.addLayer(myLayer);

Note: If the web server hosting the tile images doesn't have a crossdomain file your application will still work, but while developing you will see a warning ("Warning: Failed to load policy file"), as well as security sandbox violations for each tile.

Resources

This shows how easy it is to extend a layer to add support for additional types of layers within the ArcGIS API for Flex.

Contributed by Bjorn Svensson of the ArcGIS API for Flex team.

More Posts Next page »