Follow

How to create a hatch map in MapViewer Scripter from a user-specified boundary file and customize it

This article contains a sample script for creating a hatch map from a user-specified boundary file, adding a legend, and adding the current date.

 

To run this script:

  1. Copy the text below, from the Sub Main start line to the End Sub end line, or click here to download the BAS file: Add Legend_Date.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.

*************

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Add Legend_Data.BAS
' Copyright (C) Golden Software Inc. 1992-2015
'
' This script demonstrates how to add a legend and insert the date into
' the lengend title
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

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

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

    'Prompts user for boundary file and assigns it to the variable named
    '"BoundaryFile"
    BoundaryFile = GetFilePath(,"gsb",,"Specify Map Boundary File")

    'Prompts user for data file and assigns it to the variable named "DataFile"
    DataFile = GetFilePath(,"dat",,"Specify Data Boundary File")

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

    'Assigns the current layer to the variable named "HatchLayer"
    Set HatchLayer = Plot.Layers.ActiveLayer

    'Creates a hatch map object and assigns it to the variable named "HatchMap"
    'If you're not using the 2010 county GSB and DAT files from Samples, update the
    ' PID and Variable columns
    Set HatchMap = Plot.CreateHatchMap(BoundaryFileName:=BoundaryFile, _
        DataFileName:=DataFile, PIDCol:=1, VarCol:=6, NumClasses:=4)

    'Add a Legend To the Map, Including the current Date
    Set Legend = HatchMap.AddLayerToLegend("Layer #1")

    'Set the date equal to the variable "CurrentDate"
    CurrentDate = Str(Date)

    'Create a Title for the Legend, including the date
    Legend.title("Layer #1") = "Map Report for:  " + CurrentDate

    'Position Legend on Page
    Legend.left=9
    Legend.top=2

    'Close current map window and saves the map as a GSM file with the current
    'data as the file name
    'Plot.Close(SaveChanges:=3)
End Sub

 

Updated: September 17, 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.