Follow

How can I change my MapViewer choropleth (hatch) map to a base map using automation?

This article contains a sample script for creating a choropleth (hatch) map, changing some properties and adding a legend, and then switching to a bar map.

To run this script:

  1. Copy the script below, or click here to download the BAS file: Map.BAS.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\MapViewer 8\Scripter.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. 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.
  6. Click Script | Run to run the script.
     

*********

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Map.BAS
' Copyright (C) Golden Software Inc. 1992-2015
'
' This sample demonstrates how to create a map and switch map types.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub Main

   'Creates an instance of the MapViewer Application object
   ' and assigns it to the variable named "MapViewerApp"
   Set MapViewerApp = CreateObject("MapViewer.Application")

   'Makes the application main window visible
   MapViewerApp.Visible = True

   'Assigns the location of the samples folder to the variable "InPath"
   InPath$ = MapViewerApp.ModuleFolder + "samples\"

   'Creates a map document object, and assigns it to the variable named "doc"
   Set doc = MapViewerApp.Documents.Add(DocType:=mvDocPlot)

   'Assigns the layer object to the variable named "LayersObj"
   Set LayersObj = doc.Layers

   'Creates a hatch map object and assigns it to the variable named "HatchMap"
   Set HatchMap = doc.CreateHatchMap(InPath$ + "co2010.gsb", InPath$ + "co2010.dat", "", "", 1, 7, 5)

   'Changes the drawing type to square
   HatchMap.DrawType = mvHatchDrawSquare

   'Creates a legend for the map
   Set Legend = HatchMap.CreateLegend(-2,6)

   'Switches from hatch map to bar map
   Dim Variables(1 To 3) As Long
   Variables(1) = 7
   Variables(2) = 8
   Variables(3) = 9
   Set BarMap = doc.CreateBarMap(Variables,"", "", "", "", 1)

   'Shows proportional bar heights
   BarMap.Proportional = True

   'Changes to 3D bars
   BarMap.Bar3DFace = 1

End Sub

 

Updated November 2, 2016

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.