How can I select one item from my base map and change the fill color using MapViewer automation?

This article contains a sample script for creating a base map and how to fill a selected item in the base map.

To run this script:

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


' Fill_Selected.BAS
' Copyright (C) Golden Software Inc. 1992-2018
' This sample demonstrates how to change select a polygon by PID and then
' assign a specific fill pattern to that polygon

Sub Main

   Set MapViewerApp = CreateObject("MapViewer.Application")
   MapViewerApp.Visible = True

   Set doc = MapViewerApp.Documents.Add(DocType:=mvDocPlot)

Dim area As Object
Set area = Doc.Layers(1).Shapes.Item("08059")
area.Fill.Pattern = "Crosshatch"
area.Fill.ForeColor = mvColorGreen

End Sub


Updated May 22, 2018

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


Please sign in to leave a comment.