Programming MapPoint in .NET

3.1. Understanding the MapPoint 2004 Data API

In MapPoint 2004, both business data and demographic data are represented using the DataSet class. An active Map object exposes the DataSets collection, which you use to access a valid DataSet object. How does a DataSets collection get its data wrapped as a DataSet object? The DataSets collection is different from traditional .NET collectionsit not only exposes a collection of DataSet objects, but it also offers methods to import external data and to access MapPoint 2004 demographic data.

A DataSet object is similar to a data table with rows and columns and regular querying capabilities. However, a DataSet object allows you to query the records or data rows based on location information. Each query results in a Recordset object containing the records that satisfy the location-based query. The DataSet object can also be used to display data on maps. In essence, if you are using any data features (such as data maps, territories, etc.) in MapPoint 2004 APIs, the DataSet class is the root for all these tasks; Figure 3-1 shows the relationships between an active Map object, a DataSets collection, a DataSet object, and a Recordset object.

Figure 3-1. MapPoint 2004 data-related API object model

It is important to note that the DataSet and RecordSet objects shown in the MapPoint object model are different from the Dataset and RecordSet classes defined in the System.Data namespace in the .NET Framework.

Tables 3-1 and 3-2 show some of the key methods exposed on the DataSet and RecordSet objects.

Table 3-1. Key Methods in the DataSet object

Method Name

Description

DisplayDataMap

Displays a set of data on a map

QueryAllRecords

Returns all records in a DataSet as a RecordSet object

QueryShape

Returns records that fall within a specified shape on the map as a RecordSet object

ZoomTo

Zooms to the best map view of the specified DataSet object

Table 3-2. Key methods in the RecordSet object

Method Name

Description

MoveFirst

Sets the current record of the RecordSet to the first record

MoveNext

Sets the current record of the RecordSet to the next record

With this introduction, let's look at specifics of dealing with visualization of data using MapPoint 2004.

Категории