Follow

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

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

To run this script:

  1. Copy the script below, or click here to download the BAS file: Create_Pin_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_Pin_Map.BAS
' Copyright (C) Golden Software Inc. 1992-2015
'
' This sample demonstrates how to create a pin 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 base map object and assigns it to the variable named "BaseMap"
	Set BaseMap = Plot.CreateBaseMap(InPath$+"us50alb.gsb")

'Creates a pin map object and assigns it to the variable named "PinMap"
	Set PinMap = Plot.CreatePinMap(DataFileName:=InPath$+"uscity.xls", _
		LocatingMethod:=mvPinLocCoordinates, XCol:=2, YCol:=3 )

'Appends a pin map To an existing image.
	PinMap.Append = True

'Sets the data class column to 2
	PinMap.ClassCol=2

'Sets the pin method to bin the classes from values in the class column
	PinMap.PinMethod=mvPinMethodBinClass

'Sets the number of classes for the pin map
	PinMap.NumClasses=3

'Returns the maximum value of Class 1
	Debug.Print "Class 1 MaxVal = "+PinMap.ClassMaxVal(1)

'Returns the minimum value of Class 1
	Debug.Print "Class 2 MaxVal = "+PinMap.ClassMinVal(2)

'Sets the Class Method for the pin map
	PinMap.ClassMethod = mvClassificationUserDefined

'Sets the properties for the symbol of class 1
	PinMap.ClassSymbol(1).FillColor=mvColorRed
	PinMap.ClassSymbol(1).Index=24
	PinMap.ClassSymbol(1).LineColor=mvColorPurple
	PinMap.ClassSymbol(1).Set="GSI Default Symbols"
	PinMap.ClassSymbol(1).Size=0.3

'Shows the labels on the pins
	PinMap.ShowLabel=True

'Sets the label angle in degrees
	PinMap.LabelAngle=45

'Sets the label column of the worksheet.
	PinMap.LabelCol=1

'Sets the font properties for the labels
	PinMap.LabelFont.BackColor=mvColorPowderBlue
	PinMap.LabelFont.Background=True
	PinMap.LabelFont.Bold=True
	PinMap.LabelFont.Face="Arial"
	PinMap.LabelFont.ForeColor=mvColorBlack
	PinMap.LabelFont.HAlign=mvTACenter
	PinMap.LabelFont.Italic=True
	PinMap.LabelFont.Size=10
	PinMap.LabelFont.StrikeThrough=False
	PinMap.LabelFont.Underline=True
	PinMap.LabelFont.VAlign=mvTAVCenter

'Sets the label format properties
	PinMap.LabelFormat.AbsoluteValue = True
	PinMap.LabelFormat.NumDigits=4
	PinMap.LabelFormat.Postfix=""
	PinMap.LabelFormat.Prefix="City Name= "
	PinMap.LabelFormat.Thousands=True
	PinMap.LabelFormat.Type = mvLabFixed

'Sets the label position offset type
	PinMap.LabelPosOffsetType=mvPosOffsetUser

'Sets the Label position X offset.
	PinMap.LabelPosXOffset=0.01

'Sets the Label position Y offset.
	PinMap.LabelPosYOffset=-0.16

'Sets the state using other location file
	PinMap.OtherLocation=False

'Sets the PID column of the worksheet
	PinMap.PIDCol=2

'Sets the symbol angle in degrees.
	PinMap.SymbolAngle=45

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.