All Blog Posts

Getting Started with ESRI’s ArcGIS Mapping Platform

In a previous article, I discussed some of the cool features in the Mortgage MarketSmart application. This is the first article in a series which discusses some of the things I learned using ArcGIS while building the Mortgage MarketSmart application.

Working with ArcGIS

The foundation of MMS is the maps served up by ArcGIS, which provides the means to store and deliver geographic information consumed by the MMS application. This information is delivered via map layers—each of which consists of three things:
  • Metadata – Information about the map layer and its contents.
  • Geography – The information needed to draw the map layer on a map (e.g. coordinates to draw a state).
  • Attributes – Each location included in a map layer includes one or more attributes. The attributes can be anything, but at a minimum should include a unique identifier (e.g. State Abbreviation) and friendly description (e.g. State Name).
Let's look at a quick example. This link is a map layer containing sample data about U.S. states. You will notice a few things about this map layer:
  • Extent – Where this map layer will be displayed on the map.
  • Drawing Info – Information about the renderer, which is essentially how the legend will be shown on the map.
  • Fields – The listing and definition of the attributes in the map layer.

Getting Data from a Map Layer

Let's dive in and get some data from the map layer via a query. Using the U.S. states map layer (the link above), scroll to the bottom of the page and click "Query" (or go here). You'll see a screen that allows you to create an ad-hoc query. Some fields of note:
  • Where – Use this field to filter the data. The format is very similar to that of SQL. Let's use: state_abbr = 'IA' as our filter. Note: state_abbr is one of the fields/attributes in the layer.
  • Out Fields – To see all of the fields, enter an asterisk *. You can limit the fields returned by entering a comma delimited list of fields (e.g. state_abbr,state_name)—a valid reason to know the fields.
  • Return Geometry – Try both true and false to see the differences in the returned data.
  • Format – For testing I use HTML, but in the application I use JSON. Try both to see the differences in the output.
Click the Query (get) button to view the results. Mortgage MarketSmart essentially uses the same query functionality when retrieving data from map layers, but does so programmatically.

Getting Metadata from a Map Layer

Knowing the fields and their data types in your application is essential. One easy way to get the field metadata (and all metadata for a map layer) is to call the map layer and append "?f=json" to the URL. This will return a JSON string of metadata about the application. Here is the URL for the U.S. states map layer:

I use this technique in Mortgage MarketSmart to dynamically store the list of fields available in a map layer. One use of this data is to populate a dropdown with the list of fields.

I found a powerful and easy way to consume the JSON returned—through the power of serialization. In my project I have defined the following classes, which I use to serialize the JSON string into these classes.

 ArcGIS Mapping Software

Now use the DataContractJsonSerializer class to serialize the JSON string to the MapLayerInfo class.

ArcGIS Mapping Software
Once the MapLayerInfo class is primed with the map layer information, I can use this throughout my application.

Performance Considerations When Retrieving Data from a Map Layer

It is important to make your application as efficient as possible. When working with maps, it is easy to be overwhelmed by the amount of data returned by a map layer. I have taken the approach of only asking for the data I need and nothing else. So what does that mean?
  • Outfields – Explicitly list only the fields you need when querying a map layer. At a minimum return the unique ID field so you can still uniquely define each location in the map layer.
  • Geometry – Don't return the geometry if you are just getting data from a map layer.
  • Feature Layers – Set Mode = FeatureLayer.QueryMode.OnDemand so data loads on demand. You only get data you need from the feature layer when you need it. For example, if I am zoomed into Iowa, I don't need to get the geometry data for the entire United States.
  • MaxAllowableOffset – Use this to control the accuracy/generalization of the geometry in a map layer. If you are zoomed out to a national level, the number of points needed to draw the shape of a state is significantly less than when you are zoomed in to a state level. MaxAllowableOffset allows you to control this. I have found that setting this to the map's Resolution works quite well. Learn more.
  • Query: OutSpatialReference – Typically you want to set this to the SpatialReference of your map. Learn more.
Use a tool like Fiddler to monitor traffic between your browser and the server. You'll get a good idea of how big your queries can become if you don't take performance into consideration. Users expect responsive applications!

Learning ArcGIS

The best way I found to learn about ArcGIS was to review the ArcGIS API for Silverlight Samples application, which provides a ton of samples and sample code to get an experienced developer off on the right foot. For non-Silverlight developers, have a look at the ArcGIS API for Javascript. Both APIs provide essentially the same set of functionality.

Knowing the basics of ArcGIS map layers allows us to create maps that are useful, powerful, and responsive. I will explore some other tips and tricks in upcoming blog posts.