Understanding Data Binding in Dundas Map
In Dundas Map, shapes, paths, symbols and groups (collectively, "content elements") can all be given custom columns of data. For example, you can add fields such as population, area, or abbreviation to your shapes, or length or road type to your paths, etc. You can set elements' Text or Tooltip properties to include the field (e.g. "Population: #POPULATION") or use the field in a shape rule or other element-rule. For more information on fields, have a look at the articles "Shape Fields", "Path Fields", "Symbol Fields", and/or "Group Fields" in our documentation.
Data binding can be used to add symbols to your map, or to add field data to existing shapes, paths, symbols, and groups. Paths and Shapes cannot be added using data-binding, as they are made of a set—often a large set—of connected points and segments, and there is no general way to store this information in a database.
Your data source can be a DataTable, DataSet, DataView, BindingSource, or any instance of a class that implements IEnumerable, IDbCommand, or IDbAdapter.
There are two ways to data bind: the DataBind[Elements]() methods and data binding rules.
- Call the method, passing the data source, data member, and field names as arguments. (The dataMember argument is only needed for multi-member data sources, for example to specify the name of the table to use in a DataSet.)
this.mapControl1.DataBindShapes(dataSet, "US_REGIONS", "SUB_REGION");
this.mapControl1.DataBindSymbols(dataSet.Tables, "", "State_Capital_City", "", "X", "Y");
Me.mapControl1.DataBindShapes(dataSet, "US_REGIONS", "SUB_REGION")
Me.mapControl1.DataBindSymbols(dataSet.Tables(0), "", "State_Capital_City", "", "X", "Y")
Data Binding Rules:
- Set the MapControl.DataSource property to your data source
- Create a new data binding rule object
- Set the BindingField property on your binding rule
- Set the DataMember property if needed
- On a SymbolDataBindingRule, set any fields containing data that you want bound to your symbols' properties
- Add the rule to the DataBindingRules collection
- If you want to force data binding to happen before the control is next rendered, call the MapControl.DataBind() method (optional)
// Set the dataset as the data source for the Map control
this.mapControl1.DataSource = dataSet;
// Create a new group data binding
GroupDataBindingRule dataBinding = new GroupDataBindingRule();
dataBinding.DataMember = "US_REGIONS";
dataBinding.BindingField = "RegionName";
' Set the dataset as the data source for the Map control
Me.mapControl1.DataSource = dataSet
' Create a new group data binding
Dim dataBinding As GroupDataBindingRule = New GroupDataBindingRule()
dataBinding.DataMember = "US_REGIONS"
dataBinding.BindingField = "RegionName"
To add symbols using data binding:
- Set BindingField to the column of your data source that you want to use to name your symbols
- Set the XCoordinateField and YCoordinateField of the DataBindSymbols() method or SymbolDataBindingRule object to the columns that store your X and Y coordinates
- You can optionally provide fields to bind Category and ParentShape property values.
To add field data to existing content elements:
- Use a data source with a column of names that match the names of your existing elements. Use this column as your BindingField column. (Alternatively, use a column with values that match the existing field data of any field that has its UniqueIdentifier property set to true.)
- All remaining columns of your data source will be added as new fields for your elements.
For more information and examples, see the article "Binding to Data Sources" in our documentation.