ImportTerritories method
Imports data that defines a set of territories as a DataSet object; similar to the Import Territories Wizard. Fails if the map already contains a DataSet object with a DataMapType property of geoDataMapTypeTerritory.
Applies to
Collections: DataSets
Syntax
Click a parameter to jump to its description below.
object .ImportTerritories(DataSourceMoniker, [ArrayOfFields], [Country], [Delimiter], [ImportFlags])
Parameters
Part | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
object | Required. An expression that returns a DataSets collection. | |||||||||||||||||||||||||||
DataSourceMoniker | Required String. File name to import. Can also provide information on which part of the file to import. See the DataSourceMoniker syntax topic for the correct syntax to use for this parameter. | |||||||||||||||||||||||||||
ArrayOfFields | Optional Variant. A two-column array:
The first column contains the field name or an integer representing the field index (which starts at 1) of each field to import. If a Field object is not listed in the array, then it is given a GeographicFieldType property of geoFieldSkipped. The second column designates one of three ways to treat the record: Use a GeoFieldType value of geoFieldTerritory, which MapPoint will use to determine the territory names. Use a string, which MapPoint will interpret as the field name for geoFieldData. Leave blank to have MapPoint determine the field's contents and title. If this parameter is not supplied, then all fields in the data source are imported. | |||||||||||||||||||||||||||
Country | Optional GeoCountry. Country associated with the data. Default is geoCountryDefault. See the GeoCountry values topic for a list of GeoCountry values and their descriptions. | |||||||||||||||||||||||||||
Delimiter | Optional GeoDelimiter. Characters that separate individual fields. Can be one or more characters. Required for importing text files. Default is geoDelimiterDefault.
| |||||||||||||||||||||||||||
ImportFlags | Optional Long. Provides information about the DataSourceMoniker and the data in the file. Multiple values can be passed by using the Visual Basic "Or" operator (for example, geoImportExcelNamedRange Or geoImportFirstRowIsNotHeadings ).
|
Remarks
To open the Import Territories Wizard for user input, use the ShowImportTerritoriesWizard method on the DataSets collection.
To learn more about mapping data, see the Getting started with data sets and data mapping reference topic.
For information on territories in MapPoint, see the About territories reference topic.
Example
Importing data from a spreadsheet
Sub CreateTerritoriesMap()
Dim objApp As New MapPoint.Application
objApp.Visible = True
objApp.UserControl = True
Dim szconn As String
Dim oDS As MapPoint.DataSet
With objApp.ActiveMap.DataSets
'Excel sheet
szconn = objApp.Path & "\Samples\Terrs.xls!Sheet1!A1:E127"
Set oDS = .ImportTerritories(szconn, , geoCountryUnitedStates, , geoImportExcelA1)
End With
End Sub
Using an Array
Sub CreateTerritoriesMap()
Dim objApp As New MapPoint.Application
objApp.Visible = True
objApp.UserControl = True
Dim szconn As String
Dim oDS As MapPoint.DataSet
Dim arArray(1 To 4, 1 To 2) As Variant
arArray(1, 1) = 2
arArray(1, 2) = geoFieldRegion2
arArray(2, 1) = 3
arArray(2, 2) = geoFieldRegion1
arArray(3, 1) = 4
arArray(3, 2) = geoFieldCountry
arArray(4, 1) = 5
arArray(4, 2) = geoFieldTerritory
With objApp.ActiveMap.DataSets
'Text file with tab and no headings
szconn = objApp.Path & "\Samples\Terrs.txt"
Set oDS = .ImportTerritories(szconn, arArray, geoCountryUnitedStates, geoDelimiterTab, geoImportFirstRowNotHeadings)
End With
End Sub
Note These samples are specific for use in MapPoint North America; they are for illustration purposes only.