KB no longer maintained - MapViewer is a Legacy Product. Legacy Products are still supported, but no longer receive new features or updates. Many of MapViewer's features have been moved to Surfer. Please contact support@goldensoftware.com with any questions. |
This article contains a sample script for creating a choropleth (hatch) map and editing the methods and properties of the hatch map.
To run this script:
- Copy the script below, or click here to download the BAS file: Create_Hatch_Map.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\MapViewer 8\Scripter.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
- Click Script | Run to run the script.
*********
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Create_Hatch_Map.BAS ' Copyright (C) Golden Software Inc. 1992-2015 ' ' This sample demonstrates how to create a hatch map and change the properties ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub Main 'Initializes and opens MapViewer Set mvApp = CreateObject("MapViewer.Application") mvApp.Visible = True InPath$ = mvApp.ApplicationFolder + "samples\" Set Plot = mvApp.Documents.Add(DocType:=mvDocPlot) 'Creates a hatch map object and assigns it to the variable named "HatchMap" Set HatchMap = Plot.CreateHatchMap(BoundaryFileName:=InPath$ + "co2010.gsb", _ DataFileName:=InPath$ + "co2010.dat", PIDCol:=1, VarCol:=7, NumClasses:=4) 'Loads a color spectrum for the background color HatchMap.BgColorSpectrum.LoadFromList("Forest") 'Set the diameter of the square HatchMap.CircleOrSquareWidth=0.5 'Changes the fill properties for class 1 in the hatch map HatchMap.ClassFill(iClass:=1).ForeColor = mvColorBlue HatchMap.ClassFill(iClass:=1).BackColor = mvColorYellow HatchMap.ClassFill(iClass:=1).Pattern = "Diagonal Cross" HatchMap.ClassFill(iClass:=1).Transparent = False 'Sets the data classification method to Equal Number. HatchMap.ClassificationMethod=mvClassificationEqualNumber 'Returns the index number of the All Others class Debug.Print "ClassIndexOfAllOthers = "+HatchMap.ClassIndexOfAllOthers 'Returns the index number of the No Data class Debug.Print "ClassIndexOfNoData = "+HatchMap.ClassIndexOfNoData 'Returns the maximum value of class 1 Debug.Print "Class 2 MinVal = "+HatchMap.ClassMaxVal(iClass:=2) 'Returns the minimum value of class 1 Debug.Print "Class 1 MinVal = "+HatchMap.ClassMinVal(iClass:=1) 'Sets the draw type of the hatch map to be a square HatchMap.DrawType = mvHatchDrawSquare 'Loads a color spectrum for the foreground color HatchMap.FgColorSpectrum.LoadFromList("Flame") 'Set the Pattern and Mode for all classes HatchMap.FillPatAndMode.Pattern = "Gravel" HatchMap.FillPatAndMode.Transparent = True 'Set the data limits to use Global Data HatchMap.GlobalData = True 'Returns the PID column of the worksheet. Debug.Print "PIDCol = "+HatchMap.PIDCol 'Sets the PID column of the worksheet to Column B. 'HatchMap.PIDCol = 2 'Returns the state of the User Limits checkbox Debug.Print "UserLimits = "+HatchMap.UserLimits 'Returns the User Limits max value Debug.Print "UserLimitMaxVal = "+HatchMap.UserLimitMaxVal 'Returns the User Limits min value Debug.Print "UserLimitMinVal = "+HatchMap.UserLimitMinVal 'Sets the variable coloumn of the worksheet to Column H HatchMap.VarCol= 6 'Interpolate all class fills between first and last color HatchMap.InterpolateHatchFills 'Adds a class color to the color spectrum and then interpolate all class fills HatchMap.ClassFill(iClass:=2).ForeColor = mvColorBlue HatchMap.InterpolateWithClassFill(2) 'Set the min and max values for class 1 HatchMap.SetClassMinMaxVals(1,400,4000) 'Set the User Limits state and specify the Min/Max values HatchMap.SetUserLimits(True,500,400000) 'Creates a legend for the map Set Legend = HatchMap.CreateLegend(-2,6) 'Adds HatchMap information in Layer #1 to legend HatchMap.AddLayerToLegend("Layer #1") End Sub
Updated November 2, 2016
Comments
0 comments
Please sign in to leave a comment.