DensityMap Object Script Example

 

This script demonstrates all the properties in the DensityMap object.  If you wish to run the script, open Scripter and then open DensityMapObject.bas from the MapViewer 8 SAMPLES folder.

 

Sub Main

'Declare the variable that will reference MapViewer

 Dim mvapp As Object

 

'Creates an instance of the MapViewer Application object

'and assigns it to the variable named "mvapp"

 Set mvapp = CreateObject("MapViewer.Application")

 

'Make MapViewer visible

 mvapp.Visible = True

 

'Declare Plot as Object

 Dim Plot As Object

 

'Creates a new map window

 Set Plot = mvapp.Documents.Add(mvDocPlot)

 

'Declare DensityMap as object

 Dim DensityMap As Object

 

'Create a density map

 Set DensityMap= Plot.CreateDensityMap(BoundaryFileName:= _

 mvapp.ApplicationFolder + "\Samples\tx2010.gsb", DataFileName:= _

 mvapp.ApplicationFolder + "\Samples\tx2010.dat", _

 BoundaryFileOptions:="AreasToCurves=0", PIDCol:=1, VarCol:=3)

 

'=============================================================

' Density Map Properties

'=============================================================

'DiffPos Property

'----------------

'Return the DiffPos setting, true means the dots are randomly

'positioned each time the map is redrawn

 Debug.Print "Redraw points randomly? "; DensityMap.DiffPos

 

'Redraw dots in random positions each time the map is redrawn

 DensityMap.DiffPos=True

 

 

'DotSum Property

'---------------

'This example returns the dot sum value for a density map.

 Debug.Print "Dot sum value = "; DensityMap.DotSum

 

'This example sets the dot sum value to 250. Note that the

'Method property must be mvDensityMethodDotSum to use this value.

 DensityMap.Method = mvDensityMethodDotSum

 DensityMap.DotSum = 250

 

 

'DotValue Property

'-----------------

'This example returns the value for each symbol in a density map.

 Debug.Print "Dot value = "; DensityMap.DotValue

 

'This example sets the value for each symbol in a density map to 3500.

'Note that the Method property must be mvDensityMethodDotRatio to use

'this value. Some rounding will occur depending on data values.

 DensityMap.Method = mvDensityMethodDotRatio

 DensityMap.DotValue = 3500

 

 

'GlobalData Property

'-------------------

'This example returns the state of using global data.

 Debug.Print "Using global data? "; DensityMap.GlobalData

 

'This example shows how to use global data.

 DensityMap.GlobalData = True

 

 

'MaxDot Property

'---------------

'This example returns the maximum symbol value for a density map.

 Debug.Print "Maximum dot value = "; DensityMap.MaxDot

 

'This example sets the density map maximum symbol value to 3,000.

 DensityMap.MaxDot = 3000

 

 

'Method Property

'---------------

'This example returns the density map method.

 Debug.Print "Density map method = "; DensityMap.Method

 

'This example sets the density map method to dot sum.

 DensityMap.Method = mvDensityMethodDotSum

 

 

'PIDCol Property

'---------------

'This example returns the primary ID column.

 Debug.Print "Primary ID column (column A = 1) = "; DensityMap.PIDCol

 

'This example sets the primary ID column to column A.

 DensityMap.PIDCol = 1

 

 

'Symbol Property

'---------------

'This example changes the symbol outline color.

 DensityMap.Symbol.LineColor = mvColorBlue

 

 

'UseAbsoluteValue Property

'-------------------------

'This example returns the state of using absolute values.

 Debug.Print "Use absolute values? "; DensityMap.UseAbsoluteValue

 

'This example uses absolute values in a density map.

 DensityMap.UseAbsoluteValue = True

 

 

'VarCol Property

'---------------

'This example returns the variable column.

 Debug.Print "Variable column (column A = 1) = "; DensityMap.VarCol

 

'This example sets the variable column to column F.

 DensityMap.VarCol = 6

 

End Sub