Follow

How can I create and edit a cartogram map in MapViewer via automation?

This article contains a sample script for creating a cartogram map and editing the methods and properties of the cartogram map.

To run this script:

  1. Copy the script below, or click here to download the BAS file: Create_Cartogram_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.
     

*********

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Create_Cartogram_Map.bas
' Copyright (C) Golden Software Inc. 1992-2015
'
' This script creates a Dorling cartogram and fills in
' the circles with a color.
'
' This script requires MapViewer 6 or later.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub Main
  Dim mvApp, plot, cartmap As Object
  Dim path As String

  ' Start MapViewer and create a pointer to the application object
  Set mvApp = CreateObject("MapViewer.Application")

  ' Make the application visible
  mvApp.Visible = True

  ' Create a plot document
  Set plot = mvApp.Documents.Add(DocType:=mvDocPlot)

  path = mvApp.ApplicationFolder & "samples\"

  ' Create cartogram map
  Set cartmap = plot.CreateCartogramMap ( BoundaryFileName := path & "AL2010.gsb", _
    DataFileName := path & "AL2010.dat", PIDCol := 1, VarCol := 7 )

  ' Fill the cartogram circles with blue
  cartmap.Fill.ForeColor = mvColorBabyBlue
  cartmap.Fill.Pattern = "solid"


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.