阅读:1339回复:0
Example in Visual Basic
' This sample demonstrates the use of Datasets.Add and
' the RequestData ' event supported by MapX to build an unbound dataset, which ' allows MapX to access data whose format is known only to the ' programmer. In this example, the data is in the form of a ' two-dimensional array in VB. Private Const kNumberOfRows = 3 Dim theData(1 To 3, 1 To 2) As Variant Private Sub Form_Load() theData(1, 1) = "ME" ' Fill in the data to theData(2, 1) = "NH" ' be used by RequestData theData(3, 1) = "VT" theData(1, 2) = 100 theData(2, 2) = 200 theData(3, 2) = 300 Map1.ZoomTo 800, -70.26, 44.05 ' Zoom in on New England End Sub Private Sub Command1_Click() Dim flds As New MapXLib.Fields Dim ds As Dataset ' Describe the structure of the unbound dataset: flds.Add "State", "State", miAggregationIndividual,_ miTypeString flds.Add "Sales", "Sales", miAggregationSum, miTypeNumeric ' Create the unbound dataset. The "RequestData" event will be `triggered to get the data to be used. Set ds = Map1.Datasets.Add(miDatasetUnbound, Nothing, _ "My Dataset", "State", , "USA", flds) ' Create a theme based on the "Sales" column in the unbound dataset ds.Themes.Add miThemeGradSymbol, "Sales", "My Theme" End Sub Private Sub Map1_RequestData(ByVal DataSetName As String, _ ByVal Row As Long, ByVal Field As Integer, _ Value As Variant, Done As Boolean) Done = False If DataSetName <> "My Dataset" Or Row > kNumberOfRows Then Done = True Else Value = theData(Row, Field) End If End Sub |
|
|