PDA

View Full Version : Using ImportData and DisplayDataMap - Part 2 of 3 - Introducing DisplayDataMap



Richard Marsden
12-12-2011, 11:01 AM
DisplayDataMap

DisplayDataMap is where things can become more difficult. This method is used to display a dataset. It is a complicated method with lots of parameters. It is easy to make a mistake with the parameters, and all parameter errors result in an un-informative “The parameter is incorrect” error. It is therefore recommended that you start with a working example (e.g. from this article), and adjust it step-by-step until it does what you require. Diagnostics such as the field loop in the above code sample, can also help.

The following code samples can all be inserted in the sample above where the comment “(data plotting code goes here)” appears.

Before describing all the parameters, let’s start with an example. The following code plots the sales data as Sized Pie Charts:


// These are the (1-ref) indexes for the fields we are plotting
object ourSalesIDX = 4;
object compASalesIDX = 5;
object compBSalesIDX = 6;

// Use these indexes to create an array of data fields to plot
datafields = new object[3];
datafields[0] = ds.Fields.get_Item(ref ourSalesIDX);
datafields[1] = ds.Fields.get_Item(ref compASalesIDX);
datafields[2] = ds.Fields.get_Item(ref compBSalesIDX);

Console.WriteLine("fields created");

// change the dataset into Sized Pie Chart map
datamap = ds.DisplayDataMap(MapPoint.GeoDataMapType.geoDataM apTypeSizedPie,
datafields,
MapPoint.GeoShowDataBy.geoShowByRegion1,
MapPoint.GeoCombineDataBy.geoCombineByNone,
MapPoint.GeoDataRangeType.geoRangeTypeDefault,
MapPoint.GeoDataRangeOrder.geoRangeOrderDefault,
6,
3,
missing,missing,missing,missing,missing);

datamap.LegendTitle = "Sales by State";

This is what the resulting map looks like:

http://www.mp2kmag.com/images/articles/winwaed/displaydatamap_01_sm.jpg (http://www.mp2kmag.com/images/articles/winwaed/displaydatamap_01_bg.png)

There are potentially a lot of parameters but in this example we leave most of them as their defaults. Most of the other parameters are enumerations which define how the geographic data is displayed and grouped.

The most complex parameter in this example is the second one, datafields. This lists the data field or fields which will be plotted. Specify a MapPoint Field object (for one data field – e.g. in a shaded area map), or as in this example, an array of MapPoint Field objects to specify multiple data fields. The Field objects are queried using Fields.get_Item. Note that this uses 1-referenced indices.

All of the parameters are technically optional, although it is generally a good idea to explicitly specify many of them. .NET’s interface to COM requires all ‘missing’ optional parameters to be passed as System.Reflection.Missing.Value. All of the code in these examples use a variable called missing which is set to System.Reflection.Missing.Value.

Many of the parameters are enumerations and the full set of values for these enumerations can be found in the MapPoint documentation.

Continue Reading http://www.mapforums.com/using-importdata-displaydatamap-part-3-3-displaydatamap-parameters-18539.html