Professional Documents
Culture Documents
Programmer's
Reference
The information contained in this document is the exclusive property of Environmental Systems
Research Institute, Inc. This work is protected under United States copyright law and the copyright laws
of the given countries of origin and applicable international laws, treaties, and/or conventions. No part
of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical,
including photocopying or recording, or by any information storage or retrieval system, except as
expressly permitted in writing by Environmental Systems Research Institute, Inc. All requests should be
sent to Attention: Contracts Manager, Environmental Systems Research Institute, Inc., 380 New York
Street, Redlands, CA 92373-8100 USA.
Any software, documentation, and/or data delivered hereunder is subject to the terms of the License
Agreement. In no event shall the U.S. Government acquire greater than RESTRICTED/LIMITED
RIGHTS. At a minimum, use, duplication, or disclosure by the U.S. Government is subject to restric-
tions as set forth in FAR 52.227-14 Alternates I, II, and III (JUN 1987); FAR 52.227-19 (JUN 1987)
and/or FAR 12.211/12.212 (Commercial Technical Data/Computer Software); and DFARS 252.227-
7015 (NOV 1995) (Technical Data) and/or DFARS 227.7202 (Computer Software), as applicable.
Contractor/Manufacturer is Environmental Systems Research Institute, Inc., 380 New York Street,
Redlands, CA 92373-8100 USA.
ESRI, MapObjects, ARC/INFO, and ArcView are trademarks of Environmental Systems Research
Institute, Inc., registered in the United States and certain other countries; registration is pending in the
European Community. Spatial Database Engine, SDE, the ArcView GIS logo, GIS by ESRI, the
MapObjects logo, and the ESRI globe logo are trademarks and www.esri.com is a service mark of
Environmental Systems Research Institute, Inc. Other companies and products mentioned herein are
trademarks or registered trademarks of their respective trademark owners.
The material in this book reflects the information available at the time of publication and is
essentially identical to the information contained in the MapObjects online help. In some
cases, more up-to-date information may be available in the online help.
Contents
Add Method 18
AddEvent Method 19
AddGeoDataset Method 21
AddIndex Method 25
AddNew Method 29
AddressLocation Object 30
AddRelate Method 30
AfterLayerDraw Event 34
AfterTrackingLayerDraw Event 34
Alignment Constants 36
AllowDuplicates Property 36
AllowSharing Property 39
Appearance Constants 40
Appearance Property 41
Area Property 41
AreaOfInterest Property 42
AutoFlush Property 43
Axis Property 46
BackColor Property 47
BackgroundRenderer Property 48
BarHeight Property 52
BarWidth Property 53
BatchMatch Method 54
BatchMatchVariableField Property 60
BeforeLayerDraw Event 60
BeforeTrackingLayerDraw Event 62
BorderStyle Property 63
Bottom Property 64
Break Property 66
BreakCount Property 68
Buffer Method 68
BuildIndex Method 72
BuildIndices Method 73
CalculateStatistics Method 74
CancelAction Constants 76
CancelAction Property 76
CancelUpdate Method 78
Candidate Property 81
CandidateCount Property 87
Ceiling Property 88
Center Property 89
CenterAt Method 90
CenterOnAscent Property 91
Centroid Property 93
CharacterIndex Property 94
ChartRenderer Object 95
ChartType Constants 98
ChartType Property 98
ClassBreaksRenderer Object 98
Clear Method 99
Click Event 100
ClearConnectError Method 100
ClearEvents Method 102
CodePage Constants 103
CodePage Property 104
Color Constants 104
Color Property 106
CommitTransaction Method 107
Connect Method 111
Connected Property 112
Add Method
Applies To Parts Collection, Points Object, Strings Collection, GroupRenderer Object, Layers Object
Part Description
variable A boolean expression that indicates whether item was added successfully.
Strings or Layers collections only.
item An expression of any type that specifies the member to add to the collection.
Remarks The Add method will only return a Boolean variable if the object is a MapObjects Strings or
Layers collection.
When you add a MapLayer or an ImageLayer to a Layers collection, youre adding it to the
beginning or top of the collection; consequently its index is 0 and the numeric index of
previously added members of the collection increment by one. You can use the MoveTo and
MoveToBottom methods to change the position of a member of the collection. Note that you
can refer to an existing layer in the Layers collection using the Item method with either its
name or its numeric index.
Example This example uses the Add method to add MapLayer objects to a Map. To try this example,
paste the code into the Declarations section of a form containing a CommonDialog control, a
CommandButton named Command1 and a Map named Map1 and then press F5 and click
Command1. Move to a folder containing ESRI shapefiles and open the file.
Option Explicit
Private Sub Command1_Click()
Dim oConnect As New DataConnection
Dim oDataset As GeoDataset
Dim sName As String
Dim oLayer As MapObjects2.MapLayer
oConnect.Database = CurDir
If Not oConnect.Connect Then Exit Sub
End Sub
AddEvent Method
Applies To TrackingLayer Object
Description Creates a new GeoEvent based on a given shape. The method draws the GeoEvent using the
Symbol referenced by the SymbolIndex property.
Part Description
symbolIndex An integer index that indicates with which Symbol to draw the GeoEvent.
Remarks Care should be taken when adding GeoEvents of different shape types to the TrackingLayer.
If a GeoEvent is added, but given the SymbolIndex of a symbol with an incorrect
SymbolType, MapObjects will add the GeoEvent using the correct SymbolType, but the
default properties of that SymbolType will be used.
For example, if you add a Point as a GeoEvent to a TrackingLayer, but use a SymbolType
of moFillSymbol, that GeoEvent will be drawn with a black circle Symbol.
Example This example uses the AddEvent method to place a GeoEvent on the TrackingLayer of a map
interactively. The addition of GeoEvents as different shapes is also demonstrated. This code
adds the GeoEvent to the TrackingLayer at the location(s) you click. To try this example, paste
the code into the Declarations section of a form containing a Map named Map1 that contains
at least one MapLayer, and then press F5 and click the map. Note that if you click the map
with the left mouse button, the GeoEvent is marked with a red symbol. If you click the map
with the right mouse button, you must then track a polygon, which is added to the
TrackingLayer as a GeoEvent.
Option Explicit
End Sub
AddGeoDataset Method
Applies To DataConnection Object
Part Description
name A string expression that evaluates to the name of the GeoDataset object to
add to the DataConnection.
Settings The values for shapeType are ShapeTypeConstants. Note that as the new GeoDataset will be
stored as a Shapefile, only the Point, Points, Line and Polygon shape types are valid.
Remarks The AddGeoDataset method creates a new GeoDataset stored as a Shapefile. To successfully
create a new GeoDataset; the data source of the DataConnection object must be a folder to
which your application has write access. If MapObjects fails to create a new GeoDataset, the
method will return nil. In Visual Basic, your application can test for this as follows:
Dim gdNew as MapObjects2.GeoDataset
Shapefiles with support for Z and Measure values are only fully supported as of ArcView 3.1
and MapObjects 2.0. In some cases, older applications may not be able to read such
Shapefiles. If you intend to use geographic data created in MapObjects with older applica-
tions, you may wish to leave the HasZ and HasM arguments as their default values of False.
MapObjects does not directly support the MultiPatch shape type and can not create a
GeoDataset that stores shapes of this type.
Example This example uses the AddGeoDataset method and the TableDesc properties to create a new
shapefile that represents a GeoDataset with polygon features in a DataConnection. In addition,
the code associates the GeoDataset with a MapLayer, adding it to the Map. The TableDesc
properties define three additional fields in the Recordset. For each feature added, the code
invokes the AddNew and Update methods to populate the fields of the Recordset. To try this
example, paste the code into the Declarations section of a form containing a CommonDialog
control named CommonDialog1, a CommandButton named Command1 and Map named
Map1 that contains a MapLayer or an ImageLayer. This layer will serve as a background layer,
providing the coordinates and map units of the new MapLayer. Click F5, and track polygons
by clicking on the map, a double-click signals the end of a polygon. When youve added the
polygons you want, click the Save button to specify the name of the shapefile.
Option Explicit
Dim moSymbol As New MapObjects2.Symbol
Dim moPolygons As New Collection
With CommonDialog1
.Filter = ESRI Shapefiles (*.shp)|*.shp
.DefaultExt = .shp
.ShowSave
With Desc
define three additional fields
.FieldCount = 3
Map1.Layers.Add lyr
Map1.Refresh
End Sub
If Button = 1 Then
Set oPoly = Map1.TrackPolygon
moPolygons.Add oPoly
Map1.TrackingLayer.Refresh True
Else
Set oRect = Map1.Extent
oRect.ScaleRectangle 0.5
Map1.Extent = oRect
End If
End Sub
AddIndex Method
Applies To Geocoder Object
Description This method is used to define which fields of the StreetTable have logical indices built when
the BuildIndices method is used.
Part Description
fieldName A string expression that specifies the name of the field in the
StreetTables GeoDataset.
secondaryFieldName A string expression that specifies the name of the Field in the
StreetTables GeoDataset. This option is used if more than one
Field is indexed as one query variable, for example, left ZIP and right
ZIP. This field is optional and you can use an empty string (two
double quotes), if no other field needs to be indexed for the query
variable.
IndexType A value or constant that specifies the type of index as defined in the
IndexTypeConstants.
Remarks All logical indices have to be defined before the indices are built using the BuildIndices
method. The AddIndex method defines which Fields are indexed, and the type of index which
is built. Multiple logical indices can be specified; there will be more options available when
defining a search query if more logical indices are specified.
For a large street network, it is common to index street name and ZIP or city name Fields. For
example, two streets in different cities may have the same name, so you may want to search on
both street name and ZIP fields. A search query can also be relaxed by querying only on the
street name if no ZIP or an uncertain ZIP is provided in the address.
When you have added indices to a Geocoder object, the SearchQueries property should be
defined accordingly, based on those indices.
A normal (mgIndexTypeNormal) index can be used on any field in the StreetTable. You may
like to use a Soundex (mgIndexTypeSoundex) index on fields which can be misspelled, for
example street names.
See Also BuildIndices Method, EraseIndices Method, IndexStatus Method, ListIndices Method,
SearchQueries Property, IndexType Constants
Example This example demonstrates the use of the AddIndex, BuildIndices, ListIndices, EraseIndices
and IndexStatus methods. To try this example, paste the code into the Declarations section of a
form that contains a Map named Map1 and three CommandButtons named Command1,
Command2, and Command3. Next to the three buttons, add three Labels named Label1,
Label2 and Label3. Substitute appropriate values for the data paths. Then press F5 and click
each button to see what will happen.
Option Explicit
If Not geo.IndexStatus = _
MapObjects2.IndexStatusConstants.mgIndexExists Then
End Sub
End Sub
Set l = geo.ListIndices
If geo.IndexStatus = MapObjects2.IndexStatusConstants. _
mgIndexExists Then
msg = The index file contains & l.count & _
logical index/indices, including: & vbCrLf
For i = 0 To l.count - 1
msg = msg & l.Item(i) & vbCrLf
Next i
Else
msg = No indices are found
End If
Label3.Caption = msg
End Sub
Label1.Caption =
Label2.Caption =
Label3.Caption =
Set gd = dc.FindGeoDataset(Redlands)
lyr.GeoDataset = gd
lyr.Symbol.Color = moBlue
Map1.Layers.Add lyr
geo.StreetTable = gd
Change the path below to ones appropriate for your data
geo.MatchRules = C:\Program Files\ESRI\MapObjects2\ _
GeoRules\us_addr1.mat
End Sub
AddNew Method
Applies To Recordset Object
Syntax object.AddNew
Part Description
Remarks The AddNew method creates a new record you can edit and add to the Recordset referenced
by object. This method sets the fields to null or default values, if any.
After you modify the new record, use the Update method to save the changes and add the
record to the Recordset. No changes are made to the data set until you use the Update
method.
Invoke AddNew on complete Recordset objects only. MapObjects will issue a run-time error
if you invoke AddNew on a Recordset that represents a subset of a MapLayer objects
Recordset created by one of the following Recordset methods: SearchShape,
SearchByDistance, or SearchExpression.
Make sure that any editing operations your program carries out are made to the same
Recordset object for which you called the AddNew method. The safest approach is to create a
local Recordset object, on which all the editing operations are carried out. The following
Visual Basic example shows how this can be done for a given MapLayer, called new_layer:
Dim recs As MapObjects2.Recordset
Set recs = new_layer.Records
If recs.Updatable Then
recs.AddNew
If recs.EditMode = moEditAdd Then
Add new feature and attributes
recs.Update
Else
MsgBox AddNew failed.
End If
End If
See Also Recordset Object
AddressLocation Object
An AddressLocation object represents the results of an address match. When you locate a
successfully matched address using LocateCandidate, an AddressLocation object is re-
turned. MapObjects finds the geographic location of an address by searching the Geocoder
objects StreetTable.
You can return the status of the matched AddressLocation by reading its MatchScore
property. If your MatchScore is low, you might decide to provide a means for manual
intervention in order to match the address. If the match was successful, you can return the
Location of the address as a Point object, and side of the street with the StreetSide property
if applicable.
Properties
AddRelate Method
Applies To MapLayer Object
Description Creates a relate between the Recordset associated with a MapLayer and the Recordset of
another Table.
Part Description
toField A string expression that evaluates to the name of a Field in the Recordset
associated with the MapLayer.
sourceTable An object expression that evaluates to a Table object that contains the data
to relate to the MapLayer objects Recordset.
Remarks When the AddRelate method is used, checks are performed on the sourceTable to ensure that
the relate is possible. The following checks are carried out:
The supported relate types: are numeric fields, character/string fields and Boolean fields. If
either the toField or fromField is not of a supported type then AddRelate will return False,
and the relate will not be successful.
The default value for checkFields is True. When checkFields is True, the AddRelate method
carries out further checks against the toField in the sourceTable. The following checks are
made:
If one or more of these conditions are true, then AddRelate will succeed. If checkFields is
false, this last set of checks will not be carried out and AddRelate will succeed if the first sets
of checks are successful. Depending on the database that contains the sourceTable, it may not
be possible for MapObjects to carry out the last set of checks. Certain ODBC drivers do not
support the necessary functionality to determine these conditions. In these cases, you may
wish to set checkFields to False in order to carry out the relate; for example when carrying out
a relate to an Oracle view. This should be done with care, particularly with large data sets, as
the performance of any relate without an index may be inefficient.
The checkFields parameter can also be used when the AddRelate is to be carried out using a
database table that is not owned by the current user. If the user specified in the User property
of the Table object does not have sufficient privileges, MapObjects can not carry out the
required indexing operations. In this case, the checkFields parameter should be set to False.
Example This example uses the AddRelate method to associate records from a foreign table (referred to
as sourceTable in the usage) with the records in a MapLayer objects Recordset. It also uses
the RemoveRelates method to drop all the related fields. To try this example, paste the code
into the Declarations section of a form containing a CommonDialog control named
CommonDialog1, two CommandButton controls named Command1 and Command2, a
ListBox named List1, and a Map named Map1 that has a MapLayer. The example assumes
that you have a Microsoft dBase Driver (*.dbf) DataSource named the same as the folder that
contains the dBase Table that you want to relate to the MapLayer. In addition, youll have to
change the field names that you pass as parameters to AddRelate. Press F5, then click Com-
mand1. Youll see the additional fields in the ListBox. If the Recordset has more than 100
records, youll have to create an index on the field in the sourceTable.
Option Explicit
Dim recset As MapObjects2.Recordset
Dim f As MapObjects2.field
End Sub
AfterLayerDraw Event
Applies To Map Object
Part Description
Remarks You can use the hDC to refer to the handle for an objects device context. This provides a
value to pass to Windows API calls.
Example This example illustrates when the AfterLayerDraw Event occurs. Prior to drawing each layer
on the Map, the code displays a simple message that indicates the name of the layer. To try this
example, paste the code into the Declarations section of a form containing a Map named Map1
that contains at least one MapLayer, and then press F5.
Option Explicit
AfterTrackingLayerDraw Event
Applies To Map Object
Description Occurs when a Map completes drawing all the GeoEvent objects on its TrackingLayer.
Part Description
Remarks You can use the hDC to refer to the handle for an objects device context. This provides a
value to pass to Windows API calls.
Example This example demonstrates when the AfterTrackingLayerDraw Event occurs. Clicking on the
map adds a GeoEvent to the TrackingLayer. The event code reports on the number of
GeoEvent objects on the TrackingLayer. To try this example, paste the code into the Declara-
tions section of a form containing a Map named Map1 that contains at least one MapLayer,
and then press F5. Click on the Map to add GeoEvent objects.
Option Explicit
Alignment Constants
MapObjects defines the following constants for use with the HorizontalAlignment property
(H in the table below)and the VerticalAlignment property (V in the table below) of a
TextSymbol object.
AllowDuplicates Property
Applies To LabelRenderer Object, LabelPlacer Object
Description Returns or sets a value indicating whether a LabelPlacer or LabelRenderer object will draw
duplicate labels if it has already drawn a label with the same text.
Part Description
Setting Description
Example This example uses three of the LabelRenderer properties to control the appearance of the text
drawn by the renderer. It uses the AllowDuplicates property to control whether a
LabelRenderer object will draw more than one instance of the same text to a MapLayer. It uses
the DrawBackground property to control whether the features of the MapLayer draw. It also
uses the SplinedText property to control whether text splines when the MapLayer displays line
features. Note that while the example initializes AllowDuplicates to False; its actual default is
True. To try this example, paste the code into the Declarations section of a form containing a
Map named Map1 that contains a MapLayer that displays polygon features, a ListBox named
List1, three CheckBox controls named Check1, Check2, and Check3, and a CommandButton
named Command1. The code will position and size the controls; just make sure to leave
enough room below the map on the Form. Press F5 and double-click the name of a Field that
will serve as the source or the text. Toggle the check box controls to set the properties.
Option Explicit
With oRenderer
.SymbolCount = 1
.AllowDuplicates = Check1.Value
.DrawBackground = Check2.Value
.SplinedText = Check3.Value
.Symbol(0).Font = oFont
.Symbol(0).Color = moBlack
.Symbol(0).Height = Map1.Extent.Height * 0.08
sFldname = List1.List(List1.ListIndex)
.Field = sFldname text values stored in this field
End With
disassociate objects
Set oFont = Nothing
Set oRecs = Nothing
Set oRenderer = Nothing
End If
End Sub
List1.Left = Map1.Left
Check1.Left = List1.Left + List1.Width + 100
Check2.Left = Check1.Left
Check3.Left = Check1.Left
Command1.Left = Check1.Left
End Sub
AllowSharing Property
Applies To GeoDataset Object
Description Returns or sets a value indicating whether other applications may write to the GeoDataset
object.
Part Description
shared A boolean expression specifying whether other applications may write to the
GeoDataset object, as described in Settings.
Setting Description
False (Default) Shares to other applications for reading the GeoDataset object.
Remarks The AllowSharing property can be used to allow other applications to make edits to a
GeoDataset that is being used in a MapObjects application. By default, when a GeoDataset is
returned its AllowSharing property is set to False. If a GeoDataset has already been opened
by another application for editing, then MapObjects will return the GeoDataset with its
AllowSharing property set to True.
If you wish other applications to be able to edit the GeoDataset, and the MapObjects applica-
tion is not editing the Recordset (see the EditMode property page), set the AllowSharing
property to True after it is returned. As neither MapObjects nor the computers operating
system can efficiently cache files that have been opened with shared write privileges, perfor-
mance may be slower when using a GeoDataset with its AllowSharing property is set to True.
Appearance Constants
MapObjects defines the following constants for use with the Appearance property of a Map
object.
Appearance Property
Applies To Map Object
Description Returns or sets the paint style of a Map object at run time. Read-only at run time.
Part Description
Area Property
Applies To Polygon Object
Part Description
value A value of double data type equating to the area of the Polygon.
Example This example makes use of some of the geometric properties of a Polygon to report back some
standard information about a feature you select. To try this example, copy the code into the
Declarations section of a Form that contains a Map named Map1 that contains a MapLayer
with polygon features. Press F5 and click on a polygon.
Option Explicit
End Sub
AreaOfInterest Property
Applies To MapLayer Object
Description Returns the default area of interest for a MapLayer object. The property is read-only at both
design time and run time.
Part Description
Remarks For MapLayer objects based on shapefiles, the area of interest is the same as the Extent. The
area of interest for an SDE layer may be a subset of the entire layer extent.
Example This example uses the AreaOfInterest property to zoom to the extent of a MapLayer. To try
this example, paste the code into the Declarations section of a form containing a
CommandButton named Command1 and a Map named Map1 that has at least one MapLayer.
Press F5. Drag a rectangle to zoom in and press Command1 to zoom to the extent of the
topmost MapLayer.
Option Explicit
AutoFlush Property
Applies To Recordset Object
Description Returns or sets a value that indicates whether changes to a Recordset are automatically
flushed on each write.
Part Description
Setting Description
Remarks Setting AutoFlush to False will result in performance improvements for batch type opera-
tions such as creating new Shapefiles. For updates to be reliably seen as they occur,
AutoFlush should be set to True. Setting AutoFlush to True will flush the file, as will
StopEditing or releasing the Recordset object.
Example This example uses the SearchShape method to select features in order to create a new
shapefile based on the Recordset the method returns. The example makes use of the AutoFlush
method to optimize the write operations. To try this example, paste the code into the declara-
tions section of a form that contains a Map named Map1 that has at least one MapLayer that
contains polygon features; then press F5. Track a polygon shape to select the features you
want to save to a new shapefile. Note that this example creates a hard-coded shapefile named
shptemp in the current path.
Option Explicit
Dim moPoly As MapObjects2.Polygon
Dim moRecset As MapObjects2.Recordset
With oSym
.SymbolType = moFillSymbol
.Style = moSolidFill
.Color = moYellow
End With
moRecset.MoveFirst
Map1.TrackingLayer.Refresh True
End Sub
Check out the path of your current directory - you may wish to
change
this path to a more suitable location.
oConnection.Database = CurDir
If oConnection.Connect Then
Set oTable = oRecset.TableDesc
Set oDataset = oConnection.AddGeoDataset(shptemp, _
moPolygon, oTable)
If oDataset Is Nothing Then Exit Sub
Set oLayer.GeoDataset = oDataset
Map1.Layers.Add oLayer
oRecset.MoveFirst
, Shapefile Exported
Map1.Layers.Remove 1
Map1.Layers(shptemp).Visible = True
Map1.Extent = Map1.Layers(shptemp).Extent
End Sub
Axis Property
Applies To Spheroid Object
Description Sets or returns a value that identifies the semimajor Axis upon which the Spheroid is based.
Part Description
value A double value that specifies the length of the semimajor Axis of the
Spheroid.
Remarks A Spheroid is based on the two radii of an Ellipse, the shorter of which is referred to as the
semiminor axis, and the longer as the semimajor. The line of latitude midway between the
poles of the earth is called the Equator, and defines the semimajor axis of the earth. The
vertical axis (the Polar axis), connecting the centre of the earth with either pole, may also be
referred to as the PrimeMeridian.
Example This example demonstrates how the Flattening and Axis properties of the Spheroid object may
be changed. To try this example, paste the code into the Declarations section of a new Form
which has two textboxes named Text1 and Text2, and a CommandButton named Command1.
Also, there you should add a Map named Map1 containing one MapLayer which has a
GeoCoordSys set. Then press F5, enter different values in the two textboxes, and click
Command1.
Option Explicit
theDatum.Type = Map1.Layers(0).CoordinateSystem. _
GeoCoordSys.Datum.Spheroid.Type
theDatum.Spheroid = theSphere
theGCS.Type = Map1.Layers(0).CoordinateSystem._
GeoCoordSys.Datum.Spheroid.Type
theGCS.Datum = theDatum
Map1.Layers(0).CoordinateSystem = theGCS
Map1.Refresh
End Sub
BackColor Property
Applies To Map Object
Part Description
color A value or constant that determines the color of the background of the Map
control.
Remarks Note that when using a Map control with its WindowMode property set to Windowless
Transparent, the BackColor will not be used, as the background of the Map is transparent.
Any features in MapLayers with the same color as the BackColor property will also be
rendered transparent.
Example This example uses the BackColor property to toggle the background color of a Map. To try
this example, paste the code into the Declarations section of a form containing a
CommandButton named Command1 and a Map named Map1 and then press F5 and click the
button.
Option Explicit
Private Sub Command1_Click()
If Map1.BackColor = moBlack Then
Map1.BackColor = moWhite
Command1.Caption = Black
Else
Map1.BackColor = moBlack
Command1.Caption = White
End If
End Sub
BackgroundRenderer Property
Applies To LabelPlacer Object
Description Returns or sets a reference to the renderer MapObjects will use to render the MapLayer
features prior to invoking the LabelPlacer.
Part Description
Remarks A Renderer is a creatable object in MapObjects. In Visual Basic, heres one way to create one
of the kinds of renderers:
Set Map1.Layers(0).Renderer = New MapObjects2.ValueMapRenderer
To draw with a single symbol, set the Renderer property to Nothing.
Set Map1.Extent = r
LabelPlacer.Field = NAME
LabelPlacer.DrawBackground = True
default symbol
LabelPlacer.DefaultSymbol.Height = Map1.FullExtent.Height / 150
Set LabelPlacer.DefaultSymbol.Font = fnt
LabelPlacer.AllowDuplicates = False
Check1.Value = Checked
End Sub
BarHeight Property
Applies To ChartRenderer Object
Description Returns or sets the full height of the bar chart in points.
Part Description
value An integer that represents the full height of the bar chart in points.
Remarks Bar charts are scaled such that the largest bar will equal the specified BarHeight. If any of the
data the ChartRenderer renders has a negative value, then the full size of the chart will be
twice the BarHeight. If no BarHeight is specified a default value of 20 points is used.
Example This example uses the BarHeight and BarWidth properties of the ChartRenderer to control the
height and width of the bar charts drawn on the map features. To try this example, paste the
code in the Declarations section of a form that contains two TextBoxes named Text1 and
Text2, a CommandButton named Command1 and a Map named Map1 that contains a
MapLayer that has numeric data to render. This example assumes the MapLayer is the USA
Counties sample data, therefore if needed, you should change the values in the Field property
array. Press F5 to run the example; you can change the values of the dimensions of the bar
charts and then click Command1 to display them.
Option Explicit
Dim cr As New MapObjects2.ChartRenderer
Map1.Refresh
End Sub
BarWidth Property
Applies To ChartRenderer Object
Description Returns or sets the full width of the bar chart in points.
Part Description
value An integer that represents the full width of the bar chart in points.
Remarks All the bars of the bar chart will be scaled to fit within the specified BarWidth value. If no
BarWidth is specified a default value of 20 points is used.
BatchMatch Method
Applies To Geocoder Object
Description This method matches all the addresses in a Table, and creates a Shapefile containing the
results of the BatchMatch.
Part Description
variable A numeric expression that specifies the number of records have been
matched.
addressField A string expression that represents the name of the field in addressTable that
contains the addresses to match against the StreetTable of the Geocoder
object. The addressField is the field that is parsed by the Standardizer
object. For example, the addressField may contain records such as 380
New York St. If there is an additional field used for matching, such as ZIP
or city name, specify the field in the Geocoder objects
BatchMatchVariable field property
outputTable A string expression that represents the name of the shapefile containing the
results of the BatchMatch method action.
Remarks The addressTable can be created either within MapObjects, or by connecting to a file, see the
Table Object page for more information.
The results of the BatchMatch can be found in the outputTable, the dataConnection param-
eter of the BatchMatch method determines where the outputTable will be located. The
outputTable is a shapefile, whose Shape field contains Point features. These Point features
represent the Location of each address which is matched.
The BatchMatch method returns the number of addresses that have been matched.
MapObjects adds all addressTable fields, plus any specified streetFields to the outputTable. If
you do not want to add any streetFields, specify an empty Strings object or Nothing as the
argument.
Fields named Side, Status and Score are also added to the outputTable, giving you
information about the matching process. A Side Field will only be added to the outputTable
if the addresses are geocoded to a StreetTable that specifies house number fields on the left
and right street sides. The Status Field shows the match status of the address. It is either M
(successfully matched) or U (not matched). Addresses with a MatchScore below the
MinimumMatchScore are not matched.
The Score Field stores the MatchScore of each address. In a range of 0 to 100, 100 signifies
a highly confident or exact match. If an address is not matched (U in the Status field), the
Score Field will be blank and the Value of the Shape Field will be Nothing.
A Geocoder used for batch matching must be valid, i.e. must be set up in a similar way as a
Geocoder used with the LocateCandidate method.
Example This example demonstrates how to use the BatchMatch method and set the
BatchMatchVariableField property to match a file of addresses. To try this example, paste the
code into the Declarations section of a form that contains a CommonDialog named
CommonDialog1, a Map named Map1, and a CommandButton named Command. Substitute
appropriate values for all the data paths. Press F5, then click Addresses to specify the name of
a dBASE file that contains a list of addresses. Note that the name of the Table objects
Database property for the dBASE Driver DataSource is hard-coded in Command1_Click. You
should ensure you have set an appropriate Data Source Name in using the ODBC utility in
Windows Control Panel. Try different values in the MinimumMatchScore and
MatchWhenAmbiguous properties and see the different results.
Option Explicit
Dim geo As New MapObjects2.Geocoder
Dim stan As New MapObjects2.Standardizer
Dim dcx As New MapObjects2.DataConnection
geo.MinimumMatchScore = 70
geo.MatchWhenAmbiguous = True
With CommonDialog1
.FileName =
.Filter = dBASE (*.dbf)|*.dbf
.DefaultExt = *.dbf
.CancelError = True
On Error Resume Next
.ShowOpen
If Err.Number = cdlCancel Then
Unload Me
End If
ft = .FileTitle
fn = .FileName
End With
write outputTable
Debug.Print AddressTable.Records.count
End Sub
Set up Standardizer
Change the paths below to ones appropriate for your data
stan.StandardizingRules = C:\Program Files\ESRI\MapObjects2 _
\GeoRules\us_addr.stn
stan.IntersectionStandardizingRules = C:\Program Files _
\ESRI\MapObjects2\GeoRules\us_intsc.stn
Set geo.Standardizer = stan
dc.Connect
If Not dc.Connected Then
MsgBox dc.connected error
End
End If
geo.MatchVariableIntersectionLink(RightZone, _
mgLinkPrimary) = RightZone1
Command1.Caption = Addresses
End Sub
BatchMatchVariableField Property
Applies To Geocoder Object
Description Returns or sets field names in addition to the addressField specified in the Geocoder objects
BatchMatch method.
Part Description
fieldName A string expression that specifies the name of the field in the address table
for batch matching. This is an additional field used for matching, such as
ZIP or city name. Unlike the addressField, this field will not parsed with a
Standardizer object.
Remarks The addressField parameter of the BatchMatch method defines the Field that is parsed by a
Standardizer object. If there is an additional Field which is required for matching, for
example a separate Field in the addressTable such as ZIP or city name, this Field needs to be
specified in the objects BatchMatchVariableField property.
This property is optional, if no additional Table Fields are required for the batch match, you
do not need to set a BatchMatchVariableField.
BeforeLayerDraw Event
Applies To Map Object
Part Description
Remarks You can use the hDC to refer to the handle for an objects device context. This provides a
value to pass to Windows API calls.
Example This example illustrates when the BeforeLayerDraw Event occurs. Prior to drawing each layer
on the Map, the code determines which of two layers to draw based on how close youve
zoomed in to the map. To try this example, paste the code into the Declarations section of a
form containing a command button called Command1 and a Map named Map1 that contains
two MapLayer objects, one with greater detail than another, and then press F5. Click on the
map to zoom in or press Command1 to zoom to the full extent of the map.
Option Explicit
BeforeTrackingLayerDraw Event
Applies To Map Object
Description Occurs when a Map starts to display the GeoEvent objects on its TrackingLayer.
Part Description
Remarks You can use the hDC to refer to the handle for an objects device context. This provides a
value to pass to Windows API calls.
Example This example illustrates when the BeforeTrackingLayerDraw Event occurs. The example
traces the path of a GeoEvent initially added to the TrackingLayer at the center of the Maps
extent. Clicking on the Map designates a new location for the GeoEvent. The code in the
BeforeTrackingLayerDraw event draws the trail. To try this example, paste the code into the
Declarations section of a form containing ListBox named List1 and a Map named Map1 that
contains at least one MapLayer, and then press F5. Click on the map to specify a new location.
Change the symbol of the trail by selecting from the list.
Option Explicit
Dim ln As New MapObjects2.Line
sym.SymbolType = moLineSymbol
sym.Style = List1.ListIndex
sym.Color = moBlue
Map1.DrawShape ln, sym
End If
End Sub
Map1.TrackingLayer.Refresh True
End Sub
BorderStyle Property
Applies To Map Object
Part Description
value A value or constant that determines the border style, as described in Set-
tings.
Setting Description
0 None.
Example This example uses the BorderStyle property to toggle the border of a Map. To try this ex-
ample, paste the code into the Declarations section of a form containing a CommandButton
named Command1 and a Map named Map1 and then press F5 and click the button.
Option Explicit
Private Sub Command1_Click()
If Map1.BorderStyle = 1 Then
Map1.BorderStyle = 0
Command1.Caption = Border
Else
Map1.BorderStyle = 1
Command1.Caption = No Border
End If
End Sub
Bottom Property
Applies To Ellipse Object, Rectangle Object
Description Returns or sets the distance between the internal bottom edge of an object and the top edge of
its container.
Part Description
Example This example uses the Bottom property to provide a coordinate point to use to position
graphic text on a map. To try this example, paste the code into the Declarations section of a
form containing a Map named Map1 that contains at least one MapLayer. Press F5 and then
click-drag a Rectangle after the MapLayers finish drawing.
Option Explicit
Dim oRect As New MapObjects2.Rectangle
Private mbTextAlreadyDisplayed As Boolean
Break Property
Applies To ClassBreaksRenderer Object, ZRenderer Object
Description Returns or sets the upper bound of a category or class of data in a renderer object.
Part Description
index An integer that specifies a category. The integer must be a number from 0 to
one less than the value of the renderers BreakCount property.
value A numeric expression that evaluates to the upper bound of the category or
class of data. (Data type is Double.)
Example This example uses the properties and methods of the ClassBreaksRenderer to create a standard
deviation classification. The code initializes a ClassBreaksRenderer with class breaks of three
standard deviations away from the mean in both directions. Only those break values that are
within the data range are added to the renderer. To try this example, paste the code into the
Declarations section of a form containing a CommonDialog control, a CommandButton named
Command1, a ListBox named List1, and a Map named Map1 that contains one MapLayer with
polygon features. Press F5 and select the name of a numeric field appropriate to your data
from the list; click the button to see the results.
Option Explicit
With oClassRend
.SymbolType = moFillSymbol
.Field = List1.Text
Set oStats = Map1.Layers(0).Records. _
CalculateStatistics(List1.Text)
Else
MsgBox Data type not suitable: & _
Map1.Layers(0).Records.Fields(List1.Text).Type
End If
End Sub
BreakCount Property
Applies To ClassBreaksRenderer Object, ZRenderer Object
Description Returns or sets the number of breaks between categories or classes of data used to classify the
values of the Field property of a ClassBreaksRenderer object. For a ZRenderer object, the
shapes Z values are used.
Part Description
value An integer that species the number of breaks between categories or classes
of data. (Data type is Integer.)
Remarks There is always one more category than the value of BreakCount.
Buffer Method
Applies To Point Object, Points Collection, Line Object, Polygon Object, Rectangle Object, Ellipse
Object
Description Returns a shape object that represents the perimeter of another shape object that has been
increased or decreased by a specific distance in all directions.
Part Description
resultShape An object expression that evaluates to a shape object. Will contain the
resulting buffered shape.
object An object expression that evaluates to an object in the Applies To list. This
is the object which is to be buffered.
bufferDistance A numeric expression that represents the distance by which object should be
buffered. This distance must be positive for Point, Points or Line objects.
Remarks A negative buffer distance can be specified for Rectangle, Polygon and Ellipse objects only.
In this case, the resulting buffered shape will be inset from the input object (i.e. it will have a
smaller radius). If a negative number is specified for a Point object, Points object or Line
object, then it is treated as a positive number of the same absolute value.
If you set a buffer distance of zero on an Ellipse object, the resultShape will be a Polygon
clone of that ellipse. A buffer distance of zero on a Point, Points, Line, Rectangle or Polygon
object will not set the resultShape object.
Example This example uses the Buffer method to allow the user to buffer points, lines, rectangles,
polygons and ellipses. The user point and the new shape generated by the buffer operation are
added to the tracking layer as GeoEvents. To try this example, paste the code into the Declara-
tions section of a form containing a Map named Map1 that has at least one MapLayer, and 5
OptionButtons named Option1 to Option5. Also add a Textbox named Text1. Press F5, and
choose an option, then click on the map to create a point, or track a line, rectangle, ellipse or
polygon. Try changing the value in the textbox.
Option Explicit
Set pt = Map1.ToMapPoint(x, y)
Set eventPt = Map1.TrackingLayer.AddEvent(pt, 0)
Set buffPt = pt.Buffer(Text1.Text, Map1.FullExtent)
Set buffEventPt = Map1.TrackingLayer.AddEvent(buffPt, 3)
Line buffering
ElseIf Option2.Value Then
Dim line As New MapObjects2.line
Dim eventLine As New MapObjects2.GeoEvent
Dim buffLine As New MapObjects2.Polygon
Dim buffEventLine As New MapObjects2.GeoEvent
Rectangle buffering
ElseIf Option3.Value Then
Dim rect As New MapObjects2.Rectangle
Dim eventRect As New MapObjects2.GeoEvent
Dim buffRect As New MapObjects2.Polygon
Dim buffEventRect As New MapObjects2.GeoEvent
Polygon buffering
ElseIf Option4.Value Then
Dim poly As New MapObjects2.Polygon
Dim eventPoly As New MapObjects2.GeoEvent
Dim buffPoly As New MapObjects2.Polygon
Dim buffEventPoly As New MapObjects2.GeoEvent
Ellipse buffering
ElseIf Option5.Value Then
Dim arect As New MapObjects2.Rectangle
Dim elli As New MapObjects2.Ellipse
Dim eventElli As New MapObjects2.GeoEvent
Dim buffElli As New MapObjects2.Polygon
Dim buffEventElli As New MapObjects2.GeoEvent
elli.Top = arect.Top
elli.Bottom = arect.Bottom
elli.Left = arect.Left
elli.Right = arect.Right
End If
End Sub
Private Sub Form_Load()
Option1.Caption = Point
Option2.Caption = Line
Option3.Caption = Rectangle
Option4.Caption = Polygon
Option5.Caption = Ellipse
Text1.Text = 100
Map1.TrackingLayer.SymbolCount = 4
With Map1.TrackingLayer.Symbol(0)
.SymbolType = moPointSymbol
.Style = moTriangleMarker
.Color = moRed
.Size = 3
End With
With Map1.TrackingLayer.Symbol(1)
.SymbolType = moLineSymbol
.Color = moRed
.Size = 3
End With
With Map1.TrackingLayer.Symbol(2)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moRed
.OutlineColor = moRed
End With
With Map1.TrackingLayer.Symbol(3)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moBlue
.OutlineColor = moBlue
End With
End Sub
BuildIndex Method
Applies To MapLayer Object, PlaceLocator Object
Description Builds a spatial index on a MapLayer object that is based on a Shapefile GeoDataset, or an
index for a field of a PlaceNameTable of a PlaceLocator object.
Part Description
Setting Description
True The objects index rebuilds regardless of its previous state. Note that
building an index may take an appreciable amount of time.
Remarks The BuildIndex method returns True if the index built successfully. Otherwise, it returns
False.
BuildIndex should not be used on a MapLayer based on ARC/INFO Coverages, SDE layers,
or CAD files. However, MapObjects does make use of spatial indices built in the original
applications for these data sources.
When applied to a MapLayer object based on a shapefile, the BuildIndex method creates a
spatial index and stores it in two files that have the name of the GeoDataset as a prefix and
the following suffixes: .sbn and .sbx. The two files are stored in the same folder as the
GeoDataset. The spatial index enhances performance when zooming, panning, using the
SearchShape method, and the SearchByDistance method.
Example This example uses the Indexed property and BuildIndex method to add an index to the first
MapLayer in a map control. To try this example, paste the code into the Declarations section
of a form containing a CommonDialog Control named Common1, and a Map named Map1
that has at least one MapLayer, and a command button called Command1. Press F5, then click
the button.
Option Explicit
Private Sub Command1_Click()
If Not Map1.Layers(0).Indexed Then
If Map1.Layers(0).BuildIndex(False) Then
MsgBox Index Built for layer: & Map1.Layers(0).name
Else
MsgBox No index Built
End If
Else
MsgBox Layer & Map1.Layers(0).name & has an existing index.
End If
End Sub
BuildIndices Method
Applies To Geocoder Object
Description This method builds the indices on the Geocoder object which are defined in the AddIndex
method.
Part Description
variable A boolean expression that indicates whether the indices are built success-
fully.
force A boolean expression that evaluates whether MapObjects will build the
indices regardless of the previous state of the indices, as described in
Settings.
Setting Description
True The objects indices rebuild regardless of its previous state. Note that
building the indices may take an appreciable amount of time.
False The objects indices will not rebuild if the index file already exists.
Remarks This method builds a geocoding index, or multiple indices, on match variables of the
StreetTable of a Geocoder. The indices must be specified before building, by using the
AddIndex method.
The BuildIndices method returns True if the index was built successfully. Otherwise, it returns
False. Use the Geocoder objects IndexStatus method to evaluate the status of the index. An
index file with a .gcd file extension will be created in the workspace of the StreetTables
GeoDataset if the indices are built successfully.
CalculateStatistics Method
Applies To Recordset Object
Description Creates a Statistics object whose statistical properties you can return.
Part Description
fieldname A string expression that evaluates to the name of the Field in the Recordset
for which to calculate statistics. Field must contain numeric values.
Remarks The CalculateStatistics method calculates statistics for a Field whose records contain non-
null numeric values only.
Example This example uses the Min, Max, Mean, StdDev, and Sum properties to report statistics for a
numeric field. To try this example, paste the code into the Declarations section of a form
containing a List control named List1, two Label control arrays named Label1() and Label2(),
and a Map named Map1 that contains one MapLayer that has at least one numeric field. To
create the Label control arrays, set the Index property of each Label control to 0. The code in
Form_Load will create additional instances, but you should align Label1(0) with Label2(0)
vertically. Press F5 and click the field name in the list to see the statistics for the field.
Option Explicit
Label1(0).Caption = Min
Label1(1).Caption = Max
Label1(2).Caption = Mean
Label1(3).Caption = StdDev
Label1(4).Caption = Sum
End Sub
Label2(4) = oStats.Sum
End Sub
CancelAction Constants
MapObjects defines the following constants for use with the Map objects CancelAction
property to control what action to take if the application receives an ESC keypress.
CancelAction Property
Applies To Map Object
Description Returns or sets a value indicating what action to take if the user presses the ESC key when the
application draws the Map.
Part Description
Example This example demonstrates the role of the value of the CancelAction property if the user
presses ESC while the map is drawing. To try this example, paste the code into the Declara-
tions section of a form containing a ComboBox named Combo1, a CommandButton named
Command1 and a Map named Map1 that contains more than one MapLayer, and then press
F5. While the map is drawing, press the ESC key. Change the CancelAction setting in the
ComboBox to see what effect a different CancelAction setting has. Use Command1 to zoom to
the full extent of the map.
Option Explicit
rect.ScaleRectangle 0.1
Map1.Extent = rect
End If
End Sub
CancelUpdate Method
Applies To Recordset Object
Description Cancels any pending updates for the Recordset object represented by the object placeholder.
Syntax object.CancelUpdate
Part Description
Remarks The CancelUpdate method cancels any updates made after a call to Edit or AddNew but
before a call to the Update method. Calling MoveNext before a call to Update has the same
effect as calling CancelUpdate.
Use the EditMode property to determine if there is a pending operation that can be canceled.
See Also Recordset Object, Edit Property, EditMode Property, and Updatable Property
Example This example uses the Edit method and the Updatable property in the context of a simple
record editing application. The code also demonstrates how to use the CancelUpdate method
to back out of making a change. In addition, the first time you change a record the code
demonstrates the EditMode property. Note that the example determines the number of records
by iterating through the Recordset. To try this example, paste the code into the Declarations
section of a form containing a CommandButton control named Command1, a ComboBox
named Combo1, a TextBox named Text1, and a Map named Map1 that has a MapLayer. For
the CommandButton, set its Index property to 0 in the Control Properties dialog box to create
a control array of one element, and then press F5. Choose a Field whose values you want to
change. Enter the new value in the text box and press the Change button. You can iterate
through the Recordset with the buttons named Next and Previous.
Dim editbufr As Variant
Dim recset As MapObjects2.Recordset
Dim TotalRecs As Integer
End Sub
With recset.Fields(Combo1.List(Combo1.ListIndex))
Select Case Index
Case 0 Next
If recnum < TotalRecs Then
recset.MoveNext
Text1.Text = .Value
recnum = recnum + 1
Command1(1).Enabled = True
If recnum = TotalRecs - 1 Then
Command1(0).Enabled = False
Else
Command1(0).Enabled = True
End If
Map1.TrackingLayer.Refresh True
End If
Case 1 Previous
If recnum > 0 Then
recset.MovePrevious
Text1.Text = .Value
recnum = recnum - 1
Command1(0).Enabled = True
If recnum = 0 Then
Command1(1).Enabled = False
Else
Command1(1).Enabled = True
End If
Map1.TrackingLayer.Refresh True
End If
Case 2 Change
editbufr = .Value
recset.Edit
.Value = Text1.Text
resp$ = MsgBox(Are you sure you want to change the value _
?, vbYesNo + vbInformation, MapObjects)
If resp$ = vbYes Then
GetEditMode demonstrates EditMode property
recset.Update
GetEditMode
Else
recset.CancelUpdate
Text1.Text = editbufr
End If
End Select
End With
End Sub
Sub GetEditMode()
Static Demonstrated As Integer
If Demonstrated < 2 Then
Select Case recset.EditMode
Case 0
Msg$ = No editing operation is in progress.
Button$ = vbInformation
Case 1
Msg$ = Edit in progress
Button$ = vbExclamation
Case 2
Msg$ = AddNew method has been invoked.
Button$ = vbExclamation
End Select
MsgBox Msg$, Button$, MapObjects
End If
Demonstrated = Demonstrated + 1
End Sub
Command1(0).Caption = Next
Command1(1).Caption = Previous
Command1(2).Caption = Change
recset.MoveNext
Loop
recset.MoveFirst
Text1.Text = recset.Fields(Combo1.List(Combo1.ListIndex)).Value
Command1(1).Enabled = False
If Not recset.Updatable Then
Command1(2).Enabled = False
End If
End Sub
Candidate Property
Applies To Geocoder Object
Description Returns the information of a candidate address associated with the Geocoder object.
Part Description
index A numeric expression that specifies the relative position of a member of the
group of Candidate values associated with the Geocoder object. Index
must be a number from 0 to a number that is one less than the value of the
Geocoder objects CandidateCount property.
Remarks The string returned from this property contains the following fields of information. Each field
is delimited by a vertical bar, |:
Score: The matching score in a range of 0 to 100; 100 indicates a highly confident or exact
match and 0 means the candidate is not a match.
Street side: The side of a centerline in relation to the reference StreetTable where the address
is successfully matched to. The values are L (left), R (right), and blank if it doesnt apply. This
information is only available if the address is geocoded against a StreetTable containing left/
right house numbers.
Percentage along the line segment: This value indicates the location of the geocoded point
(the candidates address location) along a line in terms of percentage. By simple linear
interpolation, 50.0 indicates that the geocoded point is on the mid-point of the arc.
Although 0.0 and 100.0 represent the two end points of the arc, the geocoded point may not be
actually placed on the end point if the objects SqueezeFactor property is set with a value
other than 0.
Record number of the StreetTable: This number indicates the record number of the candi-
date within the StreetTable.
Example This example demonstrates how to review the candidates that a Geocoder finds using the
GenerateCandidates method, Candidate and CandidateCount properties. Then an address can
be geocoded against a selected candidate using and LocateCandidate method. To try this
example, paste the code into the Declarations section of a form that contains a Map named
Map1, two TextBoxes named Text1 and Text2, a CommandButton named Command1, two
Labels named Label1 and Label2, and two ListBoxes named List1 and List2. Substitute
appropriate values for the data paths and then press F5. Try different values in the
SpellingSensitivity property and see the different number of candidates returned.
Option Explicit
If stan.StandardizeAddress(Text1.Text) Then
stan.FieldValue(ZN) = Text2.Text
geoStatus = geo.GenerateCandidates
Label1.Caption = msg
cand = geo.Candidate(0)
Label2.Caption = Here are the & num & candidates:
List2.AddItem Detail information of the first candidate:
List2.AddItem
s.Add Score
s.Add Side
s.Add Percent
If InStr(1, Text1.Text, &) = 0 Then
For i = 0 To geo.MatchVariableCount - 1
s.Add geo.MatchVariable(i)
Next i
Else
For i = 0 To 13 geo.IntersectionMatchVariableCount - 1
s.Add geo.IntersectionMatchVariable(i)
Next i
End If
s.Add Record no
a = 1
For i = 0 To s.count - 2
b = InStr(a, cand, |)
List2.AddItem s.Item(i) & vbTab & Mid(cand, a, b - a)
a = b + 1
Next i
List2.AddItem s.Item(s.count - 1) & vbTab & vbTab & _
Right(cand, Len(cand) - b)
End If
End If
End Sub
Set up Standardizer
Change the paths below to ones appropriate for your data
stan.StandardizingRules = C:\Program Files\ESRI\ _
MapObjects2\GeoRules\us_addr.stn
stan.IntersectionStandardizingRules = C:\Program Files\ESRI\ _
MapObjects2\GeoRules\us_intsc.stn
geo.Standardizer = stan
geo.MatchVariableIntersectionLink(PreDir, mgLinkPrimary) _
= PreDir1
geo.MatchVariableIntersectionLink(PreType, mgLinkPrimary) _
= PreType1
geo.MatchVariableIntersectionLink(StreetName, mgLinkPrimary) _
= StreetName1
geo.MatchVariableIntersectionLink(StreetType, mgLinkPrimary) _
= StreetType1
geo.MatchVariableIntersectionLink(SufDir, mgLinkPrimary) _
= SufDir1
geo.MatchVariableIntersectionLink(LeftZone, mgLinkPrimary) _
= LeftZone1
geo.MatchVariableIntersectionLink(RightZone, mgLinkPrimary) _
= RightZone1
Else
MsgBox Indices are built.
End If
End If
geo.SpellingSensitivity = 80
End Sub
CandidateCount Property
Applies To Geocoder Object
Description Returns the number of the candidate addresses found associated with the Geocoder object.
Part Description
value A variable declared to be of the integer data type that specifies the number
of candidate addresses returned from the GenerateCandidates method.
Ceiling Property
Applies To Rectangle Object
Part Description
Example This example illustrates setting of the Ceiling and Floor properties of a rectangle, and return-
ing the Depth property to check the dimensions of the rectangle. To try this example, paste the
code into the Declarations section of a form containing a Map named Map1, and a
CommandButton named Command. Also add three TextBoxes named Text1, Text2 and Text3,
and three corresponding Labels named Label1, Label2 and Label3. Press F5, and try changing
the ceiling and floor properties of the rectangle by typing new values in the TextBoxes, and
then pressing the CommandButton. If the depth of the rectangle is below 0.5, the rectangle will
draw in red.
Option Explicit
Dim rectSym As New MapObjects2.Symbol
Dim drawRect As New MapObjects2.Rectangle
Stdole.OLE_HANDLE)
End Sub
With drawRect
.Left = 0.3
.Right = 0.8
.Floor = 0
.Bottom = 0.3
.Top = 0.8
.Ceiling = 1
End With
With rectSym
.SymbolType = moFillSymbol
.Outline = True
.Size = 2
.Style = moGrayFill
End With
Label1.Caption = Ceiling
Text1.Text = drawRect.Ceiling
Label2.Caption = Floor
Text2.Text = drawRect.Floor
Label3.Caption = Depth
Text3.Text = drawRect.Depth
Text3.Enabled = False
End Sub
Center Property
Applies To Ellipse Object, Rectangle Object
Part Description
Example This example uses the Center property to report the coordinates of the center of the maps
current extent. To try this example, paste the code into the Declarations section of a form
containing a Map named Map1 that contains at least one MapLayer. Press F5 and click-drag to
pan the map. Dismiss the Message Box and pan again.
Option Explicit
CenterAt Method
Applies To Map Object
Syntax object.CenterAt x, y
Part Description
x The horizontal coordinate to position at the center of the Map. (Data type is
Double.)
y The vertical coordinate to position at the center of the Map. (Data type is
Double.)
Example This example uses the CenterAt method to pan the display to a specified location. To try this
example, paste the code into the Declarations section of a form that contains a Map named
Map1 that contains at least one MapLayer, and then press F5; click the Map. The display will
refresh and display the position you clicked at the center of the Map.
Option Explicit
Private Sub Form_Load()
Dim rect As MapObjects2.Rectangle
Set rect = Map1.Extent
rect.ScaleRectangle 0.5
Map1.Extent = rect
End Sub
CenterOnAscent Property
Applies To Symbol Object
Description Returns or sets whether MapObjects centers TrueType symbols by font ascent or by the actual
glyph bounds.
Part Description
boolean A boolean expression specifying whether to center the object by font Ascent
or not as indicated in Settings.
Setting Description
Example This example uses the CenterOnAscent property to control how to align TrueType symbols,
either centered by font Ascent or by the actual glyph bounds. To try this example, paste the
code into the Declarations section of a form containing a CheckBox named Check1 and a Map
named Map1. Press F5, then click the Map. Toggle the CheckBox to see the effect of the
property.
Option Explicit
Dim pt As MapObjects2.Point
With sym
.Style = moTrueTypeMarker
.SymbolType = moPointSymbol
If Check1.Value = 1 Then
.CenterOnAscent = True
ElseIf Check1.Value = 0 Then
.CenterOnAscent = False
End If
.CharacterIndex = 45
.Color = moRed
Map1.DrawShape pt, sym
.CharacterIndex = 46
.Color = moBlue
Map1.DrawShape pt, sym
End With
End If
End Sub
Centroid Property
Applies To Polygon Object
Part Description
Remarks The centroid represents the geometric center of a Polygon. For an irregular polygon, the
location of this Point will differ from the location of the Center of the Rectangle representing
the Extent of the Polygon.
CharacterIndex Property
Applies To Symbol Object
Description Returns or sets the character code in the Font associated with a Symbol object. To return or
set a Symbol objects Font, use the Font property.
Part Description
index A numeric expression that specifies the character code in the Symbols Font.
Example This example uses the CharacterIndex property to change the Symbol associated with a
GeoEvent on a TrackingLayer. As you click on the Map, the code increments the
CharacterIndex value associated with the Symbol. In this example, the CharacterIndex
property refers to the Wingdings character number. To try this example, paste the code into the
Declarations section of a form containing a Map named Map1 that contains at least one
MapLayer. Press F5 and click the Map repeatedly to see the different symbols.
Option Explicit
With Map1.TrackingLayer.Symbol(0)
.Font = fnt
.Size = 18
.Style = moTrueTypeMarker
.Color = moBlack
End With
End Sub
Static chridx
With Map1.TrackingLayer
If .EventCount > 0 Then .RemoveEvent 0
End With
With Map1.Extent.Center
Dim pt As MapObjects2.Point
Set pt = Map1.ToMapPoint(x, y)
Map1.TrackingLayer.AddEvent pt, 0
End With
Map1.TrackingLayer.Symbol(0).CharacterIndex = chridx
chridx = chridx + 1
End Sub
ChartRenderer Object
The ChartRenderer Objects properties and methods provide the ability to compare multiple
attributes of a feature by depicting the attributes as elements of either a pie chart or a bar chart.
In addition, you can compare one feature to another by the relative size of each features chart.
Use the ChartType property to set whether the chart is a pie chart or a bar chart. Use the
ShowOutline property to control the appearance of the chart outlines. Set the number of fields
represented in the chart with the FieldCount property, and for each attribute, set an indexed
Field property and an indexed Color property. To determine the dimensions of each bar chart,
use the BarHeight and BarWidth properties. To normalize bar charts, use the
NormalizationField property. To control the size of pie charts, use the SizeField,
MinPieSize, and MaxPieSize properties. You can set what value to consider as a null value
with the NullValue property and cancel the specified null value with the NoNullValue
method. A chart which contains data totaling zero will not be displayed.
Properties
Methods
NoNullValue
Example This example demonstrates how to use the properties and methods of a ChartRenderer object
to compare multiple attributes of the same feature and the relative magnitude of the features of
a MapLayer. To try this example, paste the code into the Declarations section of a Form that
contains a Map named Map1 with a MapLayer that references the USA Samples data states
shapefile, two OptionButton objects named Option1 and Option2, and a ListBox named List1.
Set the ListBox MultiSelect property to 2-Extended to allow for multiple selections and set the
ListBox Sorted property to True. Press F5; select one or more field names, and then choose a
chart type.
Option Explicit
Dim cr As New MapObjects2.ChartRenderer
Set Map1.Layers.Item(states).Renderer = cr
Set recset = Map1.Layers.Item(states).Records
For Each fld In recset.Fields
If fld.Type > 0 And fld.Type < 8 Then
List1.AddItem fld.Name
End If
Next fld
End Sub
ctr = ctr + 1
With cr
.FieldCount = ctr
.Field(ctr - 1) = List1.List(i)
.Color(ctr - 1) = QBColor(ctr + 1)
End With
End If
Next i
End If
End If
End Sub
ChartType Constants
MapObjects defines the following ChartType constants to describe the type of chart in a
ChartRenderer.
ChartType Property
Applies To ChartRenderer Object
Description Returns or sets which type of charts are drawn by the ChartRenderer object.
Part Description
value A value or constant that determines the chart type as described in Settings.
ClassBreaksRenderer Object
A ClassBreaksRenderer is an object that represents a way of classifying features into
categories or classes, by drawing different symbols for features. The Symbol used to render
the feature depends upon the value contained in the specified Field. You can specify the
number of categories (number of different Symbols you wish to use) in the BreakCount
property, and use the Break property to specify the values in Field which determine which
Symbol is used.
When setting the BreakCount property, remember that there is always one more category than
the number of breaks, so if you set BreakCount to be 2, there will be three categories. A
features Field value determines the category it falls into. The ClassBreaksRenderer assigns
a symbol to a feature using the indexed Symbol property. You can assign a specific Symbol to
each category. You can specify the type of Symbol to associate with the
ClassBreaksRenderer, depending on what kinds of features are associated with the
MapLayer, by setting the SymbolType property.
If you want, you can use the RampColors method to assign a start color to the first class and
an end color to the last class. The ClassBreaksRenderer will interpolate colors for interven-
ing classes. In a similar fashion, you can use the SizeSymbols method to create graduated
symbols by assigning an initial size in points to the Symbol associated with the first class and
a maximum size to the symbol associated with the last class. The ClassBreaksRenderer will
interpolate sizes for the intervening classes linearly.
Properties
Methods
RampColors SizeSymbols
Clear Method
Applies To Layers Collection, Strings Collection
Syntax object.Clear
The Clear method syntax has the following object qualifier and part:
Part Description
Example This example uses the Clear method to clear all layers from the map. To try this example,
paste the code into the Declarations section of a form containing a CommandButton named
Command1 and a Map named Map1 containing at least one MapLayer or ImageLayer and
then press F5 and click Command1.
Option Explicit
Private Sub Command1_Click()
Map1.Layers.Clear
End Sub
Click Event
Applies To Map Object
Description The Click event is a standard ActiveX control event, which occurs when the user presses and
then releases a mouse button over the map.
Part Description
Remarks For more information about the Click event, see the Visual Basic online reference.
See Also DblClick Event, MouseDown Event, MouseUp Event, MouseMove Event
ClearConnectError Method
Applies To DataConnection Object
Syntax object.ClearConnectError
Part Description
Remarks You should use the ClearConnectError method after reporting the value of the
ConnectError property, to ensure that the most recent error status is always reported.
Example This example uses the ConnectError property to return messages about problems encountered
when connecting to an SDE database. If Connect returns False, the code returns a message
about the type of error. To try this example, paste the code into the Declarations section of a
form containing a Map named Map1. Substitute appropriate values for the DataConnection
objects properties. Press F5.
Option Explicit
With dc
.Server = silver
.User = paul
.Password = revere
.Database = Midnight
If .Connect Then
MsgBox Connected successfully, vbInformation, MapObjects
Else
Select Case .ConnectError
Case 1
SDEErr = Unknown error
Case 2
SDEErr = Access denied
Case 3
SDEErr = Invalid user
Case 4
SDEErr = Network timeout
Case 5
SDEErr = Dataset invalid
Case 6
SDEErr = Tasks exceeded
Case 7
Build message
msg = Connection Error: & sMsg & Chr(13)
If Not dc.ExtendedError = 0 Then
msg = msg & dc.ExtendedError & : & dc.ExtendedErrorString
End If
msg = msg & Chr(13) & Do you want to clear the last _
connect error?
End If
End With
End Sub
ClearEvents Method
Applies To TrackingLayer Object
Description Deletes all GeoEvent objects and their corresponding Symbols from the TrackingLayer.
Syntax object.ClearEvents
Part Description
Remarks To remove individual events from the TrackingLayer, use the RemoveEvent method. To
clear all Symbol objects, set SymbolCount to 0.
Example This example uses the ClearEvents method to remove all GeoEvents from the TrackingLayer
at once. This code prompts the user when there are more than 5 GeoEvents to see if they want
to clear all events. To try this example, paste the code into the Declarations section of a form
containing a Map named Map1 that contains at least one MapLayer, and then press F5 and
click the map to add GeoEvents.
Option Explicit
Set pt = Map1.ToMapPoint(x, y)
Map1.TrackingLayer.AddEvent pt, 0
CodePage Constants
MapObjects defines the following code page constants to describe the CodePage property of
a TableDesc object derived from a Recordset of a MapLayer.
CodePage Property
Applies To TableDesc Object
Part Description
value An integer or constant that indicates the code page, as described in Settings.
Remarks The dBASE V specification has a byte in its header for a locale id (the 29th byte). If the byte
contains a value of 0x57, this indicates that all of the characters are stored in the ANSI code
page. MapObjects version 2.0 treats everything else as OEM. If the data is not correctly
marked with a code page specifier, you can override the behavior by setting the code page
value to one of the CodePage constants. To do this, access the TableDesc from a Recordset:
Map1.Layers(0).Records.TableDesc.CodePage = moAnsiCodePage
The code page will then be set for the duration of the project for all Recordset objects
subsequently derived from the specified MapLayer.
Color Constants
MapObjects defines the following color constants for use with Symbol objects.
Color Property
Applies To Symbol Object, TextSymbol Object, ChartRenderer Object
Part Description
Example This example uses the Color property to control the color of the symbol used to render a
MapLayer. To try this example, paste the code into the Declarations section of a form contain-
ing a CommonDialog control, a CommandButton named Command1 and a Map named Map1
that contains one MapLayer with polygon features. Press F5 and click Command1. The first
time you click the button, you can make a selection from the Color dialog and click OK.
Subsequent clicks on the button illustrate different ways to set Color in code.
Option Explicit
With Map1.Layers(0).Symbol
Select Case lNumClicks
Case 0
CommonDialog1.ShowColor
.Color = CommonDialog1.Color
Case 1
fRed = 255 * Rnd
fGreen = 255 * Rnd
fBlue = 255 * Rnd
.Color = RGB(fRed, fGreen, fBlue) random
Case 2
.Color = QBColor(10) light green
Case 3
.Color = vbActiveTitleBar
Case 4
.Color = moOrange
Case Else
MsgBox No more examples. Thanks anyway!, vbInformation
End Select
lNumClicks = lNumClicks + 1
End With
If lNumClicks < 6 Then Map1.Refresh
End Sub
CommitTransaction Method
Applies To Recordset Object
Description Causes all operations that have occurred since the StartTransaction request to be committed
to the server.
Syntax object.CommitTransaction
Part Description
object An object expression that evaluates to a Recordset object that has an open
transaction.
Remarks The CommitTransaction method is used at the end of a single edit, or series of edits, on an
open Recordset, i.e. one that has previously had the StartTransaction method called.
If the edits are not required the RollbackTransaction request can be used to save the
Recordset to the server as it was before the transaction began.
Example This example demonstrates how you might connect to and perform a transaction on a dataset
stored in SDE. A useful function is included to return a string based on the LastError of a
DataConnection. To try this example, paste the code into the Declarations section of a new
Form which has three CommandButtons named Command1, COmmand2 and Command3, a
Map named Map1, and a ListBox named List1. Edit the properties of the DataConnection as
appropriate for your SDE instance, using the name of an SDE layer containing Line features in
the FindGeoDataset method. Then press F5, and click Connect. When connected to SDE,
click Start transaction, and then track a line on the Map. Press End Transaction. To see the
results of the transaction, you can press the last CommandButton to remove and re-load the
same MapLayer.
Option Explicit
Dim dc As New MapObjects2.DataConnection
Dim lyr As New MapObjects2.MapLayer
Dim recs As New MapObjects2.Recordset
Dim reportCnt As Integer
Dim sym As New MapObjects2.Symbol
dc.Server = drfinlay
dc.User = sde_user
dc.Password = sde_user
dc.Database = esri_sde
Screen.MousePointer = vbDefault
End Sub
Screen.MousePointer = vbHourglass
Result = MsgBox(Do you want to Commit this Transaction? _
, vbYesNoCancel, Commit Transaction)
Map1.Refresh
Command4.Enabled = True
Screen.MousePointer = vbDefault
End Sub
Screen.MousePointer = vbHourglass
Command1_Click
Command4.Enabled = False
Screen.MousePointer = vbDefault
End Sub
ReportOut
recs.AddNew
recs.Fields(Shape).Value = NewLine
ReportOut
recs.Update
ReportOut
Map1.Refresh
Screen.MousePointer = vbDefault
Exit Sub
SDEErrors:
MsgBox Error in Carrying out Editing on SDE: & vbNewLine _
& Connect Error: & dc.ConnectError & vbNewLine & ExtendedError _
: & dc.ExtendedError & vbNewLine & dc.ExtendedErrorString
ReportOut
Screen.MousePointer = vbDefault
End Sub
reportCnt = reportCnt + 1
ConnStr = ConnectErrorMsg(dc.ConnectError)
dc.ClearConnectError
Connect Method
Applies To DataConnection Object
Part Description
Remarks To successfully connect to a DataConnection object, you should ensure that the
DataConnections Database property specifies a source of a supported vector data. The
Connect method returns a Boolean value indicating whether or not MapObjects was able to
create the connection.
You can also check the status of the DataConnection using the Connected property, after the
Connect method has been attempted, or to check the current status of a previously used
DataConnection object.
In order to establish a successful connection with an SDE database, the Server, User and
Password properties of the DataConnection object must be set with appropriate values for
the database.
The ConnectError property provides more information should the connection fail. If your
application is attempting to connect to SDE, the ExtendedError and ExtendedErrorString
properties will return any error messages from the database. A useful function is provided in
the Connection property example code, providing error string reporting for each of the SDE
errors supported by MapObjects as ConnectionErrorConstants.
Example This example uses the Connect method to establish a connection to a folder containing
GeoDatasets. If Connect returns True, the code adds a MapLayer based on a GeoDataset to the
collection of MapLayers. In this case, Database is a path name to a directory. To try this
example, paste the code into the Declarations section of a form containing a Map named
Map1. Substitute an appropriate pathname for the DataConnection objects Database property
and specify the name of a valid GeoDataset as an argument to FindGeoDataset. Press F5.
Option Explicit
If dc.Connect Then
Set lyr.GeoDataset = dc.FindGeoDataset(Redlands)
Map1.Layers.Add lyr
Else
MsgBox Connection failed
End If
End Sub
Connected Property
Applies To DataConnection Object
Description Returns a value indicating whether the DataConnection object has a current valid connection.
Syntax object.Connected
Part Description
Return Values The returned values for the Connected property are:
Setting Description
Example This example demonstrates the use of the Connected Property and the Disconnect method. To
try this example, paste the code into the Declarations section of a form containing a Map
control, a DriveList control named Drive1, a DirListBox control named Dir1, and two
CommandButton controls named Command1 and Command2. Press F5 and navigate through
the file system. Disconnect from the Database by clicking Command1. Check the status by
clicking Command2.
Option Explicit
Dim dc As New MapObjects2.DataConnection
If dc.Connected Then
sTitle = DataConnection Status
MsgBox Connected, vbInformation, sTitle
Else
MsgBox Disconnected, vbExclamation, sTitle
End If
End Sub
dc.Database = Dir1.path
If dc.Connect Then
Command1.Enabled = True
End If
End Sub
ConnectError Property
Applies To DataConnection Object
Description Returns a value that specifies the type of error that caused an unsuccessful DataConnection
connection.
Part Description
Return Values Return values from the ConnectError property are ConnectionErrorConstants.
Remarks If you have used the ConnectError property to report on the last DataConnection error, you
should then call the ClearConnectError method.
A useful function is provided in the Connection property example code, providing error string
reporting for each of the SDE errors supported by MapObjects as
ConnectionErrorConstants.
Connection Property
Applies To DataConnection Object
Part Description
Return Values If the object is a connection to a non-SDE data source, or there is no connection to the SDE
server made, the Connection property will be zero.
For more information on SDE handles and the SDE API, see your SDE documentation.
Remarks For an SDE database, the Connection property will return a handle to the database connec-
tion. The Connection property exposes the results of the SDE SE_connection_create function.
This connection can be used if your application needs to make direct calls to the SDE API. All
operations performed using this connection are executed as the user named in the User
property.
The connection will be valid as long as the DataConnection exists. You can create multiple
SDE connections, by repeating the Connect process on a new DataConnection object.
If appropriate, when the DataConnection object goes out of scope, the database connection
will be freed. If your application makes use of the database Connection, it is important that it
does not try to free the connection itself, the Disconnect method should always be used to
disconnect from an SDE server before the application ends.
ConnectionError Constants
MapObjects defines the following Error code constants for DataConnection connections.
moNoError 0 No Error
CoordinateSystem Property
Applies To MapLayer Object, Map Object
Description Returns or sets the coordinate system for a Map or a MapLayer object.
Part Description
Example This example uses the CoordinateSystem property to hide each MapLayer which does not
have a coordinate system set. To try this example, paste the code into the Declarations section
of a form containing a Map named Map1 that has more then one MapLayer (some of which
should have corresponding .prj files), and a ListBox called List1. Press F5 to run the example.
Option Explicit
CopyMap Method
Applies To Map Object
Description Copies the visible extent of the Map to the Clipboard in enhanced and standard metafile
format.
Part Description
Example This example uses the CopyMap method to copy the visible extent of a Map to the Clipboard
in enhanced and standard metafile format. To try this example, paste the code into the Declara-
tions section of a form that contains a CommandButton named Command1 and a Map named
Map1 that contains at least one MapLayer, and then press F5; click Command1 and then paste
the contents of the Clipboard into another application.
Option Explicit
Private Sub Command1_Click()
Map1.CopyMap 1
End Sub
Count Property
Applies To Fields Collection, GeoDatasets Collection, GroupRenderer Object, Layers Collection,
Parts Collection, Points Object, Strings Object, Recordset Object, Statistics Object
Description Returns the number of objects in a collection. For Recordset objects, if the number of records
is unknown, the property returns -1.
Part Description
total An integer data type variable, indicating the number of objects in a collec-
tion.
Remarks You can use this property with a For...Next statement to carry out an operation on the mem-
bers of a collection. For example, the following code adds the names of all layers in a map to
a list:
For I = 0 To Form1.Map1.Layers.Count - 1
List1.Additem Form1.Map1.Layers(I).Name
Next I
The Count property may return a value of -1 when the object is a Recordset derived from
sources which do not contain header information such as:
an SDE layer
a Table object
a SearchExpression
In these cases, to obtain the correct Count of the Recordset, a Statistics object should be
created from the Recordset, and the number of records taken from the Count property of this
Statistics object.
Example This example uses the Count property to report on how many layers constitute the Map, and
the number of events in the tracking layer. To try this example, paste the code into the Declara-
tions section of a form containing a Label named Label1 and a Map named Map1 that contains
at least one MapLayer, and some GeoEvents. Press F5
Private Sub Form_Load()
Label1.Caption = Map1.Layers.Count & layers in the map, and _
& Map1.TrackingLayer.EventCount & events in the tracking layer
End Sub
Custom Property
Applies To Symbol Object, Projection Object
Part Description
Remarks The Custom property is used to set a reference to a user-defined custom Symbol or Projec-
tion object, for example:
Dim myMarker as New MySymbols.MarkerSymbol
myLayer.Symbol.Custom = myMarker
Custom Symbols and Projections are created by using the ICustom Interface. For example, in
Visual Basic you can create your own DLL using the ICustom interface by adding a reference
to the AFCust2.0.tlb Type Library.
You can also create a custom renderer object, allowing the developer to render a MapLayer
to exact specifications.
Database Property
Applies To DataConnection Object, Table Object
Description Returns or sets the Database name for an SDE connection, an ODBC connection, a Microsoft
Jet database engindatabase, an installable ISAM database, an INFO database, or an ARC/
INFO or PC ARC/INFO workspace. In addition, you can use the pathname to a directory
containing ESRI shapefiles(SHP files), creating an ODBC DataConnection automatically.
Part Description
Remarks The Database property should not be used on a Table object to connect to a table in SDE.
When connecting to SDE you should use the Database, Server, User and Password proper-
ties of the DataConnection object.
For certain vector data sources, a suffix should be specified before the dbName expression.
DataConnection Object
A DataConnection represents a connection to a source of geographic data. Sources that
MapObjects can connect to are: folders containing Shapefiles or CAD files, SDE database
instances, ARC/INFO workspaces and VPF data sources. A DataConnection can return a
GeoDatasets collection. Each member of the collection, referred to as a GeoDataset, repre-
sents a discrete set of geographic data that can be retrieved from the data source. You can use
the FindGeoDataset method to return a specific GeoDataset by name. You can delete a
GeoDataset from a DataConnection object using DeleteGeoDataset, and you can make use
of the geographic data in a GeoDataset by assigning it to the GeoDatset property of a new
MapLayer object. You can also find CoordinateSystem information about your
The Connect method of the DataConnection object will attempt to connect to the data source
specified in the Database property. This method will return True if the connection was
successful. You can later verify a connections status by using the Connected property. For an
SDE database, the Connection property will return a handle to the database connection. This
connection can be used if your application needs to make direct calls to the SDE API.
The DataConnection object also allows error catching. The ConnectError property will
return the last error raised while trying to Connect to a database. The ExtendedError and
ExtendedErrorString properties will return a value and description of the last error raised by
the database while trying to access an SDE layer.
Properties
Methods
Connect FindArcInfoCoordinateSystem
Datum Constants
MapObjects defines over 200 constants for use with the Type property of a Datum object. See
the online help for details.
Datum Object
The Datum object is used to define the datum upon which a geographical coordinate system is
based.
A Datum objects properties can be specified by using a pre-defined datum, by setting the
Type property to equal one of over 200 DatumConstants. Alternatively, a user-defined
Datum can be specified by reference to a Spheroid object.
See Also Datum Constants, GeoCoordSys Object, PrimeMeridian Object, Spheroid Object, Unit
Object
Properties
Datum Property
Applies To GeoCoordSys Object
Description Sets or returns a value that identifies the datum upon which a GeoCoordSys object is based.
Part Description
Example This example uses the Datum property to check MapLayers with geographic coordinate
systems. MapLayers which are not projected, or have the same datum as that chosen by the
user in the ComboBox, remain visible. MapLayers having a geographic coordinate system
with the same datum as that chosen in the ComboBox are made invisible. To try this example,
paste the code into the Declarations section of a form containing a Map named Map1 that
contains at least one MapLayer, and a ComboBox named Combo1. MapLayers should have
their CoordinateSystem property set. Press F5, and choose a datum from the ComboBox.
Option Explicit
Map1.Refresh
End Sub
datums.PopulateWithDatums
For Each theDat In datums
Combo1.AddItem theDat
Next theDat
dat1.Type = moDatum_WGS1984
dat2.Type = moDatum_AGD1984
gcs1.Datum = dat1
gcs2.Datum = dat2
Set Map1.Layers(0).CoordinateSystem = gcs1
Set Map1.Layers(1).CoordinateSystem = gcs2
End Sub
DblClick Event
Applies To Map Object
Description The DblClick event is a standard ActiveX control event, which occurs when the user presses
and then releases a mouse button over the map twice in rapid succession.
Part Description
Remarks For more information about the DblClick event, see the Visual Basic online.
DefaultSymbol Property
Applies To LabelPlacer Object, EventRenderer Object, ValueMapRenderer Object
Description Returns a reference to the Symbol used to draw the MapLayer features that do not have an
explicitly assigned symbol.
Syntax object.DefaultSymbol
Part Description
Example This example demonstrates the role of the DefaultSymbol and UseDefault properties of a
ValueMapRenderer. The example controls whether all unique values in a specified Field draw
with a unique symbol or whether the values that fall outside a range of specified values draw
with a default symbol. To try this example, paste the code into the Declarations section of a
form containing a CheckBox named Check1, a ListBox named List1, and a Map named Map1
that contains at least one MapLayer with polygon features; press F5 and double-click a field
name in the list whose unique values to display. Use the check box to toggle whether or not to
use the default symbol for values outside the specified range.
Option Explicit
Dim moRecset As MapObjects2.Recordset
Map1.Refresh
Set oRenderer = Nothing
Set strs = Nothing
Set moRecset = Nothing
End Sub
Delete Method
Applies To Recordset Object
Syntax object.Delete
Part Description
Remarks When you delete records from a Recordset, there must be a current record in object before
you use Delete, otherwise an error will occur.
Delete removes the current record and makes it inaccessible. Although you cannot edit or use
the deleted record, it remains current. Once you move to another record, the deleted records
becomes permanently irretrievable.
See Also Edit Method, Update Method, Delete Method, EditMode Property
Example This example uses the Delete method to delete the first record in a Recordset. To try this
example, paste the code into the Declarations section of a form that contains a
CommandButton named Command1 and a Map named Map1 that has at least one MapLayer;
then press F5. Click the CommandButton to delete the record.
Option Explicit
DeleteGeoDataset Method
Applies To DataConnection Object
Part Description
name A string expression that evaluates to the name of the GeoDataset object to
delete.
Part Description
false Either the method has failed to remove one or more of the files constituting
a shapefile, or the GeoDataset specified in the name variable does not
derive from a shapefile.
Remarks The DeleteGeoDataset method will try to delete the .shp, .dbf, and .shx files as specified. If
each deletion is successful, the method will also search for and attempt to delete .sbn, .sbx and
.prj files. If each deletion is successful, the method will return True.
If any deletion is unsuccessful, the method will return False, therefore care should be taken
when using this method, as some files may remain. The method may fail, for example, due to
files having a read-only status, insufficient file privileges of the user, or the file may already be
open by another application or process.
Example This example demonstrates how you can use the DeleteGeoDataset method to remove a
GeoDataset from a DataConnection. To try this example, paste the code into the Declarations
section of a form that contains a DirListBox named Dir1, a ListBox named List1, a
CommandButton named Command1; then press F5. Navigate to a folder that contains
GeoDatasets and double-click the folders name to display its GeoDatasets. In the ListBox,
click the name of the GeoDataset to delete and press Command1.
Option Explicit
Dim dc As New MapObjects2.DataConnection
.Database = Dir1.path
If .Connect Then
If Not .FindGeoDataset(List1.List(List1.ListIndex)) Is _
Nothing Then
.DeleteGeoDataset List1.List(List1.ListIndex)
End If
List1.Clear
dir1_Change
End If
End With
End Sub
With dc
.Database = Dir1.path
If .Connect Then
List1.Clear
If .GeoDatasets.Count > 0 Then
For Each oDataset In .GeoDatasets
List1.AddItem oDataset.Name
Next
End If
End If
.Disconnect
End With
End Sub
DensificationTolerance Property
Applies To MapLayer Object
Description Returns or sets the densification tolerance for a MapLayer object. This property works in
conjunction with the MapLayers GeographicTransformation property for on-the-fly
projection of the MapLayer.
Part Description
tolerance A numeric expression, which sets the frequency at which points are inserted
into the MapLayers features, in Map Units.
Remarks When a MapLayer has its GeographicTransformation property set, MapObjects will re-
project the MapLayer, on the fly, according to that geographic transformation. You must also
set a CoordinateSystem on the Map and on the MapLayer.
Example This example sets the DensificationTolerance property of a MapLayer relative to its units. To
try this example, paste the code into the Declarations section of a form containing a Map
named Map1 that has at least one MapLayer, and a ListBox called List1. Press F5 to run the
example.
Option Explicit
End Sub
Depth Property
Applies To Rectangle Object
Description Returns the difference between the Ceiling and Floor coordinates of a Rectangle object.
Part Description
Remarks The Depth property to represents the dimension of the rectangle along the Z-axis. By default,
a Rectangle object will have a Depth of zero.
Difference Method
Applies To Point Object, Points Collection, Line Object, Polygon Object, Rectangle Object, Ellipse
Object
Description Returns a shape that represents the geometric Difference of two shape objects of the same
dimension.
Part Description
resultShape An object expression that evaluates to a shape object. (See Remarks). Will
contain the resulting shape after the difference operation.
object An object expression that evaluates to an object in the Applies To list. This
is the shape whose dimensions will be reduced by subtractShape.
subtractShape An object expression that evaluates to an object in the Applies To list. This
is the shape that represents the amount by which object will be reduced.(See
Remarks).
Remarks If the two Shapes do not have a valid Difference, the resultShape will be nil.
Only certain combinations of shape are valid, and the return result will be a different object
type depending on the nature of the objects processed. The following table summarizes the
valid combinations and possible return results.
Polygon Polygon
Ellipse
Polygon Polygon
Ellipse
Polygon Polygon
Ellipse
Where the resultShape could be more than one object type (e.g. Rectangle or Polygon), then
use an interim Object and then test the result using its ShapeType property to see what type of
object it is.
The Difference method is not commutative, therefore the order of object and subtractShape
arguments is significant to the result, i.e. shapeA.Difference(shapeB) could be different to
shapeB.Difference(shapeA).
You cannot use the Difference method with a self-intersecting Polygon. If you do, an excep-
tion is raised in Visual Basic, specifying Error 5000, Valid Object expected as argument. You
can however use a self-intersecting Line.
See Also Buffer Method, GetCrossings Method, Intersect Method, Union Method, XOr Method
Example This example uses the Difference method to allow the user to perform Difference operations
on polygons. The polygons and the new shape generated by the Difference operation are
added to the tracking layer as GeoEvents. To try this example, paste the code into the Declara-
tions section of a form containing a Map named Map1 that has at least one MapLayer, press
F5, and then click on the map to track two polygons.
Option Explicit
Dim shape1 As Object
Dim shape2 As Object
Dim diff As Boolean
Line difference
Dim poly As New MapObjects2.Polygon
Dim eventLine As New MapObjects2.GeoEvent
Map1.TrackingLayer.SymbolCount = 2
With Map1.TrackingLayer.Symbol(0)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moGreen
.OutlineColor = moGreen
End With
With Map1.TrackingLayer.Symbol(1)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moBlue
.OutlineColor = moBlue
End With
End Sub
Direction Constants
MapObjects defines the following Direction constants to describe the direction in which a
geographic transformation is performed.
Direction Property
Applies To GeoTransformation Object
Description Sets or returns a value that identifies the Direction of the GeoTransformation.
Part Description
Remarks If you are using only one GeoTransformation Type, you should set the Direction property to
the appropriate direction for the transformation you require.
If you are using two different Types on the GeoTransformation, (i.e. you have set both Type
and SecondType) you should set both the Direction and SecondDirection properties appro-
priately. By default, the Direction property is forward and the SecondDirection is reverse.
Example This example demonstrates the Direction property of the GeoTransformation object. To try
this example, paste the code into the Declarations section of a new Form which has two Map
controls named Map1 and Map2. Each Map should contain a MapLayer with geographical
locations in common. Ensure the coordinate systems of each MapLayer are set appropriately.
Then press F5, and click on either Map. The point will be transformed to the other maps
coordinate system, and displayed on both maps.
Option Explicit
Dim fromPt As New MapObjects2.Point
Dim toPt As New MapObjects2.Point
Dim curMap As Integer
Dim sym As New MapObjects2.Symbol
If Map1.CoordinateSystem.IsProjected Then
map1Projected = True
Else
map1Projected = False
End If
If Map2.CoordinateSystem.IsProjected Then
map2Projected = True
Else
map2Projected = False
End If
myGT.ToGeoCoordSys = Map2.CoordinateSystem.GeoCoordSys
Else
myGT.ToGeoCoordSys = Map2.CoordinateSystem
End If
Set transformPoint = Map2.CoordinateSystem.Transform _
(Map1.CoordinateSystem, fromPt, , myGT)
End Function
With sym
.SymbolType = moPointSymbol
.Size = 4
.Outline = False
.Style = moTriangleMarker
End With
Arrange controls
Map1.Move 60, 60, 5000, 5000
Map2.Move Map1.Left + Map1.Width + 100, Map1.Top, Map1.Width, _
Map1.Height
Form1.Width = Map2.Left + Map2.Width + 60
Form1.Height = Map2.Top + Map2.Height + 60
End Sub
Disconnect Method
Applies To DataConnection Object
Syntax object.Disconnect
Part Description
Remarks The Disconnect method should always be used to Disconnect from an SDE server before the
application ends.
DistanceTo Method
Applies To Point Object, Points Collection, Line Object, Polygon Object, Rectangle Object
Part Description
Remarks The DistanceTo method will return true 3D distances between shapes that support Z values,
except for Polygon objects, for which the shortest distance from the other shape to the nearest
edge of the Polygon is returned instead.
Example This example uses the DistanceTo method to measure the distance between the center of the
Map and the first GeoEvent on the Map objects TrackingLayer. To try this example, paste the
code into the Declarations section of a form containing a CommandButton named Command1
and a Map named Map1 that contains at least one MapLayer, and then press F5 and click the
Map to add a GeoEvent. A left-click will add a point event, and a right-click will allow the
user to track a polygon, and add this polygon as an event. To determine the distance, click
Command1.
Option Explicit
Private Sub Command1_Click()
Dim lDist As Long
Dim oMypt As Point
If Button = 1 Then
Dim oPoint As MapObjects2.Point
Set oPoint = Map1.ToMapPoint(X, Y)
Map1.TrackingLayer.AddEvent oPoint, 0
End Sub
DistanceToSegment Method
Applies To Point Object
Description Returns the distance in map units from one Point to two other Point objects that represent a
line segment.
Part Description
Example This example uses the DistanceToSegment method to return the distance from a Point to two
points that constitute a line segment. To try this example, paste the code into the Declarations
section of a form containing a Map named Map1, then press F5 and click the Map to position
a point. The code reports the distance to the line segment.
Option Explicit
Dim moLine As New MapObjects2.line
Dim moPoints As New MapObjects2.Points
Dim moPoint As MapObjects2.Point
oPoint1.X = oRect.Left
oPoint1.Y = oRect.Bottom
oPoint2.X = oRect.Right
oPoint2.Y = oRect.Top
moPoints.Add oPoint1
moPoints.Add oPoint2
moLine.Parts.Add moPoints
End Sub
End Sub
End Sub
DotColor Property
Applies To DotDensityRenderer Object
Part Description
color A value or constant that determines the color of the dots used by the
renderer.
Example This example uses the DotColor property to control the color of the dots in a Dot Density map.
To try this example, paste the code into the Declarations section of a form containing a
CommonDialog control, a CommandButton named Command1, a Label named Label1, a
ListBox named List1, a TextBox named Text1, and a Map named Map1 that contains one
MapLayer with polygon features. Press F5 and click the button.
Option Explicit
With Map1.Layers(0)
Set .Renderer = oDotRend
With oDotRend
.Field = List1.List(List1.ListIndex)
.DotSize = 4
.DotColor = CommonDialog1.Color
.DotValue = Text1.Text
.DrawBackground = True
End With
Map1.Refresh
Set oDotRend = Nothing disassociate object
End Sub
With Text1
.Text =
.Locked = True
End With
With Label1
.Caption = 1 dot equals this many units:
.AutoSize = True
.Left = Text1.Left
.Top = Text1.Top - Label1.Height
End With
With Command1
.Caption = Draw Dots
.Left = Text1.Left
.Top = Text1.Top + Text1.Height * 1.5
.Enabled = False
End With
End Sub
DotDensityRenderer Object
A DotDensityRenderer is an object that represents a way of symbolizing features by drawing
dots on a feature. Each dot represents a uniform, specified value in the Field property of the
DotDensityRenderer as specified in its DotValue property. You can set the color of the dots
with DotColor and the size of the dots in points with DotSize.
Properties
DotSize Property
Applies To DotDensityRenderer Object
Part Description
value A numeric expression that specifies the size in points to draw the dots.
Example This example uses the DotSize property to control the size of the dots in a Dot Density map.
To try this example, paste the code into the Declarations section of a form containing a
TextBox control named Text1, a CommandButton named Command1 and a Map named Map1
that contains one MapLayer with polygon features. You may want to change the Field property
from Pop1990 to the name of a numeric field appropriate to your data and change the
DotValue to a value appropriate to your data. Press F5, enter a new value for the DotSize, and
click the button.
Option Explicit
Private Sub Command1_Click()
With Map1
.Layers(0).Renderer.DotSize = Text1.Text
.Refresh
End With
End Sub
With Map1.Layers(0).Renderer
.Field = Pop1990
.DotSize = 4
.DotColor = moRed
.DotValue = 100000
.DrawBackground = True
End With
End Sub
DotValue Property
Applies To DotDensityRenderer Object
Description Returns or sets the value in the Field associated with a DotDensityRenderer that one dot
represents.
Part Description
Example This example uses the DotValue property to control the value one dot represents in a Dot
Density map. To try this example, paste the code into the Declarations section of a form
containing a TextBox control named Text1, a CommandButton named Command1 and a Map
named Map1 that contains one MapLayer with polygon features. You may want to change the
Field property from Pop1990 to the name of a numeric field appropriate to your data. Press
F5, enter a new value for the DotValue, and click the button.
Option Explicit
Private Sub Command1_Click()
With Map1
.Layers(0).Renderer.DotValue = Text1.Text
.Refresh
End With
End Sub
Text1.Text = 100000
With Map1
Set .Layers(0).Renderer = New MapObjects2.DotDensityRenderer
.Layers(0).Symbol.Color = moPaleYellow
With .Layers(0).Renderer
.Field = Pop1990
.DotSize = 4
.DotColor = moRed
.DotValue = Text1.Text
.DrawBackground = True
End With
End With
.SetFocus
.SelLength = Len(Text1.Text)
End With
End Sub
DragDrop Event
Applies To Map Object
Description The DragDrop event is a standard ActiveX control event, which occurs when an object is
dragged over a Map control and the mouse button is released.
Part Description
X A value of Single data type, specifying the X coordinate of the mouse click,
in control units.
Y A value of Single data type, specifying the Y coordinate of the mouse click,
in control units.
Remarks For more information about the DragDrop event, see the Visual Basic online reference
Note that the DragDrop event is not supported for Map controls with a WindowMode of
Windowless Opaque or Windowless Transparent.
DragFiles Event
Applies To Map Object
Description Occurs when a drag-and-drop operation of filenames is in progress. You can use this event to
monitor the mouse pointer as it enters, leaves, or rests directly over a valid target. The mouse
pointer position determines the target object that receives this event.
Part Description
x, y A number that specifies the current horizontal (x) and vertical (y) position of
the mouse pointer within the target object.
state An integer value or constant that indicates the transition state of the
filenames being dragged in relation to the target Map as indicated in
Settings.
Remarks In order for the corresponding DropFiles event to occur, dropValid must be set to True when
appropriate. The DragFiles event should be used for dragging the names of valid
GeoDatasets onto the Map control, which may then be added programmatically to the Layers
collection.
Note that the DragFiles event is not supported for Map controls with a WindowMode of
Windowless Opaque or Windowless Transparent.
Example This example demonstrates how to add one or more MapLayer objects to a Map by dragging
shapefile entries listed in the Windows Explorer and dropping them directly onto the Map. To
try this example, paste the code into the Declarations section of a form containing a Map
named Map1. Press F5 and then click-drag one or more shapefiles from Windows Explorer
onto the Map. After you release the mouse, the code adds the shapefiles as MapLayer objects,
sorted by ShapeType.
Option Explicit
Private Sub Map1_DragFiles(ByVal fileNames As Object, ByVal X _
As Single, ByVal Y As Single, ByVal state As Integer, dropValid _
As Boolean)
If fileNames.Count > 0 Then
dropValid = True
End If
End Sub
End Sub
DragOver Event
Applies To Map Object
Description The DragOver event is a standard ActiveX control event, which occurs when an object is
dragged over a Map control.
Part Description
X A value of Single data type, specifying the X coordinate of the mouse click,
in control units.
Y A value of Single data type, specifying the Y coordinate of the mouse click,
in control units.
state A value that corresponds to the transition state of the control being dragged
in relation to a target form or control, see Values below.
2 Over source control has moved from one position in the target to
another
Remarks For more information about the DragOver event, see the Visual Basic online reference.
Note that the DragOver event is not supported for Map controls with a WindowMode of
Windowless Opaque or Windowless Transparent.
DragState Constants
MapObjects defines the following constants for use with the Map objects DragFiles event.
moDragEnter 0 Enter (fileNames are being dragged within the range of the
Map).
moDragLeave 1 Leave (fileNames are being dragged out of the range of the
Map).
moDragOver 2 Over (fileNames have moved from one position in the Map to
another).
DrawBackground Property
Applies To DotDensityRenderer Object, EventRenderer Object, GroupRenderer Object, LabelPlacer
Object, LabelRenderer Object
Description Returns or sets a value indicating whether a renderer displays a maps background fill and
polygon outline.
Part Description
value A boolean expression that determines whether the back color and polygon
outline display, as described in Settings.
Setting Description
True The renderer objects back color and polygon outline display.
False The renderer objects back color and polygon outline do not display.
Remarks The DrawBackground method is implemented by all renderers, and is used to indicate
whether the features of a layer should be drawn on the Map before the renderer itself draws to
the Map. You may wish to make use of this property when using a custom renderer, as when
the DrawBackground property is True, the Map will take care of drawing features.
Example This example uses the DrawBackground property to control the background of a Dot Density
map. To try this example, paste the code into the Declarations section of a form containing a
Label named Label1, a ListBox named List1, a CheckBox named Check1, a TextBox named
Text1, and a Map named Map1 that contains one MapLayer with polygon features that have
statistical data associated with them. Press F5 and click the name of a field. You can toggle the
DrawBackground property with the CheckBox.
Option Explicit
With oRenderer
.Field = List1.List(List1.ListIndex)
.DotSize = 4
.DotColor = moRed
.DotValue = Text1.Text
.DrawBackground = Check1.Value
End With
Map1.Refresh
End Sub
With Text1
.Locked = True
.Text =
End With
With Label1
.Caption = 1 dot equals this many units:
.AutoSize = True
.Left = Text1.Left
.Top = Text1.Top - Label1.Height
End With
With Check1
.Left = Text1.Left
.Top = Text1.Top + Text1.Height
.Caption = Draw background
.Value = 1 initialize DrawBackground to True
End With
End Sub
DrawError Event
Applies To Map Object
Part Description
index An integer that uniquely identifies the member of the MapLayers collection
that can not be drawn.
Example This example demonstrates one way to use the DrawError event if the application cant draw
the specified MapLayer because another application has opened the associated Recordset for
writing. To try this example, paste the code into the Declarations section of a form containing
a Map named Map1 that contains a MapLayer. Create an executable that edits the same
GeoDataset as the one associated with the MapLayer. Run the editing application and then run
this example.
Option Explicit
DrawingCanceled Event
Applies To Map Object
Example This example demonstrates the role of the DrawingCanceled event if the user presses ESC
while the map is drawing. To try this example, paste the code into the Declarations section of a
form containing a CommandButton named Command1 and a Map named Map1 that contains
at least one MapLayer, and then press F5. While the map is drawing, press the ESC key. You
can use Command1 to zoom to the full extent of the map.
Option Explicit
DrawShape Method
Applies To Map Object
The DrawShape syntax has the following object qualifier and arguments:
Part Description
Remarks Invoke the DrawShape method in a Layer or TrackingLayer drawing event, otherwise
MapObjects returns an error.
If you specify a Recordset as the shape argument for DrawShape, the method positions the
Recordset at the first record and then draws each feature stored in the Shape field. At the end
of the call, DrawShape positions the Recordset at the first record again.
See Also Point Object, Points Object, Line Object, Rectangle Object, Ellipse Object, Polygon Object
Example This example uses the DrawShape method to draw a shape on the Map. To try this example,
paste the code into the Declarations section of a form containing a Map named Map1. Press
F5 and then click-drag a rectangle on the map.
Option Explicit
Dim rect As MapObjects2.Rectangle
DrawText Method
Applies To Map Object
The DrawText syntax has the following object qualifier and arguments:
Part Description
Remarks If shape is a Line object, DrawText splines the text, using the coordinates of the Line as a
guide. If shape is a Point object, MapObjects centers the text on the point. If shape is a
Rectangle object, MapObjects ignores the VerticalAlignment property and aligns the text
horizontally with the center point of the Rectangle. If shape is a Points object, then the text
will be positioned at the center of the extent of all points in the collection.
Example This example uses the DrawText method to draw some text on the Map. To try this example,
paste the code into the Declarations section of a form containing a Map named Map1 that
contains at least one MapLayer, and then press F5. Note that the height parameter for
DrawText is set to 0; therefore the code will draw the text using the Size property of the
TextSymbol objects Font.
Option Explicit
Dim textsym As New MapObjects2.TextSymbol
fnt.Size = 36
Set textsym.Font = fnt
With textsym
.Color = moLightGray
.Height = 0 use font size (36 points in this case)
.VerticalAlignment = moAlignBaseline
End With
End Sub
DropFiles Event
Applies To Map Object
Description Occurs when you complete a drag-and-drop operation as a result of dragging the source files
over a Map and releasing the mouse button over a valid position on the target.
Part Description
x, y A number that specifies the current horizontal (x) and vertical (y) position of
the mouse pointer within the target object.
Remarks In order for the DropFiles event to occur, dropValid must be set to True in the DragFiles
event when appropriate.
Note that the DropFiles event is not supported for Map controls with a WindowMode of
Windowless Opaque or Windowless Transparent.
Edit Method
Applies To Recordset Object
Syntax object.Edit
Part Description
Remarks Your application should check the Updatable property before calling Edit to determine
whether changes can be made to the Recordset.
When you call the Edit method, the EditMode property changes to moEditInProgress. This
can be used by your application to determine whether changes are being made to a Recordset.
Make sure that any editing operations your program carries out are made to the same
Recordset object for which you called the Edit method. The safest approach is to create a
local Recordset object, on which all the editing operations are carried out. The following
Visual Basic example shows how this can be done for a given MapLayer, called new_layer:
Dim recs As MapObjects2.Recordset
Set recs = new_layer.Records
If recs.Updatable Then
recs.Edit
If recs.EditMode = moEditInProgress Then
Edit feature and attributes
recs.Update
Else
MsgBox Edit failed.
End If
End If
Example See CancelUpdate Method
EditMode Constants
MapObjects defines the following constants for use with the Recordset objects EditMode
property.
EditMode Property
Applies To Recordset Object
Description Returns a value that indicates the state of editing for the current record
Syntax object.EditMode
Part Description
See Also Edit Method, Update Method, Delete Method, EditMode Property
Ellipse Object
An Ellipse object represents an elliptical geometric shape. The Center of an Ellipse object is
a Point that is the center of the bounding Rectangle that defines its Extent. The MapLayer
objects TrackCircle method returns an Ellipse.
You can create an Ellipse object in Visual Basic with code like this:
Set el = New MapObjects2.Ellipse
Properties
Extent
Methods
Enabled Property
Applies To Map Object
Description Returns or sets a value that determines whether an object can respond to user-generated
events.
Part Description
Setting Description
Remarks The Enabled property allows a Map to be enabled or disabled at run time. For example, you
can disable a Map that does not apply to the current state of the application.
EnableGIF Method
Applies To Map Object
Description Enables use of GIF reading when supplied with a valid license code.
Part Description
licenseCode A string expression evaluating to the license code for GIF reading
Remarks In order to use a GIF image as an ImageLayer, you must invoke the EnableGIF method at
the start of your application code, such as in the Initialize or Load event of a form
(Form_Initialize or Form_Load in Visual Basic).
Follow the procedures included with your product packaging for obtaining a valid license
code.
EnableTIFFLZW Method
Applies To Map Object
Description Enables use of TIFF LZW compression for image layers when supplied with a valid license
code.
Part Description
licenseCode A string expression evaluating to the license code for TIF LZW compression
for image layers
Remarks In order to use a TIFF LZW compressed image as an ImageLayer, you must invoke the
EnableTIFFLZW method at the start of your application code, such as in the Initialize or
Load event of a form (Form_Initialize or Form_Load in Visual Basic).
Follow the procedures included with your product packaging for obtaining a valid license
code.
EndMeasureField Property
Applies To EventRenderer Object
Description Returns or sets the field which specifies at which Measure value, along a Line feature, an
event ends.
Part Description
Remarks The EndMeasureField property is only used for rendering Line events. If you have specified
SymbolType to be moPointSymbol, the EndMeasureField is ignored.
EnhancedGeocodingError Constants
MapObjects defines the following constants for use with the Geocoder and Standardizer
objects LastError property.
mgErrorNone 0 No error
mgErrorNoCandidates 14 No candidates
EOF Property
Applies To Recordset Object
Description Returns a value that indicates whether the current record position is after the last record in a
Recordset.
Part Description
isEnd A boolean expression indicating the status of the current record, see Return
Values.
Value Description
Remarks The MoveNext method should not be called when the EOF property is True.
EraseIndices Method
Applies To Geocoder Object
Description Removes the geocoding index file associated with a Geocoder object if the file is not read-
only.
Part Description
Part Description
False The index file cannot be removed due to an error. Use the LastError
property to check the type of error.
Remarks You can use the Geocoder objects IndexStatus method to check if a valid geocoding file
exists before you attempt to remove it.
Event Property
Applies To TrackingLayer Object
Part Description
index An Integer data type index that indicates which GeoEvent to reference.
Example This example uses the Event property to iterate throughout the GeoEvents of a Maps
TrackingLayer in order to determine whether a GeoEvent falls within a selection rectangle. To
try this example, paste the code into the Declarations section of a form containing a Map
named Map1 that contains at least one MapLayer, and then press F5 and click the map to add
GeoEvents. Then hold down Shift and select some of the GeoEvents.
Option Explicit
With Map1.TrackingLayer.Symbol(1)
.Color = moRed
.Style = moTrueTypeMarker
.Font = fnt
.Size = 16
.CharacterIndex = 108
End With
End Sub
Dim pt As MapObjects2.Point
Set pt = Map1.ToMapPoint(x, y)
Map1.TrackingLayer.AddEvent pt, 0
Else
Set r = Map1.TrackRectangle
nEventCount = Map1.TrackingLayer.EventCount
Dim testPt As New MapObjects2.Point
Dim evt As MapObjects2.GeoEvent
For i = 0 To nEventCount - 1
Set evt = Map1.TrackingLayer.Event(i)
testPt.x = evt.x
testPt.y = evt.y
If r.IsPointIn(testPt) Then
evt.SymbolIndex = 1
Else
evt.SymbolIndex = 0
End If
Next i
Map1.Refresh
End If
End Sub
EventCount Property
Applies To TrackingLayer Object
Part Description
count An Integer data type variable that represents the number of GeoEvents on
the TrackingLayer.
Example This example uses the EventCount property to keep a running count of the number of
GeoEvents on the TrackingLayer of a Map. As you add GeoEvents to the TrackingLayer by
clicking on the Map, a Label displays the current count. To try this example, paste the code
into the Declarations section of a form containing a Label named Label1 and a Map named
Map1 that contains at least one MapLayer, and then press F5 and click the map.
Option Explicit
EventRenderer Object
An EventRenderer is an object that represents a way of symbolizing events that occur on
features of a MapLayer, by drawing a Symbol for each event found. Events are only gener-
ated on Line objects, therefore an EventRenderer can only be applied to a MapLayer
consisting of shapes with the Line ShapeType.
You can specify the type of event that the EventRenderer will symbolize by setting the
SymbolType property. For point events this should be set to the moPointSymbol constant
and for linear events, moLineSymbol. The type of event to be rendered will depend on the
information contained in the EventTable.
The renderer displays the events in the EventTable by matching the route Id value of each
event against the features in the MapLayer. The FeatureRouteIDField property specifies the
field in the MapLayers Recordset that contains route ID values and the EventRouteIDField
property specifies the field containing route ID values in the EventTables Recordset.
The measure values for an event determine where it will be displayed on the matching feature
in the MapLayer. An event in an EventTable is specified by values in the
StartMeasureField and EndMeasureField properties. When rendering point events, only
values contained in the StartMeasureField are used, the event is rendered at that measure.
When rendering line events, the event begins at the measure value in StartMeasureField and
continues until the measure value in EndMeasureField.
The symbols used to display events can be based on values held in the EventTable. The
SymbolField property specifies the field that contains a numeric value to match against the
renderers symbol array. By setting its ValueCount property you can determine how many
values of its SymbolField property the EventRenderer will provide a symbol for.
You should then set the properties of each Symbol in the symbol array. In addition, you should
specify which value in the SymbolField corresponds to which Symbol in the symbol array by
setting the value array. For example, if you wish to render events with a value of 75 in the
SymbolField with the first Symbol in the symbol array (Symbol(0)), you should set the first
value in the Value array to equal 75 (Value(0) = 75).
For events in the EventTable which do not have a value in the SymbolField, the
DefaultSymbol will be used if the UseDefault property is True. If the SymbolField property
is not set, or the field cannot be found, then all symbols will be rendered with the
DefaultSymbol.
When using large datasets with large numbers of events, displaying the MapLayer with an
EventRenderer may become a time consuming operation. In order to manage the rendering of
large numbers of events more efficiently, you can use the IndexEvents and IndexExtent
properties, and the InvalidateIndex method. You can control the way in which the
EventRenderer accesses the Event information, decreasing the time your MapLayer takes to
draw.
Properties
Methods
InvalidateIndex
Example This example demonstrates the use of the EventRenderer and its properties. To try this
example, paste the code into the Declarations section of a form containing a Map control
named Map1 containing one MapLayer with lines which have measure values, and a Com-
mand Button named Command1. This example uses an EventTable from Excel 97 with Fields
called ROUTE, EVENT1, EVENT2 and SYMBOL. You should change the Fields,
Values, fName and Database as appropriate for your EventTable. Press F5 and click Com-
mand1.
Option Explicit
Screen.MousePointer = moHourglass
With evRend
.DrawBackground = True
.ValueCount = 3
.SymbolType = moLineSymbol
.DefaultSymbol.SymbolType = moLineSymbol
.DefaultSymbol.Style = moDashLine
.DefaultSymbol.Color = moRed
.DefaultSymbol.Size = 1
.Color = moCyan
End With
.EventTable = evTab
Map1.Refresh
Screen.MousePointer = moDefault
End Sub
EventRouteIDField Property
Applies To EventRenderer Object
Part Description
Remarks The EventRouteIDField property is used to specify which Field in the EventTable contains
route ID information. The EventRouteIDField and FeatureRouteIDField should contain
similar values.
If the EventRouteIDField property contains a value which does not match with any value in
the FeatureRouteIDField, no event will be rendered.
EventTable Property
Applies To EventRenderer Object
Description Returns a reference to the EventTable used to draw the events on a MapLayer which has an
EventRenderer set. The EventTable property references a MapObjects2 Table object.
Part Description
Export Method
Applies To Recordset Object, GeoCoordSys Object, ProjCoordSys Object
Description For Recordset objects, the Export method writes the Recordset to a GeoDataset, creating a
Shapefile. For GeoCoordSys or ProjCoordSys objects, the Export method writes a .prj file
that describes the coordinate system itself.
object.Export ( outName )
Part Description
outName A string expression that evaluates to the full path and file name on disk for
the exported file.
outCoordSys Optional. Used with Recordset objects only. If this parameter is used, the
Recordset is exported into the coordinate system defined. May be of type
GeoCoordSys or ProjCoordSys.
When used with ProjCoordSys or GeoCoordSys objects, the Export method makes it
possible to store the details of how a shapefile or SDE layer should be projected when added
as a MapLayer in MapObjects. For shapefiles, this information can be stored separately in a
Projection file (.prj) alongside the GeoDataset on disk. The prj file should have the same
filename as the shapefile, and the .prj extension. When MapObjects reads a GeoDataset based
on a shapefile with a prj file present, the GeoDataset will be held transformed into that
coordinate system.
For SDE layers, the projection information is stored in the layers definition table. The
projection files used with shapefiles and SDE layers are the only form of projection metadata
which can be written by MapObjects. Projection files used with coverages must be generated
using ARC/INFO, not using the MapObjects Export method.
Recordset Objects
When exporting a Recordset, the Shapefile created will support Z and Measure values only if
the GeoDataset that underlies the Recordset itself has support for Z and Measure values.
Your program can check this using the HasZ and HasMeasure properties of the GeoDataset
object. Shapefiles with support for Z and Measure values are only fully supported as of
ArcView 3.1 and MapObjects 2.0. In some cases, older applications may not be able to read
such Shapefiles. If you intend to use geographic data transformed in MapObjects with older
applications, an alternative is to use the AddGeoDataset method to create a new GeoDataset
with the required Z and Measure support and then to copy features to it, transforming them if
required.
Example This example uses the Export method of the Recordset object to export a MapLayer to a
shapefile, transformed to a different coordinate system. The exported MapLayer is added to
the Map for comparison with the untransformed MapLayer. To try this example, paste the code
into the Declarations section of a form containing a CommandButton named Command1, a
CommonDialog control named CommonDialog1, a Combo Box named Combo1 and a Map
named Map1, containing one MapLayer which has a coordinate system set. Press F5, and then
click Command1.
Option Explicit
Dim newLayer As New MapObjects2.MapLayer
Dim coordSys As New MapObjects2.ProjCoordSys
CommonDialog1.ShowSave
name = Combo1.List(Combo1.ListIndex)
coordSys.Type = stripProj(name)
newLayer.GeoDataset = Map1.Layers(0).Records.Export _
(CommonDialog1.FileName, coordSys)
With newLayer.Symbol
.Style = moLightGrayFill
.Color = moYellow
End With
If newLayer.Valid Then
Map1.Layers.Add newLayer
Map1.Extent = Map1.FullExtent
Else
MsgBox New maplayer is not valid, vbExclamation, _
Invalid MapLayer
End If
End Sub
CommonDialog1.InitDir = App.Path
CommonDialog1.DialogTitle = Export Projected Shapefile
CommonDialog1.Filter = Shapefiles (.shp)|*.shp
With Map1.Layers(0).Symbol
.Style = moSolidFill
.Color = moDarkGreen
End With
End Sub
ExportMap Constants
MapObjects defines the following constants for use with the Map objects ExportMap
method to specify what type of file to export.
ExportMap Method
Applies To Map Object
Description Writes the visible extent of the Map to the specified file in Windows Bitmap or enhanced
metafile format.
Part Description
format A value or constant that determines the format of the exported file, as
described in Settings.
formatData A string expression that evaluates to the full path and file name on disk for
export files. For Clipboard formats, indicates whether or not to clear the
Clipboard. True clears the Clipboard, False prevents the clear.
See Also CopyMap Method, ExportMap2 Method, OutputMap Method, OutputMap2 Method,
PrintMap Method
Example This example uses the ExportMap method to export the visible extent of a Map to the speci-
fied file in enhanced metafile format. To try this example, paste the code into the Declarations
section of a form that contains a CommonDialog control named CommonDialog1, a
CommandButton named Command1, and a Map named Map1 that contains at least one
MapLayer, and then press F5; click Command1. Specify the folder and name of the file where
you want to export the Map. Note: If the Map you want to export contains any ImageLayer
that has an image depth greater than 8 bits per pixel, and you want to honor its palette, use
ExportMap2 and set its useSourceDepth parameter to True.
Option Explicit
Private Sub Command1_Click()
CommonDialog1.DefaultExt = *.emf
CommonDialog1.Filter = Enhanced Metafile (*.emf)|*.emf
CommonDialog1.FileName = map1.emf
CommonDialog1.CancelError = True
On Error Resume Next
CommonDialog1.ShowSave
If Err.Number = cdlCancel Then Cancel button pressed
Err.Clear
Exit Sub
End If
Map1.ExportMap moExportEMF, CommonDialog1.FileName, 2
End Sub
ExportMap2 Method
Applies To Map Object
Description Writes the visible extent of the Map to the specified file in Windows Bitmap or enhanced
metafile format, and allows an output source depth to be specified.
Part Description
format A value or constant that determines the format of the exported file, as
described in Settings.
Exporting to a file: the full path and file name on disk for export files.
Remarks ExportMap2 gives you the ability to export 16 and 24-bit truecolor bitmaps. When using the
WebLink object (supplied with MapObjects Internet Map Server) it should be noted that only
8 bit color bitmaps can be converted a JPEG with the Bmp2JPEG method.
See Also CopyMap Method, ExportMap Method, ExportMap2 Method, OutputMap Method,
OutputMap2 Method, PrintMap Method
ExtendedError Property
Applies To DataConnection Object
Description Returns a value that represents any ExtendedErrors returned from an RDBMS while access-
ing SDE layers.
Part Description
Return Values The value that is returned for this property is that raised by the Relational Database Manage-
ment System underlying your SDE instance. You should check your RDBMS manuals for
more information about the exact cause and meaning of the returned value.
See Also Connect Method, Connected Property, ConnectError Property, Disconnect Method,
ExtendedErrorString Property
ExtendedErrorString Property
Applies To DataConnection Object
Description Returns a value that represents any ExtendedErrorString returned from an RDBMS while
accessing SDE layers.
Part Description
Return Values The descriptive string that is returned for this property is that raised by the Relational Data-
base Management System underlying your SDE instance. You should check your RDBMS
manuals for more information about the exact cause and meaning of the returned description.
See Also Connect Method, Connected Property, ConnectError Property, Disconnect Method,
ExtendedError Property
Extent Property
Applies To Ellipse Object, ImageLayer Object, Line Object, Points Object, Map Object, MapLayer
Object, Polygon Object
Description Returns or sets the spatial extent of an object. The property is read-only for all objects to
which it applies, with the exception of the Map object and MapLayers derived from SDE.
Part Description
Remarks In Visual Basic you may wish to use the Extent property to zoom in on a map. Below, a code
fragment shows you how you might do this in the Maps MouseDown event:
Dim r as New MapObjects2.Rectangle
Set r = Map1.TrackRectangle
Set Map1.Extent = r
You should bear in mind that you cannot set a Maps Extent to be outside its FullExtent. If
you are setting the Map.Extent properties e.g. ,
Set Map.Extent = Rectangle)
you should be sure that the Left, Right, Top and Bottom properties of your Rectangle are
within the Maps FullExtent. If at least one of the properties lies outside of the FullExtent,
then the Map.Extent change will not be successful, and none of the Map.Extent.Left,
Map.Extent.Right, Map.Extent.Top, or Map.Extent.Bottom will change.
Example The following example uses the Extent property to set what portion of the Map is visible.
When you run the code, the ScaleRectangle method scales the Rectangle that defines the
Extent of the Map and the code resets the Extent accordingly. To try this example, paste the
code into the Declarations section of a form containing a CommandButton named Command1
and a Map named Map1 that contains at least one MapLayer or ImageLayer. Press F5 and then
click Command1.
Option Explicit
End Sub
Factor Property
Applies To Unit Object
Description Sets or returns a value that specifies the conversion Factor between meters and the Unit
specified by the Type property. For example, the Foot Unit has a factor of 0.3048.
Part Description
Example This example uses the factor property of different unit objects to build a chart. To try this
example, paste the following code into the Decalrations section of a new project, which
contains an MS Chart control. Press F5 to see a bar-chart displaying the different Factors of
the pre-defined Unit objects. Try changing the Maximum Y Axis value of the Chart to see
more detail.
Option Explicit
.ColumnLabelCount = unitObjs.Count
.ShowLegend = False
.Plot.Axis(VtChAxisIdY).AxisScale.Type = VtChScaleTypeLinear
For j = 0 To unitObjs.Count - 1
.Column = j + 1
.Data = arrChart(j + 1, 2)
.ColumnLabel = arrChart(j + 1, 1)
Next j
.ShowLegend = True
End With
End Sub
FeatureRouteIDField Property
Applies To EventRenderer Object
Part Description
Remarks The FeatureRouteIDField property is used to specify which Field in the MapLayers
GeoDataset contains route ID information. The EventRouteIDField and
FeatureRouteIDField should contain similar values.
If the FeatureRouteIDField property contains a value which does not match with any value in
the EventRouteIDField, the event will be rendered with the DefaultSymbol if the
UseDefault property is True.
Field Object
A Field object represents a column of data within a Recordset with a common data type and a
common set of properties. Each Field has a Name, which is the default property for a Field
object. The Type property returns a value representing what type of data the field contains:
string, long, double, Boolean, date, empty, point, line, and polygon.
You can return the contents of a Field as a Variant for a particular Record with the Value
property or return the value of the Field, regardless of its type, as a String with ValueAsString
property.
Remarks To distinguish a MapObjects Field from a Visual Basic Field, fully qualify the class name in
declarations, for example:
Dim fld as MapObjects2.Field
Properties
Type
Field Property
Applies To ChartRenderer Object, ClassBreaksRenderer Object, DotDensityRenderer Object,
LabelPlacer Object, LabelRenderer Object, ValueMapRenderer Object
object.Field [= value]
Part Description
value A string expression that specifies a name of a field in the Recordset of the
MapLayer on which the renderer is set. Each renderer in the Applies To list
makes use of the value of the specified field.
Part Description
value A string expression that evaluates to the required value for the renderer.
Remarks The Field property sets the Fields of the MapLayers Recordset which are used by the
renderer to determine how each feature in the MapLayer is displayed.
Example This example demonstrates the use of the Field property in association with a
ClassBreaksRenderer object to create a graduated symbol map. To try this example, paste the
code into the Declarations section of a form containing a ComboBox named Combo1 and a
Map named Map1 that has a MapLayer that represents point features. Press F5 and then select
a numeric field.
Option Explicit
With oRenderer
.Field = sFieldName
.SymbolType = moPointSymbol
.BreakCount = 2
For i = 0 To oRenderer.BreakCount
.Symbol(i).Style = moCircleMarker
.Symbol(i).Color = moRed
Next i
.Break(0) = oStats.Mean
.Break(1) = oStats.Max - oStats.Mean * 0.5
.SizeSymbols 4, 18
End With
Map1.Layers(0).Renderer = oRenderer
Map1.Refresh
End If
End Sub
Combo1.ListIndex = -1
Combo1.Text =
End Sub
FieldCount Property
Applies To ChartRenderer Object, TableDesc Object, Standardizer Object
Description Returns or sets the number of Field objects described in a TableDesc object, or returns the
number of FieldNames found in the standardization rule file associated with the
StandardizingRules or IntersectionStandardizingRules properties of the Standardizer
object.
Part Description
Remarks The number of FieldNames in the rule file set to the StandardizingRules property can be
different from the rule file set to the IntersectionStandardizingRules property. When a
regular address is standardized using the StandardizeAddress method, the
StandardizingRules will be used. When a street intersection address is standardized, the
IntersectionStandardizingRules will then be used. The FieldCount value changes at run
time depending on what addresses are assigned to the StandardizeAddress method.
See Also Recordset Object, Field Object, FieldName Property, FieldValue Property
FieldLength Property
Applies To TableDesc Object
Description Returns or sets the field length of a string or character Field described by a TableDesc object
associated with a Recordset.
Part Description
index A numeric expression that specifies the relative position of a member of the
group of FieldLength values associated with the TableDesc object. Index
must be a number from 0 to a number that is one less than the value of the
TableDesc objects FieldCount property.
value A numeric expression that specifies the length of a string or character Field
in a Recordset.
Remarks For character data, the FieldLength does not include the null termination byte. Note that the
length of a column may be different than the number of bytes required to store the data on the
data source.
Note also that dBASE files (.dbf) limit field names to 10 characters. Fields with longer names
will be truncated.
FieldName Property
Applies To TableDesc Object, Standardizer Object
Description Returns or sets a user-defined name for a Field described by a TableDesc object associated
with a Recordset, or returns the name of the match key field found in the standardization rule
file associated with the StandardizingRules or IntersectionStandardizingRules properties
of the Standardizer object.
Part Description
index A numeric expression that specifies the relative position of a member of the
group of FieldName values associated with the TableDesc or Standardizer
object. Index must be a number from 0 to a number that is one less than the
value of the TableDesc or Standardizer objects FieldCount property.
value A string expression that specifies the name of the Field in a Recordset.
Remarks For Standardizer objects, the field names are associated with the standardization rule files.
Each name is a unique two letter word such as HN. They were defined in the standardization
rule .dct file. By convention, HN stands for house number and SN for street name.
See Also Recordset Object, Field Object, FieldCount Property, FieldValue Property
FieldPrecision Property
Applies To TableDesc Object
Description Returns or sets the maximum number of digits used by the data type of a Field described by a
TableDesc object associated with a Recordset.
Part Description
index A numeric expression that specifies the relative position of a member of the
group of FieldPrecision values associated with the TableDesc object. Index
must be a number from 0 to a number that is one less than the value of the
TableDesc objects FieldCount property.
Remarks The precision of a numeric Field refers to the maximum number of digits used by its data type.
The precision of a nonnumeric field generally refers to either the maximum length or the
defined length of the field. The maximum FieldPrecision allowable is 19.
Fields Collection
A Fields object contains a collection of each Field object in a Recordset object. To access a
particular Field in the collection, use the default property, Item, for example:
aString = Records.Fields.Item(Name).ValueAsString
or,
aString = Records.Fields(Name).ValueAsString
Remarks To distinguish a MapObjects Fields collection from a Visual Basic Fields collection, fully
qualify the class name, for example:
Dim flds as MapObjects2.Fields
Fields Property
Applies To Recordset Object
Description Returns all stored Field objects of the Fields collection of a Recordset.
Syntax object.Fields
Part Description
Example This example uses the Fields Property to list the names of the fields associated with a
MapLayers Recordset. To try this example, paste the code into the Declarations section of a
form containing a CommandButton named Command1, a ListBox named List1, and a Map
named Map1 that has at least one MapLayer. Press F5 and then click Command1 to see the list
of field names.
Option Explicit
FieldScale Property
Applies To TableDesc Object
Description Returns or sets the maximum number of digits to the right of the decimal point of a numeric
Field described by a TableDesc object associated with a Recordset.
Part Description
index A numeric expression that specifies the relative position of a member of the
group of FieldScale values associated with the TableDesc object. Index
must be a number from 0 to a number that is one less than the value of the
TableDesc objects FieldCount property.
value A numeric expression that specifies the maximum number of digits to the
right of the decimal point of a numeric Field in a Recordset.
Remarks For approximate floating point number fields, the FieldScale is undefined, since the number of
digits to the right of the decimal point is not fixed. For the SQL_DECIMAL and
SQL_NUMERIC data types, the maximum scale is generally the same as the maximum
precision. However, some data sources impose a separate limit on the maximum scale.
FieldType Constants
MapObjects defines the following type constants for use with the Field objects Type property
and the TableDesc objects FieldType property
moNone 0 None
moLong 3 Long
moDouble 5 Double
moDate 7 Date
moString 8 String
moBoolean 11 Boolean
moPoint 21 Point
moLine 22 Line
moPolygon 23 Polygon
FieldType Property
Applies To TableDesc Object
Description Returns or sets the type of Field described by a TableDesc object associated with a
Recordset.
Part Description
index A numeric expression that specifies the relative position of a member of the
group of FieldType values associated with the TableDesc object. Index
must be a number from 0 to a number that is one less than the value of the
TableDesc objects FieldCount property.
Example This example uses the MapObjects FieldTypeConstants, and creates a list of details from a
MapLayers Recordset. To try this example, paste the code into the Declarations section of a
form that contains a ListBox named List1, and change the path of the database, and the
FindGeoDataset method. Then press F5.
Option Explicit
dc.Connect
Dim i As Integer
Dim field As MapObjects2.field
Dim fldString As String
List1.AddItem Field Name & Chr(9) & Field Type & Chr(9) & _
Constant
Case moPoints
fldString = fldString & Chr(9) & Chr(9) & Points
Case moPolygon
fldString = fldString & Chr(9) & Chr(9) & Polygon
Case moString
fldString = fldString & Chr(9) & Chr(9) & String
End Select
List1.AddItem fldString
Next i
End If
End Sub
FieldValue Property
Applies To Standardizer Object
Description Returns or sets the values in the FieldName properties of a Standardizer, after an address is
standardized.
Part Description
value A string expression that specifies the value in the field name.
Remarks The Standardizer objects FieldName property returns the names of the match key fields, the
FieldValue returns a standardized values of an address for each FieldName. When searching
a Geocoder objects StreetTable, the FieldName is used as a search key. FieldName values
can be read at run time from a valid Standardizer, or found in the appropriate .dct file.
You can override the values returned by the Standardizer by setting new values to the match
key fields if you wish to.
For example, the StandardizeAddress method of the Standardizer object will only parse an
address 270 North Main Avenue into the HN, PD, PT, SN, ST, and SD, as no zip code is
present in the address. If you wish the address to contain a zone, you would manually specify
the value for a field named ZN using the objects FieldValue property, for example,
stan.FieldValue(ZN) = 53702
Similarly, you can override the FieldValue of existing FieldNames which are the result of
standardization by setting a new value to the field. For example, the Standardizer may return
Ave for the street type (ST) field. You can change it to Av if you prefer by setting the new
value to the FieldValue (ST) property.
File Property
Applies To ImageLayer Object
Description Returns or sets the path and filename of an image file displayed by an ImageLayer.
Part Description
pathname A string expression that specifies the path and filename associated with an
ImageLayer.
Example This example uses the File Property to specify the file associated with an ImageLayer. In this
case, the code displays the Common FileDialog to set the File associated with the image to
add. To try this example, paste the code into the Declarations section of a form containing a
CommonDialog Control and a Map named Map1 that has at least one MapLayer located in the
same geographic coordinate space as the image to be added. Press F5, then specify the image
to add. Make sure that the image has an associated world file.
Option Explicit
Image(*.tif)|*.tif
CommonDialog1.FilterIndex = 1
CommonDialog1.ShowOpen
End If
End Sub
FillStyle Constants
MapObjects defines the following constants for use with fill symbols.
moSolidFill 0 Solid
moTransparentFill 1 Transparent
moHorizontalFill 2 Horizontal
moVerticalFill 3 Vertical
moCrossFill 6 Cross
FilterExpression Property
Applies To MapLayer Object
Description This property sets or returns an SQL statement to limit the amount of information that is
returned from an SDE layer.
Part Description
filter A string expression that specifies the filter expression to be used with the
MapLayer.
Remarks FilterExpression is intended for use with SDE, where much of the processing may be carried
out on the server, although the filter will also work with MapLayers based on shapefiles. It
can be used to limit the amount of information being returned from the SDE server, improving
the performance of your application.
When using a FilterExpression, the Count property may no longer be used on the MapLayer
objects Recordset, as there is no header information available to determine the correct record
Count. In these cases, to obtain the correct Count of the Recordset, a Statistics object should
be created from the Recordset, and the number of records taken from the Count property of
this Statistics object.
Example This example sets the FilterExpression property to limit which features of the MapLayer are
visible. The FilterFields property is used to limit the fields which are available to perform the
FilterExpression on. To try this example, paste the code into the Declarations section of a form
containing three OptionButtons named Option1, Option2, and Option3, a ListBox named
List1, a TextBox named Text1, a CommandButton named Command1 and two CheckBoxes
named Check1 and Check2. Ensure that the properties of the DataConnection are set correctly
for your SDE instance, and that a points layer is available. Now press F5. Selecting and
deselecting the Filter Strings checkbox will limit the fields listed in the ListBox to non-string
types. Click on a Field, select an operator, and enter a value in the TextBox, then press the
CommandButton.
Option Explicit
Map1.Refresh
listFields Map1.Layers(0).Records
Screen.MousePointer = vbDefault
End Sub
exp = List1.List(List1.ListIndex)
If Option1 Then
exp = exp & Option1.Caption
ElseIf Option2 Then
exp = exp & Option2.Caption
ElseIf Option3 Then
exp = exp & Option3.Caption
End If
exp = exp & Text1.Text
Map1.Layers(0).FilterExpression = exp
Map1.Refresh
End Sub
If dc.Connect Then
Dim gs As Object
For Each gs In dc.GeoDatasets
Set rs = layer.Records
List is created of all Fields, for use in FilterExpression
listFields rs
All strings fields are added to a list for us in FilterFields
filterStrings rs
Map1.Layers.Add layer
Exit For
End If
Next gs
Else
MsgBox Connection Error
End If
End Sub
InStrL = iLastPos
End Function
FilterFields Property
Applies To MapLayer Object
Description This property returns or sets a Strings object that contains the name of a number of Fields.
When this property is set, only the Fields in the Strings object will be returned from SDE.
Part Description
fields A object expression that evaluates to a Strings object, listing the Fields to
filter on for the MapLayer.
Remarks FilterFields only works with a SDE layers. It can be used to limit the amount of information
being returned from the SDE server, improving the performance of your application.
See Also FilterExpression Property, FilterOperator Property, FilterOrder Property, Strings Object
FilterOperator Property
Applies To MapLayer Object
Description This property works in conjunction with the FilterShape property, and returns or sets the type
of FilterShape operation used in the filter.
Part Description
Remarks FilterOperator and FilterShape are intended for use with SDE, where much of the process-
ing may be carried out on the server, although the filter will also work with MapLayers based
on shapefiles.
Example This example sets the FilterShape and FilterOperator properties to limit which features of the
MapLayer are visible. To try this example, paste the code into the Declarations section of a
form containing a Map named Map1 and four OptionButtons named Option1, Option2,
Option3 and Option4. Ensure that the properties of the DataConnection are set correctly for
your SDE instance. Press F5, and track a polygon onto the map. Try clicking different
OptionButtons to use different FilterOperator constants in the Filter.
Option Explicit
If dc.Connect Then
Dim gs As Object
For Each gs In dc.GeoDatasets
Here, the first Polygon dataset found is added to the map as _
a layer.
Dim dataName As String
Dim i As Integer
i = InStrL(gs.Name, .)
dataName = Right(gs.Name, Len(gs.Name) - i)
If dataName = Points Then
Dim layer As New MapObjects2.MapLayer
layer.GeoDataset = gs
Map1.Layers.Add layer
Exit For
End If
Next gs
Else
MsgBox Connection Error
End If
Option1.Value = True
Option1.Caption = Method: Area Intersect
Option2.Caption = Method: Contained By
Option3.Caption = Method: Containing
Option4.Caption = Method: Extent Overlap
End Sub
InStrL = iLastPos
End Function
If Option1.Value Then
operator = 6
ElseIf Option2.Value Then
operator = 8
ElseIf Option3.Value Then
operator = 9
ElseIf Option4.Value Then
operator = 0
End If
Map1.Layers(0).FilterOperator = operator
Map1.Refresh
End Sub
FilterOrder Constants
MapObjects defines the following constants for defining the filter order when defining filters
on MapLayers.
See Also MapLayer Object, FilterOrder Property, FilterExpression Property, FilterShape Property
FilterOrder Property
Applies To MapLayer Object
Description This property returns or sets the order that filter operations are carried out by SDE.
Part Description
Remarks This property will only affect a MapLayer that is an SDE layer with more than one filter set
on it. You should set the property to optimize the filter performance. For example, if your layer
has a FilterExpression set which eliminates the majority of the layer, then you can ensure this
expression is applied before the FilterShape is applied, by using the moAttributeFirst
FilterOrder Constant.
FilterShape Property
Applies To MapLayer Object
Part Description
filterShape A variant expression that specifies a shape to use as a filter for the
MapLayer
Remarks When setting a FilterShape on a MapLayer, you should first set the FilterOperator to the
appropriate SearchMethodConstants.
FilterOperator and FilterShape are intended for use with SDE, where much of the process-
ing may be carried out on the server, although the filter will also work with MapLayers based
on shapefiles. It can be used to limit the amount of information being returned from the SDE
server, improving the performance of your application.
If your MapLayer contains features with Z values, you can use a three-dimensional Rect-
angle as your filter shape. Features are filtered based on their Z coordinates, in addition to
Find Method
Applies To Strings Collection
Part Description
startpos An optional numeric expression that indicates the index position from which
to start the search. If startpos is omitted, Find starts at the first index
position.
Remarks If itemName is not in the Strings collection or no more instances of itemName are in the
collection from startpos to the last member of the collection, Find returns -1.
You can use startpos to find the next instance of itemName in the collection.
Example This example uses the Find method to count how many instances of a string are in a Strings
collection. Find returns the index position of the string and may be used for a variety of
purposes in MapObjects, perhaps most usefully for determining the position of an argument.
To try this example, paste the code into the Declarations section of a Form that contains a Map
named Map1. Press F5.
Option Explicit
With sMyStrs
.Unique = False allows multiple instances to be added
.Add pears
.Add apples
.Add peaches
.Add bananas
.Add apples
.Add guavas
.Add plums
.Add apricots
End With
iNumFound = 0
idx = sMyStrs.Find(apples) start at the beginning of the
collection
FindAllPlaceNames Method
Applies To PlaceLocator Object
Description Finds all place names that begin with the specified characters and returns them in upper case
as members of a Strings collection.
Part Description
prefix A string expression that specifies the first characters in the place names to
search for.
Remarks You may wish to use the FindAllPlaceNames method if the first characters of a place name
are known but the remainder of the names spelling is unsure, and the
FindApproximateMatches method does not return any successful matches.
Example This example uses the Locate method and the FindAllPlaceNames method to locate place
names. You will need to change the GeoDataset name, the field name on which to build the
index, and the path for the DataConnection to point to the correct locations and names for your
data. To try this example, paste the code into the Declarations section of a form that contains a
Map with a MapLayer containing a place name field, a TextBox named Text1, a
CommandButton named Command1, a CheckBox named Check1, and a ListBox named List1
(set the Multi-Select property to 2). Press F5 and try typing an exact placename, or the first
few characters, in Text1 and press the CommandButton. Red point symbols are drawn at the
matched place locations. Matches display in the ListBox; double-click on a name in the list to
flash it on the map, or select several names from the list and then double-click.
Option Explicit
Dim pl As New Mapobjects2.PlaceLocator
Dim pts As Mapobjects2.Points
Dim gdname As String
Dim fldname As String
Public places As New Collection
List1.Clear
attempt an exact match of the place name
Set pts = pl.Locate(Text1.Text)
If weve found one or many exact matches, add then to the List
If pts.Count > 0 Then
End Sub
Command1.Caption = Locate
Text1.Text =
Check1.Caption = Approximate match
Check1.Value = 0
End Sub
For i = 1 To places.Count - 1
Set result = Map1.Layers(0).SearchShape(places(i), _
moPointInPolygon, )
Map1.FlashShape result.Fields(shape).Value, 4
If places.Count > 1 Then
Dim res As Integer
res = MsgBox(Flash another place?, vbYesNo, MapObjects)
If res = vbNo Then
Exit For
End If
End If
Next i
End If
End Sub
FindApproximateMatches Method
Applies To PlaceLocator Object
Description Finds approximate matches for the specified name and returns the results in upper case as a
Strings collection.
Part Description
variable An object expression that evaluates to a Strings collection that contains the
results of the methods action.
name A string expression that specifies the street name or place name to find
approximate matches for.
FindArcInfoCoordinateSystem Method
Applies To DataConnection Object
Part Description
Remarks ARC/INFO stores information about a coverages coordinate system in a PRJ file within the
workspace directory. The file is an ASCII text file, and contains parameters describing the
projection, units and projection-specific parameters of the coordinate system. The file may
also contain optional parameters describing the datum, spheroid or z units of the coordinate
system (among others).
Example This example uses the FindArcInfoCoordinateSystem method. To try this example, paste the
code into the Declarations section of a form containing a DirListBox control Dir1, a
CommandButton named Command1 and a Label named Label1. Press F5 and then navigate
through the folders in the Directory list to a folder that contains a coverage with projection
information.
Option Explicit
path = Dir1.path
FindCoordinateSystem Method
Applies To DataConnection Object
Description Locates a coordinate system, and creates either a GeoCoordSys or ProjCoordSys object.
Part Description
name A string expression that evaluates to the name of a coordinate system (.prj)
file, situated in the DataConnections Database location.
Remarks Coordinate system information for a shapefile is stored in a separate file, in the same location
as the shapefile. The metadata file has the same file name as the shapefile, with a .prj exten-
sion. If the FindCoordinateSystem method finds a prj file of the specified name, the prj file
is read and a ProjCoordSys or GeoCoordSys object is created. To determine the type of
coordinate system that has been returned, you can check the IsProjected property of the
returned variable. If no coordinate system is found, the variable is not set.
Example This example uses the FindCoordinateSystem method. To try this example, paste the code into
the Declarations section of a form containing a Common Dialog control named
CommonDialog1, a ListBox named List1 and CommandButton named Command1. Press F5,
click Command1, and then navigate through the folders in the Dialog Box to find a prj file.
Select the required prj file and press Open.
Option Explicit
CommonDialog1.ShowOpen
dc.Database = path
If Not dc.Connect Then
MsgBox Could not connect to database & Chr(13) & dc.ConnectError
Else
List1.Clear
Set foundProj = dc.FindCoordinateSystem(CommonDialog1.FileTitle)
If foundProj Is Nothing Then
List1.AddItem No projections of that name found
Else
List1.AddItem foundProj.Name
List1.AddItem foundProj.Type
End If
End If
End Sub
FindEvent Method
Applies To TrackingLayer Object
Description Finds a GeoEvent object on the TrackingLayer using its Tag property value
Part Description
FindGeoDataset Method
Applies To DataConnection Object
Part Description
Remarks If you call FindGeoDataset and the DataConnection is not connected, MapObjects will
automatically attempt to Connect first. However, it is recommended that the Connect method
is called first, to allow the application to handle potential connection errors. If no GeoDataset
is found, the variable is not set.
Example This example uses the DataConnection objects FindGeoDataset method to associate a
GeoDataset with a MapLayer. The code then adds the MapLayer to a Map. To try this ex-
ample, paste the code into the Declarations section of a form containing a CommonDialog
control, a CommandButton named Command1 and a Map named Map1. Press F5 and then
click Command1. In the Open dialog that displays, navigate to a folder that contains shapefiles
and select one.
Option Explicit
With CommonDialog1
sFileDirectory = Left$(.FileName, InStr(.FileName, .FileTitle) - 1)
End With
With dc
.Database = sFileDirectory the directory containing the
selected file
If .Connect Then
sDataSetName = Mid(strFileTitle, 1, Len(strFileTitle) - 4)
remove the extension
Set lyr.GeoDataset = dc.FindGeoDataset(sDataSetName)
Map1.Layers.Add lyr
Else
MsgBox Data Connection error # & dc.ConnectError, vbExclamation
End If
End With
End If
Set dc = Nothing
Set lyr = Nothing
End Sub
Fitted Property
Applies To TextSymbol Object
Description Returns or sets a value indicating whether to adjust the gap between characters of a
TextSymbol object so that it fits between two points of a Line.
Part Description
boolean A boolean expression specifying whether to adjust the gap between charac-
ters of a TextSymbol object so that it fits between two points of a Line, as
described in Settings.
Setting Description
True MapObjects will adjust the gap between characters of the TextSymbol
object to fit it between a two-point Line specified by DrawText or the two-
point Line associated with the text drawn by a LabelRenderer.
False (Default) MapObjects will not adjust the gap between characters of the
TextSymbol object.
Remarks If the width of the character string is less than the distance between the points, MapObjects
will increase the gap between characters.
Fitted does not affect the height and width of the text. It only adjusts the gap between charac-
ters.
Example This example uses the Fitted property of the TextSymbol to control whether or not to adjust
the gap between characters of a text string positioned in relation to a two-point line. To try this
example, paste the code into the Declarations section of a form containing a CheckBox named
Check1 and a Map named Map1. Press F5 and then track a two-point line on the Map. Toggle
the CheckBox to see the effect of the property.
Option Explicit
Dim oLine As MapObjects2.Line
Dim oTSym As New MapObjects2.TextSymbol
End Sub
FittedField Property
Applies To LabelRenderer Object
Description Returns or sets the Field that contains information for whether or not to fit text between two-
point Line features for a LabelRenderer object.
Part Description
Remarks The property is especially useful when rendering ARC/INFO annotation features. See the
ARC/INFO documentation for the ANNOFIT command and the $FIT pseudo item.
The FittedField of a LabelRenderer always takes precedence over the setting of the Fitted
property of its Symbol collection.
Example This example uses the XOffsetField property, the YOffsetField property, and the FittedField
property to determine the characteristics of the labels of a LabelRenderer associated with a
MapLayer. Each of the properties specifies the name of a field in the Recordset associated
with the MapLayer. The field contains a value for each record that provides information for
the LabelRenderer. Commonly, this technique is useful when working with ARC/INFO
coverages that have annotation features. This example assumes that the GeoDataset associated
with the MapLayer is an ARC/INFO coverage that contains annotation features and has
appropriate fields. To try this example, paste the code into the Declarations section of a form
containing a Map named Map1 that contains a MapLayer based on a GeoDataset that is an
ARC/INFO coverage with annotation features (although you can use other kinds of
GeoDatasets as well), three ComboBox controls named Combo1, Combo2, Combo3, and a
CommandButton named Command1. The Form_Load event code will set the caption of the
CommandButton to Label. Press F5. In each combo box, select the name of the field
described. You dont have to select all three fields, if your data doesnt have appropriate fields.
Click the Label button to display the text.
Option Explicit
With oRenderer
.Field = name
.AllowDuplicates = False
If Combo1.ListIndex <> -1 Then .XOffsetField = Combo1.Text
If Combo2.ListIndex <> -1 Then .YOffsetField = Combo2.Text
If Combo3.ListIndex <> -1 Then .FittedField = Combo3.Text
End With
Map1.Refresh
End Sub
Combo1.ListIndex = -1
Combo2.ListIndex = -1
Combo3.ListIndex = -1
Command1.Caption = Label
Command1.Enabled = False
End Sub
FlashShape Method
Applies To Map Object
The FlashShape method syntax has the following object qualifier and arguments:
Part Description
shape Required. A reference to the shape to flash. Point, Points, Line, Rectangle,
Ellipse or Polygon objects are supported.
Example This example uses the FlashShape method to flash the first shape in a map four times. To try
this example, paste the code into the Declarations section of a form containing a
CommandButton named Command1 and a Map named Map1 that contains at least one
MapLayer, and then press F5 and click the button.
Option Explicit
Flattening Property
Applies To Spheroid Object
Description Sets or returns a value that identifies the Flattening parameter upon which the Spheroid is
based.
Part Description
Remarks The flattening, f, of a spheroid can be calculated by use of the following formulae, where a is
the length of the semimajor axis, and b is the length of the semiminor axis.
f = (a - b) / a
The f of the earth is approximately 0.003353. The value of f is a very small number, so you
may often find the quantity is expressed in terms of 1/f.
Flip Property
Applies To LabelRenderer Object
Description Returns or sets a value indicating whether a LabelRenderer object will flip text labels so that
they appear right-side up.
Part Description
Setting Description
Remarks The Flip property applies to all the labels in a LabelRenderer, and therefore may not solve all
of the labeling problems. In many, but not all cases, it will enhance the appearance of splined
text. If the general direction of the Line upon which the direction of splined text is based reads
from right-to-left, then the Flip property reverses the direction to be left-to-right. When
SplinedText is False, setting Flip to True has no effect.
Example This example uses the Flip property to control whether the LabelRenderer will flip labels so
that they appear right-side up. To try this example, paste the code into the Declarations section
of a form containing a Map named Map1 that contains a MapLayer that displays line features,
a ListBox named List1, a CheckBox control named Check1, and a CommandButton named
Command1. Press F5. Click the name of a Field that will serve as the source for the text and
then press Command1. Toggle the check box control to see the effect of the Flip property.
Option Explicit
Dim fldname As String
oFnt.Name = Arial
oFnt.Size = 6
End Sub
Check1.Caption = Flip
Command1.Caption = Label
Check1.Value = 1
End Sub
Floor Property
Applies To Rectangle Object
Part Description
Font Property
Applies To Symbol Object, TextSymbol Object
Syntax object.Font
The Font property syntax has the following object qualifier and part:
Part Description
Remarks See Visual Basic Helps Font object topic for more information about Fonts.
Example This example lets you set a TextSymbol objects Font property by displaying the Font Dialog.
To try this example, paste the code into the Declarations section of a form containing a
CommonDialog control, a CommandButton named Command1, and a Map named Map1.
Press F5 and then click Command1 to set the font and other font effects.
Option Explicit
Dim oTextsymbol As New MapObjects2.TextSymbol
oFont.Italic = .FontItalic
oFont.Strikethrough = .FontStrikethru
oFont.Underline = .FontUnderline
End With
If bTextDrawn Then
Map1.DrawText MapObjects2, Map1.Extent.Center, oTextsymbol
End If
bTextDrawn = True
End Sub
FromGeoCoordSys Property
Applies To GeoTransformation Object
Description Sets or returns an object that identifies the source GeoCoordSys in a GeoTransformation
object.
Part Description
FromMapDistance Method
Applies To Map Object
The FromMapDistance method syntax has the following object qualifier and argument:
Part Description
Remarks The FromMapDistance method performs the opposite function to the ToMapDistance
method, taking a distance in map units, and converting this to a distance on control coordi-
nates. The control coordinates are sensitive to the ScaleMode of the container. For example, if
the Form containing a Map control has a ScaleMode of centimeters, using the
FromMapDistance method will return the distance value in centimeters.
Example This example uses the TrackLine and FromMapDistance methods convert a distance from map
units to control units. To try this example, paste the code into the Declarations section of a
form containing a Map named Map1 that contains at least one MapLayer, and then press F5
and click-drag a polygon on the map.
Option Explicit
report = Line is
Set ln = Map1.TrackLine
report = report & Round(ln.Length, 3) & map units, and & _
vbNewLine & Round(Map1.FromMapDistance(ln.Length), 3) & _
control units long.
FromMapPoint Method
Applies To Map Object
The FromMapPoint method syntax has the following object qualifier and arguments:
Part Description
Remarks The FromMapPoint method performs the opposite function to the ToMapPoint method,
taking a Point in map units, and populating two variables with the equivalent control coordi-
nates. The control coordinates are sensitive to the ScaleMode of the container. For example, if
the Form containing a Map control has a ScaleMode of centimeters, using the
FromMapPoint method will return the yControl and xControl values in centimeters.
Example The following example uses the FromMapPoint method to illustrate how to derive the location
in control units of a point on the map, when that point is not directly passed in a Map event. To
try this example, paste the code into the Declarations section of a form containing a Map
named Map1 that contains at least one MapLayer, and then press F5 and click-drag on the
Map.
Option Explicit
Dim rect As MapObjects2.Rectangle
Dim Loc As New MapObjects2.Point
sym.SymbolType = moPointSymbol
sym.Style = moCircleMarker
sym.Color = moRed
Map1.DrawShape Loc, sym
End If
End Sub
FullExtent Property
Applies To Map Object
Description Returns or sets a Rectangle object that represents the bounding box of a Map.
Part Description
Example This example uses the FullExtent property to set the Extent of a Map to its FullExtent. To try
this example, paste the code into the Declarations section of a form containing a
CommandButton named Command1 and a Map named Map1 that contains at least one
MapLayer, and then press F5; drag a rectangle to zoom in on the map and then click Com-
mand1 to zoom back to the full extent of the map.
Option Explicit
Private Sub Command1_Click()
Map1.Extent = Map1.FullExtent
End Sub
FullRedrawOnPan Property
Applies To Map Object
Description Returns or sets a value that determines whether to redraw a Map object completely after a
scroll or pan event.
Part Description
boolean A boolean expression specifying whether to redraw the map after a scroll or
pan event, as described in Settings.
Setting Description
False (Default) The Map does not redraw completely after a scroll or pan event.
Remarks The FullRedrawOnPan property provides specialized applications the ability to control
whether or not to use MapObjects default display optimizations after a scroll or pan. You
should only consider using FullRedrawOnPan when using certain types of custom symbols
or specialized renderers.
Example This example uses the FullRedrawOnPan property to control whether to redraw the map
completely after a scroll or pan event. See the Remarks section of the help topic associated
with FullRedrawOnPan for more information. To try this example, paste the code into the
Declarations section of a form containing a CheckBox named Check1 and a Map named Map1
that contains at least one MapLayer, and then press F5; drag a rectangle to zoom in on the map
and then use the right button of the mouse to pan. Toggle the CheckBox to see the effect of the
property.
Option Explicit
Check1.Caption = FullRedrawOnPan
End Sub
GenerateCandidates Method
Applies To Geocoder Object
Description Generates possible matching candidate addresses, and returns a GeocodeSuccess constant
indicating the status of the candidates associated with the Geocoder object. The objects
CandidateCount property indicates how many candidates are found. The number of candi-
dates found can be varied based on the objects SpellingSensitivity properties.
Part Description
Geocoder Object
An Geocoder object lets you specify an individual address or street intersection, or supply a
table of addresses to match against a street network. A street network is assigned to the
Geocoder object by setting the StreetTable property with a suitable GeoDataset . A suitable
GeoDataset may consist of either a line shapefile attributed with road names, or an ARC/
INFO coverages containing point or polygon features attributed with land parcel information.
An address needs to be standardized before matching. You must set a Standardizer objects
properties, and associate it with the Geocoder objects Standardizer property before you can
geocode an address.
Matching different types of addresses are supported in MapObjects; you select the appropriate
matching rules by specifying the MatchRules and IntersectionMatchRules properties. You
can find the following matching rule files in the Georules folder of the MapObjects installation
folder:
US addresses with zone information, StreetTables with single house range (us_srng1.mat)
US addresses without zone information, StreetTables with single house range (us_srng2.mat)
The first time you work with the StreetTable, use the AddIndex and BuildIndices methods to
create a geocoding index for the StreetTable. You can verify that an index exists for the
GeoDataset with the IndexStatus method. An index is searched based on the queries defined
in the SearchQueries property. To verify that the Geocoder has a valid StreetTable and that
the fields specified are valid, you can test the value of the Valid property. If it is not Valid, you
can examine the LastError property to check the type of error.
Given a string with either a street address or an intersection (two streets delimited with an &
symbol), you can invoke the GenerateCandidates method to get the possible matching
candidates. You can then match the address against the best candidate with the
LocateCandidate method, which returns an AddressLocation object.
If you have address data in a Table you can use the BatchMatch method to perform address
matching on each record, creating a new shapefile containing the results of the matching.
During the batch matching process, you can control the sensitivity of the matching process by
adjusting the values in the MatchWhenAmbiguous and MinimumMatchScore properties.
You can also set other geocoding preferences that apply to both interactive and batch matching
with the SpellingSensitivity, Offset, and SqueezeFactor properties.
Properties
IntersectionMatchRules MatchVariableIntersectionLink
MatchRules MinimumMatchScore
Methods
BuildIndices IndexStatus
Example To try this example, paste the code into the Declarations section of a form that contains a Map
named Map1, a CommandButton named Command1, and two TextBoxes named Text1 and
Text2. Substitute appropriate values for the data paths and then press F5.
Option Explicit
If stan.StandardizeAddress(Text1.Text) Then
stan.FieldValue(ZN) = Text2.Text
geo.GenerateCandidates
If geo.CandidateCount > 0 Then
Set foundLoc = geo.LocateCandidate(0)
Map1.FlashShape foundLoc.location, 3
End If
End If
End Sub
Set up Standardizer
stan.StandardizingRules = C:\Program Files\ESRI\MapObjects2\ _
GeoRules\us_addr.stn
stan.IntersectionStandardizingRules = C:\Program Files\ _
ESRI\MapObjects2\GeoRules\us_intsc.stn
geo.Standardizer = stan
= StreetType1
geo.MatchVariableIntersectionLink(SufDir, mgLinkPrimary) _
= SufDir1
geo.MatchVariableIntersectionLink(LeftZone, mgLinkPrimary) _
= LeftZone1_
geo.MatchVariableIntersectionLink(RightZone, mgLinkPrimary) _
= RightZone1
End Sub
GeocodeSuccess Constants
MapObjects defines the following constants for use with the Geocoder objects
GenerateCandidates method.
GeoCoordSys Object
A geographic coordinate system describes positions on the earth using a coordinate system
based on latitude-longitude coordinates. A geographic coordinate system is based on a datum,
defined in the Datum property. The line of zero longitude is named the prime meridian, which
is defined in the PrimeMeridian property. The units of the coordinate system are defined in
the Unit property.
A standard geographic coordinate system can be created by setting the Type property with a
GeographicCoordSysConstants, which include over two-hundred and fifty pre-defined
geographic coordinate systems.
Properties
IsProjected PrimeMeridian
Methods
See Also Map Object, MapLayer Object, Projection Object, ProjCoordsys Object
GeoCoordSys Property
Applies To ProjCoordSys Object
Description Sets or returns a value that identifies the geographic coordinate system (GeoCoordSys) upon
which a ProjCoordSys object is based.
Part Description
Remarks The GeoCoordSys property contains a GeoCoordSys object defining the geographical
coordinate system from which the ProjCoordSys is projected.
Example This example uses the GeoCoordSys property of a ProjCoordSys object to summarize the
geographic coordinate systems applied to projected layers. To try this example, paste the code
into the Declarations section of a form containing a Map named Map1, a command button
named Command1 and a ListView named ListView1. Map1 should contain more than one
MapLayer, each having a coordinate system set. Press F5, and click the command button.
Option Explicit
Dim symPCS As New MapObjects2.Symbol
Dim symGCS As New MapObjects2.Symbol
End Sub
Command1.Caption = Summarise CS
ListView1.View = lvwReport
End Sub
GeoDataset Object
A GeoDataset object represents a layer of geographic data. The GeoDataset object is
associated with the MapLayer object in order to display the data in a Map. This geographic
data may be held in any of the vector data formats supported by MapObjects.
Name is the default property for a GeoDataset object. To share the GeoDataset with other
applications for reading and writing (while you are not editing it) set AllowSharing to True.
Use the HasZ and HasMeasure properties to test whether the GeoDataset supports Z values
or Measures.
Properties
GeoDatasets Collection
A GeoDatasets collection contains all GeoDataset objects found in a DataConnection.
A DataConnection objects Database property includes a data source specific suffix for
certain data sources, which will determine which GeoDatasets are returned.
Properties
Count
Methods
Item
GeoDatasets Property
Applies To DataConnection Object
Part Description
Remarks A DataConnection objects Database property includes a data source specific suffix for
certain data sources, which will determine which GeoDatasets are returned to the
GeoDatasets collection.
Note: if used with a CAD DataConnection, i.e. the Database property begins with [CAD],
the GeoDatasets property will return a collection containing all files in the directory. Be
careful to select the correct GeoDataset, as errors will occur if you set a MapLayers
GeoDataset with an unsupported file format.
Example This example uses the GeoDatasets property to list all the Shapefile, VPF and Coverage
GeoDatasets in a DataConnection objects Database. To try this example, paste the code into
the Declarations section of a form containing a DirListBox control named Dir1, and a ListBox
named List1. Press F5 and then navigate through the folders in the Directory list to a folder
that represents a Database that contains GeoDatasets.
Option Explicit
Dim dbSuffix(0 To 3) As String
End Sub
GeoEvent Object
A GeoEvent object represents a geographically referenced phenomenon whose position may
change. A GeoEvent displays on a Map objects TrackingLayer, and may be a Point, Points,
Line, Rectangle, Polygon or Ellipse. Each GeoEvent is depicted with a Symbol, identified
by its by SymbolIndex.
You can return the location of GeoEvent using its X and Y properties. You can move a
GeoEvent with the Move or MoveTo methods. The read-only Index property returns the
GeoEvent objects current position on the TrackingLayer. You can use the Index property
with the TrackingLayer objects Event property and RemoveEvent method.
Properties
Methods
Move MoveTo
GeographicCoordSys Constants
MapObjects defines over one hundred and fifty constants for use with the Type property of a
GeoCoordSys object. See the online help for a full list of GeographicCoordSysConstants.
GeographicTransformation Constants
MapObjects defines over one hundred and fifty constants for use with the Type property of a
GeoTransformation object. See the online help for a full list of
GeographicTransformationConstants.
GeographicTransformation Property
Applies To MapLayer Object
Description Returns or set the GeographicTransformation of a MapLayer. This property is used for on-
the-fly projection of a MapLayer.
Part Description
Remarks When a MapLayer has its GeographicTransformation property set, MapObjects will re-
project the MapLayer, on the fly, according to that geographic transformation. You must also
set a CoordinateSystem on the Map and on the MapLayer.
Example This example demonstrates the use of a GeoTransformation object which is set as the
GeographicTransformation property on a MapLayer. To try this example, paste the code into
the Declarations section of a new Form which has a Map named Map1 containing two
MapLayers. Then press F5, and zoom in on a small area of the Map. Now try running the code
with the indicated GeographicTransformation property line commented out to see the differ-
ence. This code sample assumes the following: (1) You have two Geographic map layers
loaded in your control (2) One layer is based on the NAD 1927 datum (3) The second layer
is based on the NAD 1983 datum
Option Explicit
and set them - in this case we are using datasets that are
based on NAD27 and NAD83 datum
gcs_nad27.Type = moGeoCS_NAD1927
gcs_nad83.Type = moGeoCS_NAD1983
lyA.CoordinateSystem = gcs_nad27
lyB.CoordinateSystem = gcs_nad83
... finally, set the map control to display using the NAD83
geographic coordinate System
Map1.CoordinateSystem = gcs_nad83
GeoTransformation Object
When converting vector data from one coordinate system to another, it is possible to use a
GeoTransformation object to perform a geographic transformation or datum shift.
by setting the Direction property, therefore transformations can also be specified from the
WGS1984 datum to an alternative datum.
Many situations require a transformation between two coordinate systems, neither of which is
based on the WGS1984 datum. You can use the SecondType and SecondDirection properties
to create a two-stage transformation, allowing for the change in datum between the coordinate
systems.
NB. The Z values on all the points of a shape will be modified appropriately.
Restrictions:
It is not possible to extract information, other than the name and direction, about the second
stage of a two stage predefined transformation.
It is not possible for one stage of a two stage transformation to be predefined and the other
stage user-defined.
Properties
Method
Methods
GetParameter SetParameter
Example This example demonstrates the Direction property of the GeoTransformation object. To try
this example, paste the code into the Declarations section of a new Form which has two Map
controls named Map1 and Map2. Each Map should contain a MapLayer with geographical
locations in common. Ensure the coordinate systems of each MapLayer are set appropriately.
Then press F5, and click on either Map. The point will be transformed to the other maps
coordinate system, and displayed on both maps.
Option Explicit
Dim fromPt As New MapObjects2.Point
Dim toPt As New MapObjects2.Point
Dim curMap As Integer
Dim sym As New MapObjects2.Symbol
If Map1.CoordinateSystem.IsProjected Then
map1Projected = True
Else
map1Projected = False
End If
If Map2.CoordinateSystem.IsProjected Then
map2Projected = True
Else
map2Projected = False
End If
myGT.FromGeoCoordSys = Map1.CoordinateSystem.GeoCoordSys
Else
myGT.FromGeoCoordSys = Map1.CoordinateSystem
End If
If map2Projected Then
myGT.ToGeoCoordSys = Map2.CoordinateSystem.GeoCoordSys
Else
myGT.ToGeoCoordSys = Map2.CoordinateSystem
End If
Set transformPoint = Map2.CoordinateSystem.Transform _
(Map1.CoordinateSystem, fromPt, , myGT)
End Function
As Single, Y As Single)
Set fromPt = Map1.ToMapPoint(X, Y)
Set toPt = transformPoint(moDirection_Forward, fromPt)
curMap = 1
Map1.TrackingLayer.Refresh (True)
Map2.TrackingLayer.Refresh (True)
End Sub
Map1.CoordinateSystem = Map1.Layers(0).CoordinateSystem
Map2.CoordinateSystem = Map2.Layers(0).CoordinateSystem
With sym
.SymbolType = moPointSymbol
.Size = 4
.Outline = False
.Style = moTriangleMarker
End With
Arrange controls
Map1.Move 60, 60, 5000, 5000
Map2.Move Map1.Left + Map1.Width + 100, _
Map1.Top, Map1.Width, Map1.Height
Form1.Width = Map2.Left + Map2.Width + 60
Form1.Height = Map2.Top + Map2.Height + 60
End Sub
GetCrossings Method
Applies To Point Object, Points Collection, Line Object, Polygon Object, Rectangle Object
Description Returns a Points collection whose members represent the points at which two objects cross.
Part Description
Example This example uses the GetCrossings method to return a Points collection whose members
represent the points at which two objects cross. To try this example, paste the code into the
Declarations section of a form containing a Map named Map1. Press F5 and then drag at least
two polygons that cross on the Map.
Option Explicit
Private moPolys As New Collection
If moPolys.Count = 2 Then
Set oCrossings = moPolys(1).GetCrossings(moPolys(2))
For Each oPoint In oCrossings
Map1.DrawShape oPoint, oSymbol2
Next
End If
End Sub
If moPolys.Count = 2 Then
moPolys.Remove 2
End If
moPolys.Add oPolygon
Map1.TrackingLayer.Refresh True
End Sub
GetParameter Method
Applies To ProjCoordSys Object, GeoTransformation Object
Description Returns a value that has been set for a specific coordinate transformation parameter on a
ProjCoordSys or a GeoTransformation object.
The GetParameter method syntax has the following object qualifier and arguments:
Part Description
variable A numeric expression that represents the value that has been set for the
parameter specified
Remarks If the specified parameter is unset for the object, GetParameter will return a value of zero. A
value of zero is also a valid value for certain objects. If in doubt, read the ParameterType
Constants page to check if a certain parameter is used.
Example This example uses the GetParameter and SetParameter methods of a ProjCoordSys object to
demonstrate how a user might alter projection parameters during run time. To try this example,
paste the code into the Declarations section of a form containing a ComboBox named
Combo1, a ListBox named List1, a Label named Label1, a TextBox named Text1, and a
CommandButton named Command1. Press F5 and choose a Projected Coordinate System
from the ComboBox. Its available parameters will be listed in the ListBox, along with their
values. Click on a parameter, enter a new value in the TextBox and click the CommandButton
to create a new ProjCoordSys object having the same parameters, but with the new value. This
object could then be applied to a MapLayer or Map.
Option Explicit
Dim choice As String
Dim newPCS As New MapObjects2.ProjCoordSys
Dim PCS As New MapObjects2.ProjCoordSys
choice = Combo1.List(Combo1.ListIndex)
getParam = stripProj(choice)
PCS.Type = getParam
pcsParams.PopulateWithParameters PCS.Projection.Type
Dim p As Variant
List1.Clear
For Each p In pcsParams
Dim ps As String
ps = p
List1.AddItem Parameter: & p & Chr(9) & = & Chr(9) & _
PCS.GetParameter(stripProj(ps))
Next p
End Sub
Combo1.Clear
Text1.Text =
List1.Clear
Command1.Caption = Set Parameter
Label1.Caption = No custom PCS
End Sub
GotFocus Event
Applies To Map Object
Description The GotFocus event is a standard ActiveX control event, which occurs when the user clicks
on the Map, or the Map control receives focus programmatically.
Part Description
Remarks For more information about the GotFocus event, see the Visual Basic online reference.
See Also Click Event, DblClick Event, KeyPress Event, KeyDown Event, LostFocus Event,
MouseMove Event, MouseDown Event
GroupRenderer Object
A GroupRenderer object provides a way to associate more than one renderer with a
MapLayer. One example of this is a situation in which you want to render some features of
the same MapLayer with one renderer and other features of the layer with a different ren-
derer. Another example might be a situation in which you want to apply two renderers to the
same feature; for example, a thematic map based on class breaks for one attribute and a pie
chart for other attributes.
Use the Add method to add the specified renderer to the group of renderers. Use Count to
return the number of renderers, and use Remove to delete a renderer from the group. To
access a specific renderer, use the Renderer property.
Properties
Methods
Add Remove
Example This example uses a GroupRenderer to apply two renderers to the same MapLayer. It assumes
that the USA sample data States shapefile is a MapLayer of the Map. To try this example,
paste the code into the Declarations section of a form that contains a Map named Map1 and a
CommandButton named Command1. Press F5. The code includes a standard pan and zoom on
MouseDown, as well as a FullExtent button to return to the full extent.
Option Explicit
Dim gr As New MapObjects2.GroupRenderer
Dim cr As New MapObjects2.ChartRenderer
Dim vmr As New MapObjects2.ValueMapRenderer
.Field(3) = nevermarry
.Color(3) = mogrey
.Field(4) = widowed
.Color(4) = moOlive
.MinPieSize = 8
.MaxPieSize = 24
.SizeField = pop1990
.NormalizationField = area
End With
gr.Add vmr
gr.Add cr
HasMeasure Property
Applies To GeoDataset Object
Description Returns a value indicating whether the GeoDataset object has the ability to support measures.
Part Description
hasM A boolean expression specifying whether the dataset has measures. See
Return Values.
Value Description
Remarks Not all types of data source that can be used with MapObjects support the storage of measure
information. If the data source does not support measures (e.g. a shapefile that contains a non-
measured shape type or an SDE layer without support for measures) then any measure values
your application sets for feature vertices will be lost when they are written to the GeoDataset.
Use this property before adding features to a GeoDataset to test that measure values will be
preserved. Features read from GeoDatasets that do not support measure values have their
measure values set to the no data value.
HasZ Property
Applies To GeoDataset Object
Description Returns a value indicating whether the GeoDataset object supports Z values.
Part Description
hasZ A boolean expression specifying whether the dataset has Z values. See
Return Values.
Value Description
Remarks Not all types of data source that can be used with MapObjects support the storage of Z values.
If the data source does not support Z values (e.g. a shapefile that contains a non-Z shape type
or an SDE layer without support for Z coordinates) then any Z values your application sets for
feature vertices will be lost when they are written to the GeoDataset. Use this property before
adding features to a GeoDataset to test that Z values will be preserved. Features read from
GeoDatasets that do not support Z values have their Z coordinates set to zero.
Example This example uses the HasZ method to give the user a list of GeoDatasets in any given
directory, and to report whether or not each dataset supports Z values. To try this example,
paste the code into the Declarations section of a form that contains a CommandButton named
Command1, a ListBox named List1 and a TextBox named Text1. Then press F5, and enter a
directory with datasets into the Text1, then press Command1.
Option Explicit
List1.Clear
load data into the map
With oConnection
.Database = Text1.Text
If .Connect Then
Screen.MousePointer = vbHourglass
If .GeoDatasets.Count > 0 Then
For Each oDataset In .GeoDatasets
List1.AddItem oDataset.Name & : & oDataset.HasZ
Next
Else
List1.AddItem <No geodatasets in current directory>
End If
Screen.MousePointer = vbDefault
End If
End With
If Not oConnection.Connect Then Exit Sub
End Sub
Height Property
Applies To Ellipse Object, Map Object, Rectangle Object, TextSymbol Object
Description Returns or sets the vertical dimensions of an object. Read-only for Ellipse and Rectangle
objects.
Part Description
Example This example uses the Height property to provide information about what clicking on the Map
does. If the user clicks on the map, a MsgBox containing information about a MouseDown
event appears. To try this example, paste the code into the Declarations section of a form
containing a Map named Map1 that contains at least one MapLayer. Press F5 and click the
map. Dismiss the MsgBox and drag a rectangle to zoom in.
Option Explicit
If oRectangle.Height = 0 Then
MsgBox Drag a box to zoom in, vbInformation
Else
Map1.Extent = oRectangle
End If
End Sub
HeightField Property
Applies To LabelRenderer Object
Description Returns or sets the Field that contains height information for a LabelRenderer object.
Part Description
Remarks If you set the HeightField property, you will override the Size property of the TextSymbol
objects Font.
Example This example uses the HeightField property to control the height of the text displayed by the
LabelRenderer. The HeightField property specifies the name of a field in the Recordset
associated with the MapLayer. The field contains a height value in map units for each record.
The Field property names the field that will serve as the source for the text. To try this
example, paste the code into the Declarations section of a form containing a Map named Map1
that contains a MapLayer , two ComboBox controls named Combo1 and Combo2, two Label
controls named Label1 and Label2, and a CommandButton named Command1. The
Form_Load event code will position all the controls except the Map. Press F5. Select the name
of the field that will serve as the HeightField and then select the name of the field whose
values will provide the source of the text for the LabelRenderer. Click Command1 to display
the text.
Option Explicit
Dim moRecset As MapObjects2.Recordset
Map1.Layers(0).Renderer = oLayer
Map1.Refresh
End If
End Sub
HorizontalAlignment Property
Applies To TextSymbol Object
Description Returns or sets a value that determines the horizontal alignment of text for a TextSymbol
object.
Part Description
Note that only the Left, Right and Center AlignmentConstants are valid for
HorizontalAlignment.
Example This example uses the HorizontalAlignment and VerticalAlignment properties of the
TextSymbol object associated with a LabelRenderer to control the label positions of the
features of a MapLayer. Once the Map draws, you can try out the various text alignment
combinations. To try this example, paste the code into the Declarations section of a form
containing two Frame controls named Frame1 and Frame2, two OptionButton controls named
Option1 and Option2, a ComboBox named Combo1 and a Map named Map1 that contains one
MapLayer. For each OptionButton, set its Index to 0 in the Control Properties dialog box to
create a control array of one element. Once youve created the OptionButtons and the Frames,
cut Option1 and paste it into Frame1 and cut Option2 and paste it into Frame2. Select Press F5
and choose the field in Combo1 whose values will serve as the text for the labels. Click the
option buttons to alter the alignment properties.
Option Explicit
Dim oRenderer As MapObjects2.LabelRenderer
Case 0
oRenderer.Symbol(0).VerticalAlignment = moAlignTop
Case 1
oRenderer.Symbol(0).VerticalAlignment = moAlignCenter
Case 2
oRenderer.Symbol(0).VerticalAlignment = moAlignBottom
Case 3
oRenderer.Symbol(0).VerticalAlignment = moAlignBaseline
End Select
Map1.Refresh
End If
End Sub
iBorder = 1000
Option1(3).Caption = Baseline
hWnd Property
Applies To Map Object
Description The hWnd property is a standard ActiveX property that returns a handle to a control.
Part Description
handle A value of Long data type specifying the Windows API handle of the object.
Remarks For more information about the hWnd property, set the Visual Basic online reference.
Example This example uses the hWnd property to draw a rectangle on a Map using Windows API calls.
To try this example, paste the code into the Declarations section of a form containing a Map
named Map1 that contains at least one MapLayer, and then press F5. Once the Map displays,
click and drag the Rectangle over the Map.
Option Explicit
End Sub
ImageLayer Object
An ImageLayer represents a layer that is based on geo-referenced raster data stored in an
image file. Each ImageLayer objects File property represents the name of the file on disk.
Most image files should have an associated file called a world file that contains the transfor-
mation parameters needed to display the image simultaneously with MapLayer objects. To
find out which image files should have a world file, see the individual image format descrip-
tions in the online help.
The Layers collection includes a MapLayer or an ImageLayer object for each layer defined
for a map. Using the Valid property, you can determine whether a layer is valid before adding
it to the collection. Use the Layers property of a Map object to retrieve its Layers collection.
You can access members of the Layers collection either by numeric index or by the Name of
the ImageLayer.
You can create ImageLayer objects in Visual Basic with code like this:
Dim ilyr as New MapObjects2.ImageLayer
Properties
Index Property
Applies To GeoEvent Object
Syntax object.Index
Part Description
Remarks The current index is the internal index of the GeoEvent. The index represents the GeoEvent
objects current position in the collection of events on the TrackingLayer. GeoEvents can be
added at a specified Index, MapObjects renumbers the Index of all subsequent events if your
application removes an event.
Example This example uses the Index property to reference a GeoEvent on the TrackingLayer. To try
this example, paste the code into the Declarations section of a form containing a Map named
Map1 that contains at least one MapLayer, a ListBox named List1, and a Label named Label1,
then press F5. Remove events by clicking the event in the list box. Note that MapObjects
reassigns a new index value to remaining events automatically. If the referenced events Index
value is -1, it means the event has been removed.
Option Explicit
Add events
Map1.TrackingLayer.SymbolCount = 4
For i = 0 To 3
With Map1.TrackingLayer
With .Symbol(i)
.Color = moBlue
.Style = moTrueTypeMarker
.Font = oFont
.Size = 36
.CharacterIndex = 74 + i
End With
ListEvents
removed)
End Sub
iEvent = moEventList(List1.ListIndex).Index
If iEvent > -1 Then
Map1.TrackingLayer.RemoveEvent iEvent
ListEvents
Else
MsgBox This event has already been removed., vbExclamation, _
Remove Event
End If
End Sub
Sub ListEvents()
Dim i As Integer
List1.Clear
For i = 0 To UBound(moEventList)
List1.List(i) = gEventList( & i & ).Index = & _
moEventList(i).Index
Next
End Sub
Indexed Property
Applies To PlaceLocator Object
Description Returns a value that indicates whether an index exists for an object.
Syntax object.Indexed
The object placeholder is an object expression that evaluates to an object in the Applies To
list.
Value Description
If the object is a PlaceLocator object, the index is a searchable index for string searching
index.
IndexEvents Property
Applies To EventRenderer Object
Description Returns or sets a value indicating whether or not an index is created for the events in a
MapLayer.
Part Description
Remarks The default setting of the boolean value is False, by default no indexing of events in the
MapLayer takes place.
When a MapLayer is drawn using an EventRenderer, an index is created on the events in the
EventTable. For large datasets this process may take some time, and therefore slow down the
drawing of a MapLayer with an EventRenderer. However, you can create an index of the
events in your MapLayer before drawing takes place, which will speed up the drawing time.
This index is created only once, not each time the MapLayer is drawn. The same index is
therefore used every time your MapLayer is drawn with the EventRenderer.
If you wish to index all of the events in your MapLayer prior to its display, you should create
an EventRenderer and set its IndexEvents property to True, and then assign the
If you set the IndexEvents property to true when the EventRenderer is already assigned to a
MapLayer, events will be indexed at draw time as features are drawn. Therefore if the user is
zoomed in on a MapLayer when IndexEvents is set to True, only events on features within
that extent will be indexed. As more features are displayed, for example if the user pans across
the MapLayer, events on those features which become visible will also be indexed.
If you only wish to display a small area of the whole MapLayer, you can also set the
IndexExtent property. Only features lying within, or partially within, the specified Extent are
indexed, which will increase the speed of the indexing operation.
If your EventTable is a dataset shared between many users, the events contained in the dataset
may change periodically. In this case, the index MapObjects created on the events assigned to
the MapLayer will be outdated. You can use the InvalidateIndex method to refresh the
index on any particular route.
Example This example demonstrates indexing of events when displaying a MapLayer with an
EventRenderer. To try this example, paste the code into the Declarations section of a form
containing a Map control named Map1 containing one MapLayer with lines which have
measure values, and a Command Button named Command1. Also add two OptionButtons
named Option1 and Option2. This example uses the Highways sample shapefile, alter the path
to this folder if required. Press F5, and the MapLayer will display with an EventRenderer
displaying the point events contained in the Accidents dbf file. Only the events within the Map
Extent are indexed. Right-Click to pan about the map, and more events will be indexed as you
pan. Click the pavements option and the MapLayer is displayed with an EventRenderer
showing the line events contained in the pavements dbf file.
Option Explicit
Dim dc As New MapObjects2.DataConnection
Dim ptRend As New MapObjects2.EventRenderer
Dim lnRend As New MapObjects2.EventRenderer
Dim lyr As New MapObjects2.MapLayer
With ptRend
.DrawBackground = True
.IndexEvents = True
.SymbolType = moPointSymbol
.EventTable = accTbl
.StartMeasureField = MILE
.DefaultSymbol.SymbolType = moPointSymbol
.DefaultSymbol.Style = moCircleMarker
.DefaultSymbol.Color = moPurple
.DefaultSymbol.Size = 4
.UseDefault = True
.FeatureRouteIDField = RKEY
.EventRouteIDField = RKEY
.StartMeasureField = MILE
End With
With lnRend
.DrawBackground = True
.IndexEvents = True
.SymbolType = moLineSymbol
.EventTable = paveTbl
.FeatureRouteIDField = rkey
.EventRouteIDField = rkey
.StartMeasureField = fmp
.EndMeasureField = tmp
.SymbolField = rideq
.ValueCount = 3
.Value(0) = L
.Symbol(0).Style = moSolidLine
.Symbol(0).Size = 2
.Symbol(0).Color = moGreen
.Value(1) = M
.Symbol(1).Style = moSolidLine
.Symbol(1).Size = 2
.Symbol(1).Color = moYellow
.Value(2) = N
.Symbol(2).Style = moSolidLine
.Symbol(2).Size = 2
.Symbol(2).Color = moBlue
End With
Screen.MousePointer = vbDefault
End Sub
lyr.Symbol.Color = moRed
lyr.Symbol.Size = 3
Option1.Caption = Render accidents
Option2.Caption = Render pavements
Option1.Value = 1
Option2.Value = 0
Map1.ScrollBars = False
setupEventRenderer
End Sub
IndexExtent Property
Applies To EventRenderer Object
Description Returns or sets a value indicating an extent of a MapLayer for which events in the
EventRenderers EventTable should be indexed.
Part Description
Remarks If you only wish to display a small area of a MapLayer, you can set the IndexExtent prop-
erty. Only features lying within, or partially within, the specified Extent are indexed, which
will increase the speed of the indexing operation.
If you set the IndexEvents property to true when the EventRenderer is already assigned to a
MapLayer, events will be indexed at draw time as features are drawn. Therefore if the user is
zoomed in on a MapLayer when IndexEvents is set to True, only events on features within
that extent will be indexed. As more features are displayed, for example if the user pans across
the MapLayer, events on those features which become visible will also be indexed. If there
are a considerable amount of new events to be indexed, this may slow down the drawing of the
Map.
You can use the IndexExtent property in this situation to index the whole area which the user
may display. Setting the IndexExtent property appropriately would prevent the indexing
occurring at draw time while the user pans about the Map.
IndexStatus Constants
MapObjects defines the following constants for use with the Geocoder objects IndexStatus
method.
IndexStatus Method
Applies To Returns an IndexStatusConstant indicating the current status of the index associated with the
Geocoder Object.
Part Description
IndexType Constants
MapObjects defines the following constants for use with the Geocoder objects AddIndex
method.
Insert Method
Applies To Points Collection, Parts Collection
Description Inserts a new Points collection at the specified position in a Parts collection or inserts a new
Point object at the specified position in a Points collection.
Part Description
index An integer that represents the position of the member in the Parts or Points
collection.
Example This example uses the Insert method to insert a new Point into a collection of Points. To try
this example, paste the code into the Declarations section of a form containing a Map named
Map1, and then press F5. Track a polygon on the Map and then use the right mouse button to
select the vertex in front of which to insert the new point.
Option Explicit
Dim moPoly As MapObjects2.Polygon
End Sub
fTol = Map1.ToMapDistance(100)
Set oPoints = oPoly.Parts(0)
For i = 0 To oPoints.Count - 2
If oPoints(i).DistanceTo(oPoint) < fTol Then
SelectVertex = i
Exit Function
End If
Next
SelectVertex = -1
End Function
If Button = 1 Then
Set moPoly = Map1.TrackPolygon
ElseIf Not moPoly Is Nothing Then
iVertex = SelectVertex(Map1.ToMapPoint(X, Y), moPoly)
If iVertex <> -1 Then
InsertVertex iVertex, moPoly
End If
End If
Map1.TrackingLayer.Refresh True
End Sub
End Sub
Inset Method
Applies To Ellipse Object, Rectangle Object
Part Description
Remarks The Inset method decreases the object by deltaX at both the left and the right of the object and
decreases the object by deltaY at both the top and the bottom.
Example This example uses the Inset method to draw a Rectangle inset from the Extent of the map. The
Maps extent is shaded with a red fill pattern, the inset rectangle is shaded with a green fill
pattern. To try this example, paste the code into the Declarations section of a form containing a
Map named Map1 containing at least one MapLayer and then press F5 and click the Map.
Option Explicit
With moRectangle
.Inset .Width * 0.1, .Height * 0.1
End With
With oSymbol
.Style = moUpwardDiagonalFill
.Color = moGreen
End With
Map1.DrawShape moRectangle, oSymbol
End If
End Sub
Intersect Method
Applies To Point Object, Points Collection, Line Object, Polygon Object, Rectangle Object, Ellipse
Object
Description Returns a shape that represents the geometric intersection of one shape object with another
shape object.
Part Description
resultShape An object expression that evaluates to a shape object. (See Remarks). Will
contain the resulting shape after the intersection operation.
object An object expression that evaluates to an object in the Applies To list. This
is the first of the two shape objects whose intersection is to be calculated.
intersectShape An object expression that evaluates to an object in the Applies To list. This
is second of the two shape objects whose intersection is to be calculated.
Remarks If the two Shapes do not have a valid Intersect, the resultShape will be Nothing.
For a list of which shapes may result from an Intesect operation, see the online help.
Where the resultShape could be more than one object type (e.g. Rectangle or Polygon), then
use an interim Object and then test the result using its ShapeType property to see what type of
object it is.
You cannot use the Intersect method with a self-intersecting Polygon. If you do, an exception
is raised in Visual Basic, specifying Error 5000, Valid Object expected as argument. You can
however use a self-intersecting Line.
See Also Buffer Method, Difference Method, Union Method, XOr Method
Example This example uses the Intersect method to allow the user to perform intersect operations lines.
The line and the new shape generated by the Intersect operation are added to the tracking layer
as GeoEvents. Note, an intersection of two lines may be a point, many points, or a line. Care
must be taken to add events to the tracking layer using the appropriate symbol for the resultant
shape type, which is checked here by reading the ShapeType property of the returned shape.
To try this example, paste the code into the Declarations section of a form containing a Map
named Map1 that has at least one MapLayer, press F5, and then click on the map to track two
lines.
Option Explicit
Dim shape1 As Object
Dim shape2 As Object
Dim inter As Boolean
End If
End Sub
IntersectionMatchRules Property
Applies To Geocoder Object
Description Returns or sets the intersection match rule file name associated with the Geocoder object.
Part Description
rule filename A string expression that specifies the path of the Intersection Match rule file
name.
Remarks MapObjects provides a set of intersection match rules. Select the one that is suitable to the
type of address you want to match.
IntersectionMatchVariable Property
Applies To Geocoder Object
Description Returns the name of variables defined in the intersection match rules associated with the
IntersectionMatchRules property of the Geocoder object.
Part Description
index A numeric expression that specifies the relative position of a member of the
group of IntersectionMatchVariable names associated with the Geocoder
object. Index must be a number from 0 to a number that is one less than the
intName An object declared as a string data type that evaluates to the returned
variable name.
Remarks Use this property to return details of the intersection match variables which have been set on a
Geocoder object. The intersection match variables are defined in the .mat file specified in the
IntersectionMatchRules property.
IntersectionMatchVariableCount Property
Applies To Geocoder Object
Description Returns the number of intersection match variables defined in the IntersectionMatchRules
property associated with the Geocoder object.
Part Description
IntersectionStandardizingRules Property
Applies To Standardizer Object
Description Returns or sets the intersection standardization rule command file associated with the
Standardizer object.
Part Description
rule filename A string expression that specifies the Intersection Standardization rule
command file path and name.
Remarks An intersection is delimited by using an address string containing the symbol &. If a
Standardizer object is has both StandardizationRules and
IntersectionStandardizationRules properties set, the Standardizer will check if the address
string contains an ampersand symbol (&). It will automatically apply the appropriate
standardization rule and return the standardized FieldValues. For this reason, you should
avoid using an & in an address string if it is not an intersection.
MapObjects provides standardizing rule files for street intersection addresses. You can find the
following Intersection Standardization rule command file in the Georules folder:
Intersects Method
Applies To Rectangle Object
Description Returns a value that indicates whether a Rectangle object intersects another Rectangle.
Part Description
Return Values
Value Description
See Also Buffer Method, Difference Method, GetCrossings Method, Intersect Method, Union
Method, XOr Method
Example This example uses the Intersects method to test whether a newly constructed rectangle
intersects the rectangle representing the original extent of a map. If it does, the code uses the
rectangle to pan the map; otherwise, the extent reverts to the original extent. To try this
example, paste the code into the Declarations section of a form containing a CommandButton
named Command1 and a Map named Map1 that contains at least one MapLayer. Press F5 and
then click Command1.
Option Explicit
Dim OrigExtent As MapObjects2.Rectangle
If OrigExtent.Intersects(Rect) Then
Map1.Extent = Rect
Else
Map1.Extent = OrigExtent
End If
End Sub
Map1.Extent = Rect
Set OrigExtent = Map1.Extent
End Sub
InvalidateIndex Method
Applies To EventRenderer Object
Part Description
boolean A string evaluating to the RouteID of the feature for which the events index
should be refreshed, from the EventRenderers EventTable.
Remarks If your EventTable is a dataset shared between many users, the events contained in the dataset
may change periodically. In this case, the index MapObjects created on the events assigned to
the MapLayer will be outdated.
You can use the InvalidateIndex method to refresh the index on any particular route. The
index of events currently stored for that RouteID will be removed, and a new index of events
for that RouteID will be created from the current EventTable.
IsCustom Property
Applies To Projection Object
Description Returns a value that indicates whether a Projection object has been user-defined, using the
Custom property.
Part Description
Value Description
Example This example demonstrates the use of the IsCustom property of the Projection object, and also
demonstrates the setting of a new Projection object as a property of a ProjCoordSys object. To
try this example, paste the code into the Declarations section of a form which has a Label
named Label1, a Combo Box named Combo1, a Command Button named Command1, and
Map named Map1 containing one MapLayer which has a ProjCoordSys set. Then press F5.
The IsCustom property is read to determine if the existing projection set on the MapLayer is a
Custom one. Now select a new projection type from the ComboBox, and click the
CommandButton to set this projection as a property of the MapLayers CoordinateSystem.
Option Explicit
newProj.Type = stripProj(Combo1.List(Combo1.ListIndex))
PCS.Type = Map1.Layers(0).CoordinateSystem.Type
PCS.Projection = newProj
Map1.Layers(0).CoordinateSystem = PCS
End Sub
Combo1.Clear
proj.PopulateWithProjections
For Each item In proj
Combo1.AddItem item
Next item
Combo1.AddItem <Select new projection>, 1
Combo1.ListIndex = 1
If Map1.Layers(0).CoordinateSystem.Projection.IsCustom Then
Label1.Caption = Custom Projection Object
Else
Label1.Caption = Pre-Defined Projection Object
End If
End Sub
IsFullyMeasured Property
Applies To Line Object
Description Returns a value indicating whether all vertices of a Line object have a non-null measure value.
Part Description
boolean A boolean indicating if the object is fully measured, See Return Values
Value Description
True All vertices of the Line have a Measure value set against them.
False Not all vertices of the Line have a Measure value set.
Example This example makes use of the IsFullyMeasured property to draw lines on a map with appro-
priate symbols. The UpdateMeasures method can also be applied if lines in the Recordset are
not already fully measured. To try this example, copy the code into the Declarations section of
a form that contains a CheckBox named Check1, a CommandButton named Command1, and
Map named Map1 with a MapLayer containing line features, some of which are fully mea-
sured. Press F5 and click on a line. Fully measured lines will be drawn with a solid blue line,
whereas lines not fully measured will be drawn with a red dotted line.
Option Explicit
Public symIs As New MapObjects2.Symbol
Public symIsNot As New MapObjects2.Symbol
recs.MoveFirst
While Not recs.EOF
Dim gLine As New MapObjects2.Line
Set gLine = recs(Shape).Value
If gLine.IsFullyMeasured Then
Map1.DrawShape gLine, symIs
Else
Map1.DrawShape gLine, symIsNot
End If
recs.MoveNext
Wend
End Sub
IsPointIn Method
Applies To Ellipse Object, Polygon Object, Rectangle Object
Description Returns a value that indicates whether a Point falls within an object.
Part Description
Value Description
Example This example uses the IsPointIn method to identify features on a map. To try this example,
paste the code into the Declarations section of a form containing a Map named Map1 that
contains one MapLayer with polygon features. You may want to change the name of the field
from State_Name to the name of a field appropriate to your data. Press F5 and click the
button. Clicking the map with the left mouse button zooms in, clicking with the right mouse
button identifies the feature.
Option Explicit
Case vbLeftButton
Set oRectangle = Map1.Extent
oRectangle.ScaleRectangle (0.5)
Map1.Extent = oRectangle
Case vbRightButton
Set oPoint = Map1.ToMapPoint(x, y)
Set oRecset = Map1.Layers(0).Records
Do While Not oRecset.EOF
Set oShape = oRecset.Fields(shape).Value
If oShape.IsPointIn(oPoint) Then
change field name in next line to reflect your data
MsgBox prompt:=oRecset(state_name), Title:=Identify
Exit Do
End If
oRecset.MoveNext
Loop
Case Else
Dont respond
End Select
End Sub
IsProjected Property
Applies To GeoCoordSys Object, ProjCoordSys Object
Description Returns a value that indicates whether a coordinate system is projected. This property can be
used to distinguish an object of type GeoCoordSys from one of type ProjCoordSys.
Syntax object.IsProjected
Part Description
Value Description
Item Method
Applies To Layers Collection, Parts Collection, Points Collection, Strings Collection, Fields Collection,
GeoDatasets Collection
The Item method syntax has the following object qualifier and part:
Part Description
index Required. A numeric expression that specifies the position or string expres-
sion that specifies the name of a member of the collection. Index must be a
number from 0 to a number that is one less than the value of the collections
Count property or a valid name.
Remarks In the case of the following objects, Item returns a reference to the member of the collection:
GeoDatasets, Layers, and Parts.
If the value provided as index does not match any existing member of the collection, an error
occurs.
The Item method is the default method for most MapObjects collections. Therefore, the
following lines of code are equivalent. All lines return the extent of the first layer in the map,
assuming roads is the first layer:
Map1.Extent = Map1.Layers.Item(0).Extent
Map1.Extent = Map1.Layers(0).Extent
Map1.Extent = Map1.Layers(roads).Extent
Note that you can refer to a layer by name as well as by index. The string matching for the
name is not case-sensitive. The following table summarizes which objects you can access by
numeric expression and which you can access by string expression:
GeoDatasets Fields
Layers Layers
Parts
Points
Strings
Example This example uses the Item method to iterate through the Layers collection of a Map to list
each layers name. To try this example, paste the code into the Declarations section of a form
containing a ListBox named List1 and a Map named Map1 that contains at least one
MapLayer. Press F5.
Option Explicit
List1.Clear
Set oLayers = Map1.Layers
For iLayer = 0 To oLayers.Count - 1
List1.AddItem oLayers.Item(iLayer).name
Next
End Sub
KeyDown Event
Applies To Map Object
Description The KeyDown event is a standard ActiveX control event, which occurs when the user clicks
on the map. The KeyPress event occurs after the KeyDown event.
Part Description
keyCode An integer specifying a key code corresponding to the Key which was
pressed. For a list of keycode constants, see the Visual Basic online refer-
ence.
shift An integer specifying the status of the Shift key, as described in Values.
Values The value of shift evaluates to a Visual Basic constant, and may have the following values
See Also Click Event, DblClick Event, KeyPress Event, KeyDown Event, LostFocus Event,
MouseMove Event, MouseDown Event
KeyPress Event
Applies To Map Object
Description The KeyPress event is a standard ActiveX control event, which occurs when the user clicks on
the map. The KeyPress event occurs after the KeyDown event.
Part Description
Remarks For more information about the KeyPress event, see the Visual Basic online reference).
See Also Click Event, DblClick Event, KeyPress Event, KeyDown Event, LostFocus Event,
MouseMove Event, MouseDown Event
LabelPlacer Object
A LabelPlacer is an object that symbolizes features, by drawing a string text on each feature
in a MapLayer. The text strings which are used to symbolize each feature are stored in a
Field in the MapLayers Recordset. The Field property specifies which Field should be used
for the label text.
A LabelPlacer gives the option of using a range of TextSymbols to display label text, using
the Symbol, Value, ValueCount and ValueField properties. The ValueField property
specifies which Field in the MapLayers Recordset contains a value indicating which
TextSymbol from the Symbol array is used to draw the labels.
By setting the ValueCount property you can determine how many values of its ValueField
property the LabelPlacer will provide a Symbol for. You should then set a TextSymbol for
each Symbol in the symbol array. In addition, you should specify which value in the
ValueField corresponds to which Symbol in the symbol array by setting the value array. For
example, if you wish to label features with a value of Road in the SymbolField with the first
Symbol in the symbol array (Symbol(0)), you should set the first Value in the value array to
equal Road, e.g:
Value(0) = Road
The DefaultSymbol property contains a TextSymbol object which is used to draw the label of
any feature which does not have a value in the ValueField, or for which a corresponding
Value is not set.
By setting the PlaceAbove, PlaceOn, and PlaceBelow properties, you can determine the
position of the label relative to the feature with which it is associated. Use SymbolHeight and
SymbolWidth to establish the space occupied by a Point features Symbol so the label does
not conflict with the Symbol .
You can control whether or not to draw the features in the MapLayer in addition to the labels
by setting the DrawBackground property, in addition you can specify a
BackgroundRenderer property to determine how those features are displayed . You can
control whether or not to draw duplicate labels on the MapLayer with the AllowDuplicates
property. You can determine whether or not to mask the labels by setting MaskLabels
property. In addition, you set the color of the mask with MaskColor.
A LabelPlacer differs from a LabelRenderer in that it can detect conflicts between labels and
it positions labels in such a way as to provide a more aesthetic appearance.
Properties
MaskColor SymbolHeight
Example This example uses the properties and methods of the LabelPlacer to render a street network.
To try this example, paste the code into the Declarations section of a form that contains a
CommandButton named Command1, two CheckBox controls named Check1 and Check2, and
a Map control named Map1 that contains a MapLayer with line features. The example assumes
the MapLayer is based on the Redlands shapefile in the sample data. Press F5. You can click-
drag to zoom in or use the right-mouse button to pan.
Option Explicit
Set Map1.Extent = r
fnt.Name = Times
fnt.Bold = False
LabelPlacer.Field = NAME
default symbol
LabelPlacer.DefaultSymbol.Height = Map1.FullExtent.Height / 150
Set LabelPlacer.DefaultSymbol.Font = fnt
LabelPlacer.AllowDuplicates = False
Check1.Value = vbUnchecked AllowDuplicates control
End Sub
LabelRenderer Object
A LabelRenderer is an object that represents a way of symbolizing features by drawing text
on a feature. The Field property is the name of the Field in the Recordset that stores the text
values to use as labels. The Symbol property returns the TextSymbol that you use to draw the
text. The SymbolCount property contains the number of symbols associated with the
LabelRenderer.
You can toggle several properties to control the appearance of the renderer. You can control
whether or not to draw the features in addition to the labels by setting the DrawBackground
property; you can control whether or not to draw duplicate labels on the MapLayer with the
AllowDuplicates property; and you can determine whether or not to spline text along line
features with the SplinedText property. Since splined text follows the order of Points of a
Line, you may need to set the Flip property to True in order to enhance the appearance of
splined text.
In addition to its Field property, the LabelRenderer provides several field-based properties
that let you drive how and even whether, labels display on the Map. You can set the Field that
specifies the height in map units of each label with the HeightField. You can set the rotation
angle of each label by specifying a RotationField that contains the angle to rotate each label.
The values stored in the Field specified as the SymbolField provide an index for each label
into the array of TextSymbol objects associated with the LabelRenderer through the Symbol
property. You can set the Field that specifies the horizontal offset distance with the
XOffsetField property and the vertical offset distance with the YOffsetField property. You
can also set the Field that specifies whether or not to fit labels between two-point line features
with the FittedField property. Finally, you can assign a level value to each label in the Field
specified by the LevelField property. Using the labels level value in concert with the
MaxLevel and MinLevel properties, you can control which levels the LabelRenderer will
draw.
Developers familiar with ARC/INFO annotation feature classes will recognize that many of
these properties map well onto the pseudo items associated with annotation. If you base the
MapLayer youre working with on an ARC/INFO coverage, you can set a property and refer
to the coverages pseudo items using the name of the pseudo item without the preceding dollar
sign ($), for example $OFFSETY should be referenced as OFFSETY.
Properties
MaxLevel SymbolCount
LastError Property
Applies To Geocoder Object, PlaceLocator Object
Description Returns a value that specifies the type of error that exists in the Geocoder or Standardizer
objects.
Part Description
value An integer that indicates the last error (See return Values).
Return Values The return values for the LastError property are EnhancedGeocodingErrorConstants.
Example This example checks if a Geocoder or Standardizer object is valid or not and uses the
LastError property to return messages about problems encountered in a Geocoder or
Standardizer object. If a problem exists, the code returns a message about the type of error. To
try this example, paste the code into the Declarations section of a form containing a Map
named Map1. Substitute appropriate values for the data paths. Press F5. You should find that
your Standardizer is Valid, but your Geocoder does not have any MatchVariableField proper-
ties set.
Option Explicit
End If
Case 19
msg = Error processing standardization rules
Case 20
msg = Cannot read standardization rules
Case 21
msg = Cannot access address file
Case 22
msg = Cannot write to output database
Case 23
msg = Match variable key field are unspecified
Case 24
msg = Street table is missing a geocoding index
Case 25
msg = Record count mismatch in building the indices
Case 26
msg = No indices were specified to build
Case 27
msg = Too many indices specified (the maximum is 10)
Case 28
msg = Corrupt metadata information
Case 29
msg = Metadata string is too long; key information is _
too complex
Case 30
msg = Could not find specified key field in database
Case 31
msg = The query is too complex, use less keys (or _
soundex searches)
Case 32
msg = No search queries given
Case 33
msg = Out of disk space
End Select
MsgBox Error: & msg, vbCritical, info
End If
End Sub
Dim gd As Object
Set gd = dc.FindGeoDataset(redlands)
lyr.GeoDataset = gd
lyr.Symbol.Color = moBlue
Map1.Layers.Add lyr
geo.Standardizer = stan
geo.StreetTable = gd
Layers Collection
A Layers collection object represents the collection of geographical data layers defined for a
Map. Each layer in the collection may either consist of vector data, in which case it is refer-
enced by a MapLayer object or it may consist of geographically referenced raster image data,
in which case it is referenced by an ImageLayer object. A MapLayer or an ImageLayer
represents a kind of spatial information - either human or natural phenomena; for example,
political boundaries, cities, highways, well sites, locations of customers, or soil types, rivers,
and lakes, etc. Using the Valid property, you can determine whether a MapLayer or an
ImageLayer is valid before adding it to the collection.
Use the Layers property of a Map object to retrieve its Layers collection. The default
property of Layers is Item. You can access members of the Layers collection either by
numeric index or by the Name of the MapLayer.
Properties
Count
Methods
Layers Property
Applies To Map Object
Part Description
Remarks You can manipulate members of the Layers collection using standard collection methods (for
example, the Add and Remove methods). Each element in the collection can be accessed by
its index.
Example This example uses the Layers property to iterate through all the Layers of a Map, adding the
name of each MapLayer to a List. To try this example, paste the code into the Declarations
section of a form containing a CommandButton named Command1, a ListBox named List1,
and a Map named Map1 that contains at least one MapLayer, and then press F5. Once the Map
displays, click Command1.
Option Explicit
Private Sub Command1_Click()
Dim l As MapObjects2.MapLayer
For Each l In Map1.Layers
List1.AddItem l.Name
Next l
End Sub
LayerType Constants
MapObjects defines the following LayerType constants to describe the layers in a Map.
LayerType Property
Applies To MapLayer Object, ImageLayer Object
Description Returns a value that indicates whether the layer is an ImageLayer displaying raster data, or
MapLayer displaying vector data.
Part Description
lyrType A LayerTypeConstant.
Return Values The return values for the LayerType property are LayerTypeConstants.
Example This example uses the LayerType property to determine whether the most recently added layer
in the MapLayers collection represents a MapLayer or an ImageLayer; if it is a MapLayer, the
code reports on some of the layers properties, if the layer is an ImageLayer, its added to the
bottom of the list of layers and others layers will be drawn on top of it. To try this example
paste the code into the Declarations section of a form containing a CommandButton named
Command1, a ListBox named List1, and a Map named Map1 that has at least one MapLayer.
Press F5 and click Command1.
Option Explicit
Private Sub Command1_Click()
Dim num As Integer
Dim f As MapObjects2.field
With Map1.Layers(0)
If .LayerType = moMapLayer Then
List1.AddItem Name: & .Name
List1.AddItem Visible: & Str(.Visible)
List1.AddItem Symbol color: & Str(.Symbol.color)
num = 1
For Each f In .Records.Fields
List1.AddItem Field & num & : & f.Name
num = num + 1
Next f
ElseIf .LayerType = moImageLayer Then
Map1.Layers.MoveToBottom 0
Map1.Refresh
End If
End With
End Sub
Left Property
Applies To Ellipse Object, Rectangle Object
Description Returns or sets the distance between the internal left edge of an object and the left edge of its
container.
Part Description
Example This example uses the Left property to set a border around a Map. When you resize the form,
the code maintains the dimensions of the border around the Map. To try this example, paste
the code into the Declarations section of a form containing a Map named Map1 that contains
at least one MapLayer. Press F5; then resize the form by dragging one of its corners.
Option Explicit
Length Property
Applies To Line Object
Part Description
Example This example makes use of the Length property to report back the length of a Line segment
you select. To try this example, copy the code into the Declarations section of a form that
contains a Map named Map1 that contains a MapLayer with Line features. Press F5 and click
on a line.
Option Explicit
LevelField Property
Applies To LabelRenderer Object
Description Returns or sets the Field that contains level information for a LabelRenderer object.
Part Description
Remarks You can use levels to control whether a label for a feature draws on a Map. Levels are stored
in the LevelField associated with a LabelRenderer. If you set a LevelField and its value for
the feature is outside the range of MinLevel and MaxLevel, the label for the feature will not
draw.
Example This example demonstrates how to set the LevelField property of a LabelRenderer and how to
control which levels the LabelRenderer draws by setting its MaxLevel property. To try this
example, paste the code into the Declarations section of a form containing a Map named Map1
that contains a MapLayer , two ComboBox controls named Combo1 and Combo2, a Slider
control named Slider1, and three Label controls named Label1, Label2, and Label3. The
Form_Load event code will position all the controls except the Map. Press F5. Select the name
of Field containing integer values that will serve as the LevelField and then select the name of
a Field whose values will provide the source of the text for the LabelRenderer. You can use the
slider to change the MaxLevel property.
Option Explicit
End Sub
Combo1.ListIndex = -1
Combo2.ListIndex = -1
Combo1.Text =
Combo2.Text =
Slider1.Min = 0
Slider1.Max = 3
Slider1.Value = 1
Slider1.LargeChange = Slider1.SmallChange
Label1.Left = Map1.Left
Label1.Top = Map1.Top + Map1.Height + Label1.Height * 1.5
Combo1.Left = Map1.Left + Label1.Width * 1.5
Combo1.Top = Label1.Top
Label2.Left = Map1.Left
Label2.Top = Label1.Top + Label1.Height * 2.5
Combo2.Left = Combo1.Left
Combo2.Top = Label2.Top
Label3.Left = Map1.Left
Label3.Top = Label2.Top + Label2.Height * 2.5
Slider1.Left = Combo1.Left
Slider1.Top = Label3.Top
End Sub
Line Object
A Line object represents a geometric shape that has two or more vertices. A Line may have
one or many discontinuous Parts; a Line with two or more Parts is a multi-part Line. Each
member of the Parts collection is a Points object, which represent the vertices of that part of
the Line. A multi-part Line acts as a single shape for methods such as SearchShape.
You can retrieve the bounding rectangle of a line with its Extent property. In addition, you can
return the length of a Line with the read-only Length property. You can use the DistanceTo
method to return the distance in map units to another Point, Points, Line, Polygon, or
Rectangle object. The geometric methods Buffer, Difference, Intersect, XOr and Union are
supported for Lines. To return the set of Points at which another object crosses the Line, use
the GetCrossings method.
The Line object supports Linear Referencing, which makes it possible to record relative
positions on or along Lines using measures. You can test whether a Line object has measure
values for all of its vertices using the IsFullyMeasured property, and you can update the
measure values using the MultiplyMeasures, OffsetMeasures, SetMeasures,
SetMeasuresAsLength and UpdateMeasures methods. You can get and set the individual
measure values along the Line using the Measure property of the Point objects that make up
its vertices. The ReturnMeasure method can be used to calculate measure values along a
Line. You can also return Point and Line events using the ReturnLineEvent and
ReturnPointEvents methods.
You can create Line objects in Visual Basic with code like this:
Dim myLine as New MapObjects2.Line
Note that in order to add points that represent vertices to a new Line object you must first
create a Points object, which represents the vertices of a part of the Line. Each vertex of the
part should be added using a Point object. Once you have built up the part, add the Points
object to the Parts collection of the Line. This can be done in Visual Basic with code like this:
Dim new_line as New MapObjects2.Line
Dim pts As New MapObjects2.Points
Dim pt As New MapObjects2.Point
pt.X = 100
pt.Y = 100
pts.Add pt
pt.X = 200
pt.Y = 200
pts.Add pt
pt.X = 300
pt.Y = 300
pts.Add pt
new_line.Parts.Add pts
See Also Points Object, TrackLine Method
Properties
IsFullyMeasured Parts
Methods
Intersect ReturnPointEvents
MultiplyMeasures SetMeasures
LineStyle Constants
MapObjects defines the following constants for use with line symbols.
LinkGroup Constants
MapObjects defines the following constants for use with the Geocoder objects
MatchVariableIntersectionLink property.
ListIndices Method
Applies To Geocoder Object
Description Returns the logical indices associated with the Geocoder object as a MapObjects Strings
object.
Part Description
variable A MapObjects Strings collection that stores the index definitions defined by
the Geocoder objects AddIndex method.
Locate Method
Applies To PlaceLocator Object
Description Locates place names that match a specified string and returns their geographic locations as a
Points collection
Part Description
Remarks Each Point in the Points collection represents the centroid of the feature which the placeName
was matched to. If MapObjects can not find the placeName, the Points collection will be
empty.
LocateCandidate Method
Applies To Geocoder Object
Description Matches the specified address against a candidate address, and returns the corresponding
AddressLocation.
Part Description
index A numeric expression that specifies the relative position of a member of the
candidate group associated with the Geocoder object.
Remarks The Geocoder objects GenerateCandidates method generates a list of candidates for
matching. The candidates in the list are ranked by their score, with the first candidate in the list
being the one with the highest score. If GenerateCandidates returns
mgGeocodeSuccessMultipleBest as a GeocodeSuccessConstant, more than one candidate in
the list have the same highest score. You can review the score of each candidate by examining
the objects Candidate property.
Location Property
Applies To AddressLocation Object
Part Description
Remarks After a successful address match, the geographical location of the matched address can be
returned using the Geocoders LocateCandidate method, which returns an AddressLocation.
The AddressLocation object can be displayed on a Map using the Location property.
The Location of the geocoded address will be affected by the SqueezeFactor and Offset if
these properties are set.
Example This example demonstrates how to use the StreetSide property to report which side of the
street a matched address falls on. The example also demonstrates the use of the Matched
property to determine if the address specified resulted in a match. To try this example, paste
the code into the Declarations section of a form that contains a CommonDialog control named
CommonDialog1, a Map named Map1, a TextBox named Text1, and two CommandButton
controls named Command1 and Command2; then press F5 and click the Load button to
specify a GeoDataset that represents a street network. Enter an address in the TextBox and
press Match. The code reports the side of the street the address falls on.
Option Explicit
Dim theGeocoder As New MapObjects2.Geocoder
Dim stan As New MapObjects2.Standardizer
If Len(Text1.Text) = 0 Then
MsgBox Please enter an address in the text box
Exit Sub
End If
Map1.TrackingLayer.ClearEvents
If addLoc.StreetSide = 0 Then
msg = left
Else
msg = right
End If
Map1.Refresh
MsgBox The address is on the & msg & side of _
the street, vbInformation, MapObjects
Else
MsgBox MapObjects couldnt match this address, vbCritical, _
MapObjects
Text1.SetFocus
End If
Else
MsgBox The geocoder is not valid & Chr(13) & _
theGeocoder.LastError
Unload Me
Exit Sub
End If
End Sub
With CommonDialog1
.Filter = ESRI Shapefiles (*.shp)|*.shp
.DefaultExt = *.shp
.CancelError = True
Change the path below if necessary
.InitDir = C:\Program Files\ESRI\MapObjects2
On Error Resume Next
.ShowOpen
If Err.Number = cdlCancel Then
MsgBox No street table selected... & Chr(13) & ...exiting, _
vbCritical, MapObjects
End
End If
ft = .FileTitle
fn = .FileName
End With
X = Left(ft, Len(ft) - 4)
dcx.Database = Left(fn, Len(fn) - Len(ft) - 1)
dcx.Connect
Call setupGeocoder
Text1.SetFocus
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub setupGeocoder()
theGeocoder.Standardizer = stan
stan.StandardizeAddress (Text1.Text)
Else
MsgBox The standardizer is not valid & Chr(13) & Please check
_
the standardizer properties
MsgBox stan.LastError
Exit Sub
End If
End Sub
Command1.Caption = Load
Command2.Caption = Match
Command2.Enabled = False
Text1.Text = 60 Parkwood Dr
sym.SymbolType = moPointSymbol
sym.Color = moRed
sym.Size = 6
End Sub
Longitude Property
Applies To PrimeMeridian Object
Description Sets or returns a value that specifies the zero longitude for coordinates that are measured from
projections built using this PrimeMeridian.
Part Description
Example This example demonstrates how to access the Longitude property of the PrimeMeridian
object, and draws a vertical line at that longitude. To try this example, paste the code into the
Declarations section of a new Form which has a Map named Map1, which has at least one
MapLayer, each having a ProjCoordSys coordinate system set. Then press F5.
Dim meridSym As New MapObjects2.Symbol
Dim currLong As Double
Dim mLine As New MapObjects2.Line
currLong = Map1.Layers(0).CoordinateSystem. _
GeoCoordSys.PrimeMeridian.Longitude
With meridSym
.SymbolType = moLineSymbol
.Color = moRed
.Size = 2
.Style = moDashLine
End With
End Sub
End Sub
LostFocus Event
Applies To Map Object
Description The LostFocus event is a standard ActiveX control event, which occurs if the Map control
has the focus, and the user clicks on a different control or Form, or a different control or Form
receives focus programmatically.
Part Description
Remarks For more information about the LostFocus event, see the Visual Basic online reference.
See Also Click Event, DblClick Event, KeyPress Event, KeyDown Event, LostFocus Event,
MouseMove Event, MouseDown Event
Map Control
A Map control displays a collection of Layers. Each layer is based on geographic data (either
a MapLayer based on vector data, or an ImageLayer based on raster data). In addition, a
Map has a TrackingLayer to display geographic phenomena that may change position.
MapObjects represents these geographic phenomena with GeoEvent objects. The default
property for a Map object is the Layers collection.
To change the way in which your map is displayed, you may wish to set the RotationAngle or
VisibleRegion properties. A Map control may have a different CoordinateSystem to the
MapLayers it contains, although ImageLayer objects, and GeoEvent objects on the
TrackingLayer in a Map share the same coordinate system as the Map control. If you wish
to display several MapLayers with data in different coordinate systems, you should also set
the CoordinateSystem property of both the MapLayers and the Map control.
You can simplify your coding tasks by using your development environments Properties
dialog to set the presentation properties of the Map such as Appearance, BorderStyle,
BackColor, ScrollBars, WindowMode, or you can use the Map Control Properties dialog
box to set properties of the Map and attach MapLayer or ImageLayer objects to the Map
and set their properties.
You can control the spatial area displayed on the map by setting the Extent property. This
property is read-writeable, you may like to change by using the TrackRectangle method. The
FullExtent of the Map represents the union of all the MapLayer extents in the Map. The
Pan method provides a way to move the Map objects extent with the mouse, whereas the
CenterAt method provides a way to position the Map so that a specific coordinate pair is at
its center.
Set the MinWidth property to determine the minimum width in map units that may be
displayed on the Map. Use the CancelAction property to determine what action to take if the
user presses the ESC key when the application draws the Map. To redraw or invalidate the
Map, use the Refresh method. If you have added new features to a MapLayer, you may wish
to use the RefreshLayer method instead. The FullRedrawOnPan property provides special-
ized applications the ability to control whether or not to use MapObjects default display
optimizations after a scroll or pan.
To draw geometric shapes or create geometric shapes that you can use to select features first
use the TrackCircle method, TrackLine method, TrackPolygon method, TrackRectangle
method, or the ToMapPoint method in a MouseDown event to construct the shape; then, if
you want to display the shape, use DrawShape in one of the drawing events such as
AfterTrackingLayerDraw. To flash a feature or other shape on the Map use the FlashShape
method. To display graphic text on the Map use DrawText.
The Microsoft Windows operating environment identifies each form and control in an applica-
tion by assigning it a handle, or hWnd. Windows API calls use the controls hWnd. Using the
hWnd of a Map, you can expose it to the entire Windows API. See the hWnd property
Example.
MapObjects provides four methods to output the visible extent of a Map to a variety of
destinations. You can use the CopyMap method to copy the visible extent of a Map to the
Clipboard in enhanced and standard metafile format. Use the ExportMap method to write the
visible extent of the Map to a specified file in one of several formats or ExportMap2 if you
have ImageLayers whose image depth exceeds 8 bits/pixel. Use the PrintMap method to
print the visible extent of the Map to a Printer. Use the OutputMap method to render the
visible extent of the Map to the specified device context (hDC). OutputMap2 is identical to
OutputMap except that it allows you to specify a destination Rectangle within which to
render on the target DC and an optional parameter specifying how the Map should be ren-
dered.
Properties
Extent Name
FullExtent RefreshCount
Methods
Events
DblClick GotFocus
DragDrop KeyDown
See Also MapLayer Object, DataConnection Object, GeoDataset Object, TrackingLayer Object
MapLayer Object
A MapLayer object represents a geo-referenced data layer on a Map, drawn with features
from a GeoDataset. You can derive a GeoDataset object from an ESRI shapefile, an SDE
layer, an ARC/INFO coverage, CAD files and VPF data.
The bounding rectangle of a MapLayer is stored in its Extent property, contributing to the
extent of the Map.
Using the Valid property, you can determine whether a MapLayer is valid before adding it to
the Layers collection. Use the Layers property of a Map object to retrieve its Layers
collection. The default property of Layers is Item.
You can retrieve the Recordset associated with a MapLayer with the Records property. To
draw a MapLayer, you create a Renderer object, establish that object as the MapLayer
objects renderer and then set the properties of the renderer. By default, a MapLayer draws
with a single Symbol. Use the Visible property to toggle whether a MapLayer or an
ImageLayer is visible or hidden.
You can perform spatial queries on MapLayer objects and qualify them with SQL where
clause expressions by using the MapLayer methods SearchByDistance or SearchShape.
Use SearchExpression to perform logical queries on the Recordset associated with the
MapLayer. You can also display subsets of the features contained in a MapLayer by setting
the FilterExpression or FilterShape properties.
You can associate tabular information stored in another table with the Recordset of a
MapLayer by creating a relate with the AddRelate method.
Each MapLayer also has a CoordinateSystem property, which is used to define the coordi-
nate system in which the MapLayer objects GeoDataset is stored. By setting the
CoordinateSystem property of each MapLayer appropriate to the underlying data, data
stored in different coordinate systems may be displayed together, projected on-the-fly to a
common coordinate system.
You can create MapLayer objects in Visual Basic with code like this:
Dim mlyr as New MapObjects2.MapLayer
See Also Map Object, GeoDataset Object, DataConnection Object, TrackingLayer Object
Properties
FilterOperator Records
Methods
MarkerStyle Constants
MapObjects defines the following constants for use with marker symbols.
moCircleMarker 0 Circle
moSquareMarker 1 Square
moTriangleMarker 2 Triangle
moCrossMarker 3 Cross
moTrueTypeMarker 4 TrueType
MaskColor Property
Applies To LabelPlacer Object
Part Description
color A value or constant that determines the color of the masked area.
For more information on color settings, see the Color settings topic in the online help.
Remarks The MaskColor property determines the color which is placed behind the label text. This
property can be used to aid the clarity of the map display.
Example This example demonstrates the use of the properties associated with label masks of the
LabelPlacer. To try this example, paste the code into the Declarations section of a form that
contains a CommonDialog control, a CommandButton named Command1, a CheckBox named
Check1, and a Map control named Map1 that contains a MapLayer with line features. Press
F5. Click the button to set a new MaskColor You can click-drag a rectangle to zoom in to an
area. You should set the Field property and the DefaultSymbols Height property to values
appropriate to your data.
Option Explicit
Dim lp As New MapObjects2.LabelPlacer
fnt.Bold = True
Set Map1.Layers(0).Renderer = lp
With lp
Set .DefaultSymbol.Font = fnt
.UseDefault = True
.DefaultSymbol.Height = Map1.FullExtent.Height / 25 arbitrary
.Field = NAME
.DrawBackground = True draws the features
End With
Command1.Caption = Mask Color...
Check1.Caption = Mask Labels
Check1.Value = vbChecked
lp.MaskLabels = True
lp.PlaceOn = True
End Sub
MaskLabels Property
Applies To LabelPlacer Object
Description Returns or sets a value indicating whether the LabelPlacer should mask labels with a colored
rectangle.
Part Description
Setting Description
True The LabelPlacer will position masks between the labels and the features.
False The LabelPlacer will not position masks between the labels and the
features.
MatchRules Property
Applies To Geocoder Object
Description Returns or sets the match rule file name associated with the Geocoder object.
Part Description
rule filename A string expression that specifies the Match rule file name.
Remarks MapObjects provides a set of match rules for different types of addresses. The match rules
.mat file specifies information about how the Geocoder will match the street information from
the street network GeoDataset with the addresses specified in the BatchMatch or
GenerateCandidates methods. The .mat file works in conjunction with the Standardizers
properties.
Select the one that is suitable to the type of address you want to match.
You can find the following Match rule files in the Georules folder:
US addresses with zone information, StreetTables with single house range (us_srng1.mat)
Example This example demonstrates how to set the MatchRules, MatchVariables, IntersectionRules and
MatchVariableIntersectionLink properties of a Geocoder object. These properties are required
before you start matching addresses. To try this example, paste the code into the Declarations
section of a form that contains a Map named Map1 and a ListBox named List1. Substitute
appropriate values for the data paths and then press F5.
Option Explicit
Dim gd As Object
Dim lyr As New MapObjects2.MapLayer
Dim f, i As Integer
Dim name As String
geo.MatchVariableField(LeftZone) = m_LeftZone
geo.MatchVariableField(RightZone) = m_RightZone
List1.AddItem ( )
List1.AddItem (Intersection Match Rule File Name = & _
geo.IntersectionMatchRules)
List1.AddItem ( )
List1.AddItem (Intersection Match Variable Name)
List1.AddItem ( )
f = geo.IntersectionMatchVariableCount
For i = 0 To f - 1
name = geo.IntersectionMatchVariable(i)
List1.AddItem vbTab & name
Next i
End Sub
MatchScore Property
Applies To AddressLocation Object
Description Returns a value that indicates the match score for an AddressLocation object.
Part Description
variable An numeric expression that will hold the match score (data type is double).
Remarks A MatchScore of 100 indicates a perfect match, with a score of 0 indicating no match at all.
MatchScores around 30-70 are more usual. However, due to the complexities of the match
process, these are not hard and fast values.
For example, you may expect higher MatchScore values if your address string and your
StreetTable have data entered to a strict procedure. There are many factors in the geocoding
process, and you may have to experiment to find the right combination for your data.
Example This example demonstrates the use of the MatchScore property to return the status of an
attempt at matching an address. To try this example paste the code into the Declarations
section of a form that contains a Map named Map1, a TextBox named Text1, a
CommandButton named Command1, and a ListBox named List1. Press F5, click the Load
button, and select a dataset. The example below uses the Redlands sample dataset. If you are
not using this dataset, you may have to change the properties of the Geocoder and
Standardizer for your data. Now press the Match button or move the slider, candidates with a
MatchScore above the MinimumMatchScore are drawn with a Red symbol, those below are
drawn with a yellow symbol. Try entering a different address in the TextBox.
Option Explicit
Dim theGeocoder As New MapObjects2.Geocoder
Dim addLoc As MapObjects2.AddressLocation
Dim pt As MapObjects2.Point
Dim stan As New MapObjects2.Standardizer
Dim sym As New MapObjects2.Symbol
Dim sym2 As New MapObjects2.Symbol
Call setupGeocoder
Select Case s
Case 1
Label3.Caption = Single best candidate found
Case 2
Label3.Caption = Mulitple best candidates found
Case 3
Label3.Caption = No candidates found above minimum match
score
Case 0
Label3.Caption = No candidates found
End Select
Map1.Refresh
End Sub
Else
theGeocoder.StreetTable = gds
Text1.Text = 60 Alta st
Command1.Caption = Match
Slider1.Max = 100
Slider1.Min = 0
Slider1.Value = 35
Label1.Caption = 0
Label2.Caption = 100
Label3.Caption =
sym.Color = moRed
sym2.Color = moYellow
End If
End Sub
theGeocoder.MatchVariableField(StreetName) = name
theGeocoder.MatchVariableField(StreetType) = type
theGeocoder.MatchVariableField(SufDir) = suffix
End Sub
MatchVariable Property
Applies To Geocoder Object
Description Returns the name of variables defined in the match rules associated with the MatchRules
property of the Geocoder object.
Part Description
index A numeric expression that specifies the relative position of a member of the
group of MatchVariable names associated with the Geocoder object. Index
must be a number from 0 to a number that is one less than the value of the
Geocoder objects MatchVariableCount property.
MatchVariableCount Property
Applies To Geocoder Object
Description Returns the number of MatchVariables defined in the MatchRules property associated the
Geocoder object.
Part Description
MatchVariableField Property
Applies To Geocoder Object
Description Returns or sets the field name in the StreetTable for the MatchVariable associated with the
Geocoder object.
Part Description
variable A string expression that specifies the variable name that is returned from the
Geocoder objects MatchVariable property.
fieldName A string expression that specifies the name of the field in the StreetTable.
Remarks The MatchVariableField property is used to link fields in the StreetTable with variables
defined in the .mat file. If a MapLayer object contains the street network you wish to geocode
against, the Records property of the MapLayer can be used to access the field names. The
variables defined in the .mat file can be accessed using the MatchVariable property of the
Geocoder.
MatchVariableIntersectionLink Property
Applies To Geocoder Object
Description Returns or sets the field name(s) in the StreetTable associated with the
IntersectionMatchVariable(s) defined on the Geocoder object.
Part Description
variable A string expression that specifies the variable name that is returned from the
Geocoder objects IntersectionMatchVariable property.
LinkGroup A value or constant that specifies the type of link group as defined in the
LinkGroupConstants.
fieldName A string expression that specifies the name of the field in the StreetTables
GeoDataset.
Remarks The variable part of the syntax is defined in the us_intsc1.mat and us_intsc2.mat files. Many
MatchVariableIntersectionLink variables may be defined.
MatchWhenAmbiguous Property
Applies To Geocoder Object
Description Returns or sets a value that indicates whether a match is considered successful if multiple
candidates with the same MatchScore are found. This property only applies to the batch
matching process, using the Geocoder objects BatchMatch method.
Part Description
Remarks Setting the property to True will force MapObjects to match an address against the first one of
the multiple candidates that generate the same highest score if the score is higher or equal to
the Geocoder objects MinimumMatchScore property. A False value will force MapObjects
to skip matching the address that generates multiple candidates with the same score even
though the score is higher or equal to the MinimumMatchScore property. The default value
for the MatchWhenAmbiguous property is False.
Max Property
Applies To Statistics Object
Description Returns a value that indicates the maximum value calculated by a Statistics object.
Part Description
value A double data type specifying the maximum value calculated by the Statis-
tics object.
Remarks To create a Statistics object whose statistical properties you can return, use the Recordset
objects CalculateStatistics method, for example:
Set stats = Map1.Layers(0).Records.CalculateStatistics(tot_vote)
See Also CalculateStatistics Method, Statistics properties
MaxFileBuffer Property
Applies To Map Object
Description This property sets or returns the amount of memory to be used to file reading, in bytes.
Part Description
value A numeric that determines the maximum file buffer size, in bytes.
Remarks In order to read large shapefiles, MapObjects maps the shapefile into memory in sections. The
amount of memory used for this operation is defined in the MaxFileBuffer property. In the
majority of cases, you will not need to change the MaxFileBuffer property.
If you are using particularly large files and have large amounts of memory, you may wish to
change the MaxFileBuffer size. A larger MaxFileBuffer size will mean that each MapLayer
is read faster, but a smaller size means that smaller sections of memory are used while reading
each file; less resources are used but the drawing of the MapLayers may take longer. If using
this property, users should be careful not to set MaxFileBuffer to a size which requires more
memory to display the Map than is available on the system.
MapObjects will only use memory mapping when it has exclusive access to a file, i.e. the
GeoDataset objects AllowSharing property is set to false.
If the MaxFileBuffer property is set to Zero, memory mapping will not be used at all. The
default MaxFileBuffer size is 1 megabyte.
Example This example returns the current size of the MaxFileBuffer property, if the GeoDataset of its
MapLayer does not currently allow sharing. To try this example, paste the code into the
Declarations section of a form containing a Map named Map1 and a Label named Label1.
Alter the Database and FindGeoDataset properties as appropriate, and then press F5.
Dim dc As New MapObjects2.DataConnection
Dim geo As New MapObjects2.GeoDataset
Dim layer As New MapObjects2.MapLayer
Option Explicit
setLabel
End Sub
MaxLevel Property
Applies To LabelRenderer Object
Description Returns or sets the maximum LevelField value at which a LabelRenderer object will draw
labels.
Part Description
value A numeric expression that indicates the maximum value stored in its
LevelField at which a LabelRenderer draws text. (Data is Integer).
Remarks You can use levels to control whether a label for a feature draws on a Map. Levels are stored
in the LevelField associated with a LabelRenderer. If you set a LevelField and its value for
the feature is outside the range of MinLevel and MaxLevel, the label for the feature will not
draw.
MaxPieSize Property
Applies To ChartRenderer Object
Description Returns or sets the maximum pie chart size of the ChartRenderer object.
Part Description
value An integer that represents the radius in points that corresponds to the largest
pie chart in the collection.
Remarks All pie charts will be scaled into the range between MinPieSize and MaxPieSize. If no
SizeField is specified then the size of the pie chart will be determined by the sum of the values
in the chart. The ChartRenderer will reverse values if MaxPieSize is less than MinPieSize.
Mean Property
Applies To Statistics Object
Description Returns a value that indicates the mean value calculated by a Statistics object.
Part Description
value A double data type specifying the mean value calculated by the Statistics
object.
Remarks To create a Statistics object whose statistical properties you can return, use the Recordset
objects CalculateStatistics method, for example:
Set stats = Map1.Layers(0).Records.CalculateStatistics(tot_vote)
See Also CalculateStatistics Method, Statistics properties
Measure Property
Applies To Point Object
Part Description
Example This example uses the Measure property of a Point object to create a list of Measures of Points
in a Line. To try this example, paste the code into the Declarations section of a form contain-
ing a ListBox named List1, and a Map named Map1 which contains one shapefile MapLayer
with Measured Lines, and then press F5.
Option Explicit
List1.Clear
Set recs = Map1.Layers(0).Records
recCount = recs.Count
For i = 0 To recCount - 1
Set line = recs(Shape).Value
outputMeasures line
Next i
End Sub
itemCount = itemCount + 1
With partLine.Item(i)
List1.AddItem Item: & i & , & itemCount & Chr(9) & X: _
& .X & Chr(9) & Y: & .Y & Chr(9) & M: & .Measure
End With
Next i
Next partLine
End Sub
Method Constants
MapObjects defines the following Method constants to describe the method by which a
GeoTransformation is calculated.
Method Property
Applies To GeoTransformation Object
Description Sets or returns a value that identifies the Method to be used to transform coordinates by the
GeoTransformation object.
Part Description
Min Property
Applies To Statistics Object
Description Returns a value that indicates the minimum value calculated by a Statistics object.
Syntax object.Min
Part Description
value A double data type specifying the minimum value calculated by the Statis-
tics object.
Remarks To create a Statistics object whose statistical properties you can return, use the Recordset
objects CalculateStatistics method, for example:
MinimumMatchScore Property
Applies To Geocoder Object
Description Returns or sets the minimum match score associated the Geocoder object. This score deter-
mines if each candidate is considered to be successfully matched by the BatchMatch method,
based on the candidates MatchScore.
Part Description
value A numeric expression that specifies the minimum match score, in the range
of 0 to 100. The value determines whether an address will be matched
against the found candidate in the batch matching process. The default
MinimumMatchScore value is 70. The value must be in the range of 0 to
100.
Remarks The batch matching process will not consider each candidate a successful match unless its
MatchScore is above that of the MinimumMatchScore. Therefore setting a higher
MinimumMatchScore restricts the results of the BatchMatch to those which have a higher
confidence of address match.
MinLevel Property
Applies To LabelRenderer Object
Description Returns or sets the minimum LevelField value at which a LabelRenderer object will draw
labels.
Part Description
value A numeric expression that indicates the minimum value stored in its
LevelField at which a LabelRenderer draws text. (Data type is Integer).
Remarks You can use levels to control whether a label for a feature draws on a Map. Levels are stored
in the LevelField associated with a LabelRenderer. If you set a LevelField and its value for
the feature is outside the range of MinLevel and MaxLevel, the label for the feature will not
draw.
MinPieSize Property
Applies To ChartRenderer Object
Description Returns or sets the minimum pie chart size of the ChartRenderer object.
Part Description
value An integer that represents the radius in points that corresponds to the
smallest pie chart in the collection.
Remarks All pie charts will be scaled into the range between MinPieSize and MaxPieSize. If no
SizeField is specified then the size of the pie chart will be determined by the sum of the values
in the chart. The ChartRenderer will reverse values if MaxPieSize is less than MinPieSize.
MinWidth Property
Applies To Map Object
Description Returns or sets the minimum width in map units that may be displayed on the Map.
Part Description
value A numeric expression that represents the minimum width in map units that
may be displayed on the Map. The default value is 0. (Data type is Double.)
Remarks Use the MinWidth property to control the extent to which the user may zoom in on the Map.
MinWidth allows zooming if the width of the Rectangle specified as the Extent of the Map
is greater than or equal to the MinWidth value.
Example This example uses the MinWidth property to control the extent to which you may zoom in on a
Map. To try this example, paste the code into the Declarations section of a form containing a
Map named Map1 that contains at least one MapLayer, and then press F5. Once the Map
displays, click-drag a Rectangle to zoom in on the Map. Once youve reached the MinWidth
threshold, you wont be able to zoom in any farther.
Option Explicit
Description The MouseDown event is a standard ActiveX control event, which occurs when the user
clicks on the map. The MouseUp event occurs when the user releases the mouse button again.
Part Description
button An integer specifying with which mouse button the user clicked on the Map,
as described in Values.
shift An integer specifying the status of the Shift key, as described in Values.
X A value of single data type, specifying the X coordinate of the mouse click,
in control units.
Y A value of single data type, specifying the Y coordinate of the mouse click,
in control units.
Values
The value of button evaluates to a Visual Basic constant, and may have the following values
The value of shift evaluates to a Visual Basic constant, and may have the following values
Remarks The MouseDown event can be used for intercepting every click, double-click or click-drag on
the Map control. For example, a left-click may invoke a TrackRectangle and which sets a
new Map Extent, and a right-click may invoke a Pan.
By using the MouseDown or MouseUp event in conjunction with the ToMapPoint method, a
Point can be created at the location where the user clicked on the Map, in map units.
See Also Click Event, DblClick Event, KeyPress Event, KeyDown Event, LostFocus Event,
MouseMove Event
MouseMove Event
Applies To Map Object
Description The MouseMove event is a standard ActiveX control event, which occurs when the user
moves the mouse pointers over the Map control.
Part Description
button An integer specifying with which, if any, mouse button is currently pressed,
as described in Values.
shift An integer specifying the status of the Shift key, as described in Values.
X A value of single data type, specifying the X coordinate of the current mouse
position, in control units.
Y A value of single data type, specifying the Y coordinate of the current mouse
position, in control units.
Values The value of button evaluates to a Visual Basic constant, and may have the following values,
The value of shift evaluates to a Visual Basic constant, and may have the following values,
Remarks The MouseMove event can be used for tracking the current location of the mousepointer. By
using the MouseMove event in conjunction with the ToMapPoint method, a Point object can
store the current location of the mouse pointer, in Map units. For example, moving the pointer
over a particular country may highlight that country, or flash information about the location in
the application.
See Also Click Event, DblClick Event, KeyPress Event, KeyDown Event, LostFocus Event,
MouseDown Event
MousePointer Constants
MapObjects defines the following color constants for use with the Map objects
MousePointer property.
moArrow 1 Arrow.
moIbeam 3 I beam.
moSizePointer 5 Size.
moSizeNS 7 Size N, S.
moSizeWE 9 Size W, E.
moUpArrow 10 Up arrow.
moHourglass 11 Hourglass.
moNoDrop 12 No drop.
moZoom 50 Zoom
moZoomIn 51 Zoom in
moPan 53 Pan
moPanning 54 Panning
moIdentify 55 Identify
moLabel 56 Label
moPencil 58 Pencil
MousePointer Property
Applies To Map Object
Description Returns or sets a value indicating the type of mouse pointer displayed when the mouse is over
the Map.
Part Description
Example This example uses the MousePointer property to set the cursor that appears on the map,
depending on whether youre zooming in on the map or panning. To try this example, paste the
code into the Declarations section of a form containing a Map named Map1 that contains at
least one MapLayer, and then press F5. Hold down the left mouse button and drag a rectangle
to zoom in on the Map. Hold down the right mouse button to pan the map.
Option Explicit
End Sub
Move Method
Applies To GeoEvent Object
Description Moves a GeoEvent object relative to its current location on the TrackingLayer.
Part Description
deltaX The horizontal distance in map units to move the GeoEvent relative to its
original location.
deltaY The vertical distance in map units to move the GeoEvent relative to its
original location.
Remarks When you apply the Move method to a GeoEvent, the TrackingLayer will redraw.
Example This example uses the Move method to perform a relative move of the most recently added
GeoEvent to a new location on the map. To try this example, paste the code into the Declara-
tions section of a form containing a CommandButton named Command1 and a Map named
Map1 that contains at least one MapLayer and then press F5. Add one or more GeoEvent
objects to the Maps TrackingLayer by clicking on the Map and then click Command1
repeatedly.
Option Explicit
With Map1.TrackingLayer
If .EventCount > 0 Then
.Event(.EventCount - 1).Move Map1.Extent.Width * 0.1, _
Map1.Extent.Height * 0.1
End If
End With
End Sub
.Size = 10
End With
End Sub
End Sub
MoveFirst Method
Applies To Recordset Object
Description Moves to the first record in a specified Recordset object and makes that record the current
record.
Syntax object.MoveFirst
Part Description
Example This example uses the MoveFirst method to return to the first record of a Recordset. To try
this example, paste the code into the Declarations section of a form containing a
CommandButton named Command1 and a Map named Map1 that has a MapLayer with a
modest number of features. Press F5 and then click Command1.
Option Explicit
Dim recset As MapObjects2.Recordset
Loop
recset.MovePrevious
Map1.FlashShape recset.Fields(shape).Value, 3
recset.MoveFirst
Map1.FlashShape recset.Fields(shape).Value, 3
End Sub
MoveNext Method
Applies To Recordset Object
Description Moves to the next record in a specified Recordset object and makes that record the current
record.
Syntax object.MoveNext
Part Description
Remarks Once the EOF property becomes True, successive calls to MoveNext may reference invalid
records. Do not call the MoveNext method when EOF is True.
Example This example uses the MoveNext Method to advance through all the records of a MapLayers
Recordset in order to create a report in a ListView control. The code also uses the EOF
property to test whether the end of the Recordset has been reached. To try this example, paste
the code into the Declarations section of a form containing two ComboBox controls named
Combo1 and Combo2, a ListView control named ListView1, and a Map named Map1 that has
at least one MapLayer. Press F5 and then choose a field in Combo1 that distinguishes features
from each other and then choose a field in Combo2 to see a list of fields to report on. The
ListView will display the results.
Option Explicit
Else
If f.Type < 21 Then rule out shape fields
Combo2.AddItem f.Name
End If
End If
Next f
End Sub
With Map1.Layers(0).Records
Do While Not .EOF
first fields set of values
Set itmX = ListView1.ListItems. _
Add(, , .Fields(Combo1.List(Combo1.ListIndex)).Value)
second fields set of values
itmX.SubItems(1) = .Fields(Combo2.List _
(Combo2.ListIndex)).ValueAsString
.MoveNext advance through the MapObjects2.Recordset
Loop
End With
End If
End Sub
MovePrevious Method
Applies To Recordset Object
Description Moves to the previous record in a specified Recordset object and makes that record the
current record.
Syntax object.MovePrevious
Part Description
Remarks MovePrevious should only be used on a full base Recordset, i.e. one that references an
unfiltered shapefile, ARC/INFO coverage, VPF files or CAD files. MovePrevious is not
supported by SDE layers.
Example This example uses the MovePrevious Method to set the current record of a MapLayer objects
Recordset. The code uses the MoveNext Method to move to the record after the first record
and then goes back one record. A MsgBox displays the field values of each of records. Three
strings display, the first and the last should match. To try this example, paste the code into the
Declarations section of a form containing a ComboBox named Combo1 and a Map named
Map1 that has at least one MapLayer. Press F5 and then choose a field name in Combo1.
Option Explicit
rec2 As Variant
Set recset = Map1.Layers(0).Records
Set fld = recset(Combo1.List(Combo1.ListIndex))
rec1 = fld Value is the default property
recset.MoveNext
rec2 = fld
recset.MovePrevious back up one record
rec = fld
MsgBox rec1 & , & rec2 & , & rec
Set fld = Nothing disassociate object variable
End Sub
MoveTo Method
Applies To GeoEvent Object, Layers Collection
Description Moves a member of a Layers collection from its current index position to a new index
position, or moves a GeoEvent to a new location on the TrackingLayer.
Part Description
value1 For a Layers collection: A numeric expression that evaluates to the current
index position in the collection.
value2 For a Layers collection: A numeric expression that evaluates to the target
index position in the collection.
For a GeoEvent: The new vertical location in map units of the GeoEvent.
Remarks When you apply the MoveTo method to a GeoEvent, the TrackingLayer will redraw.
If you have changed the order of layers in the Maps Layers collection you should refresh the
Map to see the result of the change.
Example This example uses the MoveTo method to perform an absolute move of the most recently
added GeoEvent to the center of the map. To try this example, paste the code into the Declara-
tions section of a form containing a CommandButton named Command1 and a Map named
Map1 that contains at least one MapLayer and then press F5. Add one or more GeoEvent
objects to the Maps TrackingLayer by clicking on the Map and then click Command1.
Option Explicit
Command1.Enabled = True
End Sub
MoveToBottom Method
Applies To Layers Collection
Description Moves a member of a Layers collection from its current Index position to the last Index
position in the collection.
The MoveToBottom method syntax has the following object qualifier and parts:
Part Description
index Required. A numeric expression that evaluates to the current Index position
in the collection.
Remarks The layer at the top is the last layer to draw, the layer at the bottom is the first layer to draw.
Example This example uses the MoveToBottom method to move a MapLayer or ImageLayer to the
bottom-most position in the Layers collection. To try this example, paste the code into the
Declarations section of a form containing a ListBox named List1 and a Map named Map1
containing two or more MapLayers or ImageLayers and then press F5 and click an item in the
list. The code moves the item to the bottom of the list and redraws the Map, drawing the item
first.
Option Explicit
MoveToTop Method
Applies To Layers Collection
Description Moves a member of a Layers collection from its current Index position to the first Index
position in the collection.
The MoveToTop method syntax has the following object qualifier and parts:
Part Description
index Required. A numeric expression that evaluates to the current index position
in the collection.
Remarks The layer at the top is the last layer to draw, the layer at the bottom is the first layer to draw.
Example This example uses the MoveToTop method to move a MapLayer or ImageLayer to the
topmost position in the Layers collection. To try this example, paste the code into the Declara-
tions section of a form containing a ListBox named List1 and a Map named Map1 containing
two or more MapLayers or ImageLayers and then press F5 and click an item in the list. The
code moves the item to the top of the list and redraws the Map, drawing the item last.
Option Explicit
MultiplyMeasures Method
Applies To Line Object
Description Multiplies the measure value of each vertex on a Line object by a factor.
Part Description
factor A numeric expression that represents the amount by which each measure
value is to be multiplied.
Remarks Null measure values will not be updated. Null measures are represented by no data values.
Example This example makes use of the SetMeasuresAsLength and MultiplyMeasures methods to set
and multiply the measures on a user-selected line segment, and report on those measures. To
try this example, copy the code into the Declarations section of a Form that contains a Map
named Map1 with a MapLayer containing line features, three ListBoxes named List1, List2
and List3, and three Labels above the lists named Label1, Label2 and Label3. Press F5 and
click on a line.
Option Explicit
List1.Clear
List2.Clear
List3.Clear
gLine.SetMeasuresAsLength
For Each theParts In gLine.Parts
For i = 0 To theParts.Count - 1
List2.AddItem theParts(i).Measure
Next i
Next theParts
gLine.MultiplyMeasures 3
For Each theParts In gLine.Parts
For i = 0 To theParts.Count - 1
List3.AddItem theParts(i).Measure
Next i
Next theParts
End If
End Sub
Name Property
Applies To Datum Object, Field Object, GeoDataset Object, GeoCoordSys Object,
GeoTransformation Object, ImageLayer Object, Map Object, MapLayer Object,
PrimeMeridian Object, ProjCoordSys Object, Projection Object, Spheroid Object, Table
Object, Unit Object
Description Returns or sets a user-defined name for an object. The property is read-only for GeoDataset,
Field, GeoTransformation, GeoCoordSys, ProjCoordSys and Projection objects.
Part Description
Remarks Note that if a Name of a Table object is file-based, for example, a dBASE file on disk, make
sure that it does not have an extension.
Example This example uses the Name property to populate a ListBox with the names of the fields of the
Recordset associated with a MapLayer. To try this example, paste the code into the Declara-
tions section of a form containing a ListBox named List1 and a Map named Map1 that
contains at least one MapLayer. Press F5.
Option Explicit
End Sub
NoNullValue Method
Applies To ChartRenderer Object
Syntax object.NoNullValue
The object placeholder is an object expression that evaluates to an object in the Applies To
list.
Remarks Use NoNullValue after youve set the NullValue property to signify that you no longer want
the ChartRenderer to treat a specified value as the Null value.
Example This example illustrates how to use the ChartRenderer property and method that handle null
values. You can specify a value that the ChartRenderer should treat as a null value. When it
encounters data that has this value, it ignores the data and does not render the feature. In the
example below the ChartRenderer draws pie charts that represent the FIPS codes for states and
counties of the United States. This is for illustration purposes only. Normally, youll use the
ChartRenderer to compare more meaningful numeric values associated with features. Some-
times your feature data may have a value that represents that data was not available, in which
case it may be more appropriate to specify a null data value. To try this example, paste the
code in the Declarations section of a form that contains a CheckBox named Check1 and a Map
named Map1 that contains a MapLayer that has numeric data to render.
Option Explicit
Dim cr As New MapObjects2.ChartRenderer
With Check1
.Caption = Set a Null Value
.Value = vbChecked
End With
With cr
.ChartType = moPie
.MinPieSize = 15
.MaxPieSize = 30
.FieldCount = 2
.Field(0) = MALES
.Field(1) = FEMALES MALES
.SizeField = POP1990
.Color(0) = moRed
.Color(1) = moGreen
End With
Set Map1.Layers(0).Renderer = cr
End Sub
NormalizationField Property
Applies To ChartRenderer Object
Description Returns or sets the field which will be used to normalize bar charts.
Part Description
Remarks If set, the value in the NormalizationField will be divided into the value of each field before
the chart is displayed. This property can be used to bring records in different units into a
common unit. For example, if profit and loss were recorded for different countries in local
currency, they could be converted into a common currency by the ChartRenderer by supply-
ing an exchange rate in the NormalizationField for each country.
NullValue Property
Applies To ChartRenderer Object
Description Returns or sets the value which signifies a Null value in the features Field attribute.
Part Description
value A numeric expression that specifies the numeric value the ChartRenderer
should treat as a null data value
Remarks The ChartRenderer will not render a chart for any feature that has a field which contains the
specified null value.
Once youve set the NullValue property, you must use the NoNullValue method to signify that
you no longer want the ChartRenderer to treat a specified value as the Null value.
If a Field contains an actual null value, then the individual slice of pie, or bar, will be rendered
with a value of zero.
Offset Method
Applies To Ellipse Object, Line Object, Polygon Object, Rectangle Object, Points Object
Part Description
deltaX The distance in map units to move the object horizontally. Negative values
move the object to the left.
deltaY The distance in map units to move the object vertically. Negative values
move the object down.
Remarks The Offset property sets the distance in map units, therefore if you wish to offset based on
device units, you should convert that value to map units before setting the Offset property.
Distance values may be any number equal to or greater than 0. The default Offset distance is
0, indicating that no Offset distance is added to the AddressLocation, and the geocoded
location will be placed on top of the centerline.
See Also Buffer Method, Difference Method, Intersect Method, Union Method, XOr Method
Example This example uses the Offset method to shift a Map by moving its Extent property. To try this
example, paste the code into the Declarations section of a form containing a CommandButton
named Command1 and a Map named Map1 that contains at least one MapLayer. Press F5,
then click Command1.
Option Explicit
Dim oRectangle As MapObjects2.Rectangle
Offset Property
Applies To Geocoder Object
Description Returns or sets a value in map units that represents the perpendicular distance from the street
centerline to offset a matched AddressLocation.
Part Description
distance A numeric expression that represents the perpendicular distance from the
street centerline to offset the matched address location. The default offset
distance is 0. (Data type is Double.)
Remarks This property applies to a Geocoder only if the Geocoders StreetTable contains left and
right house number match variables. The left and right house number match variables in the
StreetTable determine the direction of the offset. Use the offset property when adding
AddressLocations to a Map, so that the AddressLocations on either side of the street can be
distinguished from each other.
Example This example demonstrates the effects of setting the Offset and SqueezeFactor properties of a
Geocoder on a geocoded point location. To try this example, paste the code into the Declara-
tions section of a form that contains a Map named Map1, a CommandButton named Com-
mand1, four TextBoxes named Text1, Text2, Text3 and Text4, and two Labels named Label1
and Label2. Substitute appropriate values for the data paths and then press F5. Try different
values of offset distance and squeeze factor in Text3 and Text4, and see the differences of the
geocoded point location. Note that this example assumes the map units of the reference
StreetTable is in decmial degrees and the input offset distance is in feet. A function called
GetDegree is provided for converting the value in feet into decimal degrees.
Option Explicit
arrayLat = Array(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, _
55, 60, 65, 70, 75, 80, 85, 90)
FeetPerSecond = arrayFeet(i)
Exit For
End If
Next
GetDegree = outputDegree
End Function
If stan.StandardizeAddress(Text1.Text) Then
stan.FieldValue(ZN) = Text2.Text
geo.GenerateCandidates
If geo.CandidateCount > 0 Then
geo.Offset = 0
geo.SqueezeFactor = m_squeeze
Set foundLoc = geo.LocateCandidate(0)
Set pntLoc = foundLoc.location
If m_offset <> 0 Then
Distance of a longitude unit differs given a latitude.
Converts the offset value in feet to decimal degrees with the
consideration of the y value (i.e. latitude) of the point
location
Set the offset distance property of the geocoder and recalculate
the point location
deg = GetDegree(CDbl(m_offset), pntLoc.Y)
geo.Offset = deg
Set foundLoc = geo.LocateCandidate(0)
Set pntLoc = foundLoc.location
End If
Set new extent for the map
r.Bottom = pntLoc.Y - DIST_ZoomRadius
r.Top = pntLoc.Y + DIST_ZoomRadius
End If
End If
End Sub
Set up Standardizer
stan.StandardizingRules = C:\Program Files\ _
ESRI\MapObjects2\GeoRules\us_addr.stn
stan.IntersectionStandardizingRules = C:\ _
Program Files\ESRI\MapObjects2\GeoRules\us_intsc.stn
geo.Standardizer = stan
\ESRI\MapObjects2\GeoRules\us_intsc1.mat
End Sub
OffsetMeasures Method
Applies To Line Object
Description Adds a given value to every non-null measure on the vertices of a Line object.
Part Description
value A numeric expression that represents the amount by which the measures
should be offset.
Remarks Null measure values will not be updated. Null measures are represented by no data values.
Example This example makes use of the SetMeasures and OffsetMeasures methods to report on, and to
set and offset measures on a user-selected line segment. To try this example, copy the code
into the Declarations section of a Form that contains a Map named Map1 with a MapLayer
containing line features, three ListBoxes named List1, List 2 and List3, and three Labels above
them named Label1, Label2 and Label3. Press F5 and click on a line.
Option Explicit
List1.Clear
List2.Clear
List3.Clear
oLine.SetMeasures 0, 100
For Each vertices In oLine.Parts
For i = 0 To vertices.Count - 1
List2.AddItem vertices(i).Measure
Next i
Next vertices
oLine.OffsetMeasures 50
For Each vertices In oLine.Parts
For i = 0 To vertices.Count - 1
List3.AddItem vertices(i).Measure
Next i
Next vertices
End If
End Sub
OutputMap Method
Applies To Map Object
Description Renders the visible extent of the Map to the specified device context.
Part Description
See Also CopyMap Method, ExportMap Method, ExportMap2 Method, OutputMap2 Method,
PrintMap Method
Example This example uses the OutputMap method to render the visible extent of a Map to the speci-
fied device context. To try this example, paste the code into the Declarations section of a form
that contains a CommandButton named Command1 and a Map named Map1 that contains at
least one MapLayer, and then press F5; click Command1. The code sends the Map to the
Printer.
Option Explicit
Private Sub Command1_Click()
Printer.Print
Map1.OutputMap Printer.hDC
Printer.EndDoc
End Sub
OutputMap2 Method
Applies To Map Object
Description Renders the visible extent of the Map to the specified device context, given a destination
rectangle in device coordinates (pixels). Optionally, you may specify that the background
rectangle of the map not be drawn by setting the drawBackground parameter to False.
Part Description
drawFlags Optional. A value or constant which determines how the map is drawn on the
destination hDC, as described in Settings.
Remarks Note that MapObjects uses the target rectangle as a bounding guide, and will not distort the
geometry of the Map to fit the requested rectangle. Given an arbitrary height and width, this
method will scale the Map so that it will fit which ever dimension is smallest, centering itself
within the larger dimension. An appropriate technique is to supply rectangles whose relative
proportions in height and width match those of the maps actual extent.
See Also CopyMap Method, ExportMap Method, ExportMap2 Method, OutputMap Method,
PrintMap Method
Example This example uses the OutputMap2 method to render the visible extent of a Map to the lower
right corner of the specified device context. To try this example, paste the code into the
Declarations section of a form that contains a CommandButton named Command1 and a Map
named Map1 that contains at least one MapLayer, and then press F5; click Command1. The
code sends the Map to the Printer.
Option Explicit
Private Sub Command1_Click()
Dim pixHeight As Long
Dim PixWidth As Long
Printer.Print
Convert page dimensions to pixels.
pixHeight = Printer.ScaleHeight / Printer.TwipsPerPixelY
PixWidth = Printer.ScaleWidth / Printer.TwipsPerPixelX
Render map to lower right quadrant of printer page.
Map1.OutputMap2 Printer.hDC, PixWidth / 2, pixHeight / 2, _
PixWidth / 2, pixHeight / 2
Printer.EndDoc
End Sub
Outline Property
Applies To Symbol Object
Description Returns or sets whether the Symbol used to display an object has an outline or not.
Part Description
boolean A boolean expression specifying whether the object has an outline or not as
indicated in Settings.
Setting Description
Example This example uses the Outline property to control whether the Symbol used to display a
Polygon object has an outline or not. To try this example, paste the code into the Declarations
seciton of a form that has a Map named Map1 and a CheckBox named Check1; press F5.
Track a polygon on the Map and then use the CheckBox to toggle the polygons outline.
Option Explicit
Dim poly As MapObjects2.Polygon
OutlineColor Property
Applies To Symbol Object
Part Description
color A value or constant that determines the color of the outline of a symbol.
Settings For more information on color settings, see the Color settings topic in the online help.
Example This example uses the OutlineColor property to control the color of the border of the symbol
used to render a MapLayer. To try this example, paste the code into the Declarations section of
a form containing a CommonDialog control, a CommandButton named Command1 and a Map
named Map1 that contains one MapLayer with polygon features. Press F5 and click the button.
Make a selection from the Color dialog and click OK.
Option Explicit
Pan Method
Applies To Map Object
Syntax object.Pan
The object placeholder is an object expression that evaluates to an object in the Applies To
list.
Example The following example illustrates how to create a simple Pan and Zoom interface. When the
user clicks on the map and drags, the TrackRectangle event rubberbands a rectangle; when the
user releases the mouse, the map zooms to the specified area. If the user holds down the shift
key, the map will be panned instead. Note that if the user hits <Esc> when you invoke a
TrackRectangle method, a value of Nothing is returned. To try this example, paste the code
into the Declarations section of a form containing a Map named Map1 that contains at least
one MapLayer, and then press F5 and click and drag the mouse on the map.
Option Explicit
ParameterType Constants
MapObjects defines the following constants for use with the GetParameter and
SetParameter methods of the ProjCoordSys object.
MapObjects defines the following constants for use with the GetParameter and
SetParameter methods of the GeoTransformation object.
The Rotation values are in decimal seconds, whilst the Scale Factor is in parts per million
(ppm).
Parts Collection
A Parts collection holds the set of Points objects that make up the parts of a Polygon or Line
object. The Parts collection supports the standard collection properties and methods: Add,
Count, Item, and Remove, as well as the Insert and Set methods to reposition elements of
the collection.
Most Polygons or Lines are single part shapes, and have a Parts collection containing a
single Points object. This represents the vertices of the shape. However, multi-part shapes are
useful for representing multi-part features as single entities, such as the islands of Hawaii or a
lake and its island as a doughnut Polygon. For example, a doughnut Polygon has two
Items in its Parts collection, one that represents its outer boundary, and another that repre-
sents the hole.
The Points objects returned from the Parts collection are direct references to the vertices of
each part of the Line or Polygon feature. This means that you can directly change a Point
representing an individual vertex. The following Visual Basic example shows the vertices of
myLine, a Line object, are offset by a factor value.
Dim i As Long
Dim pt As MapObjects2.Point
Dim pts As MapObjects2.Points
pts.Set i, pt
Next i
Next pts
At the end of this code, the myLine object has been changed but the underlying GeoDataset
has not. Any changes will be lost when myLine passes out of scope. To make the changes
persist; your program should call the Edit method on the Recordset that contains the feature.
You can then update the Value of the Shape Field for that record with the altered feature.
If you wish to use a part from a Line or Polygon object as a new shape, for example as a
search shape, you must create a new Points object, and add each Point contained in the Points
object returned from the Parts collection to this new object, e.g.:
Dim i As Long
Dim new_pts As New MapObjects2.Points
For i = 0 To myLine.Parts(0).Count - 1
new_pts.Add myLine.Parts(0).Item(i)
Next I
Properties
Count
Methods
Insert
Parts Property
Applies To Polygon Object, Line Object
Part Description
Example This example uses the Parts property to list the points that constitute a Polygon object. To try
this example, paste the code into the Declarations section of a form containing a ListBox
named List1 and a Map named Map1 whose topmost MapLayer contains polygon features.
Press F5, then click a polygon feature on the Map.
Option Explicit
List1.Clear
Set oPoint = Map1.ToMapPoint(x, y)
Set oMapRecords = Map1.Layers(0).Records
Do While Not oMapRecords.EOF
Set oShape = oMapRecords(shape).Value
If oShape.IsPointIn(oPoint) Then
Exit Do
End If
oMapRecords.MoveNext
Loop
Password Property
Applies To DataConnection Object, Table Object
Description Returns or sets the User password for an SDE DataConnection or ODBC Table.
Part Description
password A string expression that evaluates to a valid password for the database user
specified in the objects User property.
Example This example demonstrates the role of the Password, Server, and User properties in making an
SDE connection. To try this example, paste the code into the Declarations section of a form
containing a Map named Map1, a ListBox named List1, and a CommandButton named
Command1. Press F5 and click Command1 to connect to your SDE connection. In the input
box that appears, specify the name of the User.
Option Explicit
Dim oConnection As New DataConnection
Dim oGeoDataset As MapObjects2.GeoDataset
End With
Screen.MousePointer = vbDefault
End Sub
Perimeter Property
Applies To Polygon Object
Syntax object.Perimeter
Part Description
PlaceAbove Property
Applies To LabelPlacer Object
Description Returns or sets a value indicating whether the LabelPlacer should place a label above the
associated feature.
Part Description
Setting Description
True The LabelPlacer will position the labels above the features.
False The LabelPlacer will not position the labels above the features.
Example This example uses the PlaceAbove, PlaceOn, and PlaceBelow properties of the LabelPlacer to
demonstrate the options available for placing labels. Note that in some cases, choosing one
option will result in different features receiving labels. To try this example, paste the code into
the Declarations section of a form that contains an OptionButton control named Option1 and a
Map control named Map1 that contains a MapLayer with line features. For the OptionButton,
set its Index property to 0 in the Control Properties dialog box to create a control array of one
element, and then press F5. Click each OptionButton to see the results. You can click-drag a
rectangle to zoom in to an area. You may want to set the DefaultSymbols Height value to a
value in MapUnits appropriate to your data.
Option Explicit
Dim lp As New MapObjects2.LabelPlacer
Set Map1.Layers(0).Renderer = lp
With lp
Set .DefaultSymbol.Font = fnt
.UseDefault = True
.DefaultSymbol.Height = Map1.FullExtent.Height / 25
arbitrary map units
.Field = NAME
.DrawBackground = True draws the line features
End With
Create and position the option buttons
Dim I Declare variable.
Option1.Item(0).Value = True
End Sub
PlaceBelow Property
Applies To LabelPlacer Object
Description Returns or sets a value indicating whether the LabelPlacer should place labels below the
associated feature.
Part Description
Setting Description
True The LabelPlacer will position the labels below the features.
False The LabelPlacer will not position the labels below the features.
PlaceLocator Object
A PlaceLocator object lets you match place names to a GeoDataset that you specify with the
PlaceNameTable property.
Once youve set the PlaceNameTable property, you can use the BuildIndex method to index
the fields in that table against which you can search. You can determine whether an index
exists for the GeoDataset with the Indexed property. The index you build is static, if the
PlaceNameTable is changed, the index must be specifically re-built. The PlaceNameTable
index file has the same filename as the PlaceNameTable, with an extension of .gcx. If the
PlaceNameTable is based on a shapefile, ARC/INFO coverage or VPF file, the index file will
be located in the same directory as the PlaceNameTable. Using the Locate method on an
SDE layer is not supported.
To match place names to geographical locations, you can use the Locate method to return a
Points collection of geographic locations of all place names that match your criteria. In
addition you can use the FindApproximateMatches method to find approximate matches for
a given place name, or the FindAllPlaceNames method to find all place names that begin with
the specified characters. Both of these methods return their results as a Strings collection.
Properties
Indexed PlaceNameTable
Methods
FindAllPlaceNames
PlaceNameTable Property
Applies To PlaceLocator Object
Description Sets the PlaceNameTable property of a PlaceLocator object to a GeoDataset that contains
place names. This property is write-only.
Part Description
PlaceOn Property
Applies To LabelPlacer Object
Description Returns or sets a value indicating whether the LabelPlacer should place the label directly on
the associated feature.
Part Description
Setting Description
True The LabelPlacer will position the labels directly on the features.
False The LabelPlacer will not position the labels directly on the features.
Point Object
A Point object represents a geometric shape that consists of a single point in space. You can
get or set the location of a Point through its X, Y and Z properties. You can return the distance
in map units between one Point object and another Point, Points, Line, Polygon or Rect-
angle object using the DistanceTo method. You also can perform other geometric operations
such as Union, Intersect, ExclusiveOr, Difference and Buffer on the Point object.
Polygon and Line objects have a Parts collection, each Item in that collection representing
one part of a multi-part shape. Each Item in the Parts collection is a Points object, where
each Point in that collection represents one vertex of the shape.
You can create Point objects in Visual Basic with code like this:
Dim pt as New MapObjects2.Point
Properties
Measure X Y Z
ShapeType
Methods
Points Collection
A Points object is a shape that represents a set of points in space. A Points object is a collec-
tion of Point objects, and can be used for storing related Point shapes in a single geometric
object. You can get the location of each Point in the collection through its X, Y and Z proper-
ties.
To return a new Points object at which another shape object crosses an existing Points object,
use the GetCrossings method. You can also perform other geometric operations such as
Union, Intersect, ExclusiveOr, Difference and Buffer. Points objects may be used in the
DrawShape method, and as GeoEvent shapes. You can create a Points collection in Visual
Basic with code like this:
Dim pts as New MapObjects2.Points
Polygon and Line objects have a Parts collection, each Item in that collection representing
one part of a multi-part shape. Polygon and Line objects with a single part also have a Parts
collection, with only one member. Each Item in the Parts collection is a Points object, each
Point in that collection represents one vertex of the shape. To add points that represent
vertices to a new Line or Polygon object you must first create a Points object and then add to
it Point objects representing each vertex of that part. Once you have built up the part, add the
Points object to the Parts collection. This can be done in Visual Basic with code like this:
Dim poly as New MapObjects2.Polygon
Dim pts As New MapObjects2.Points
Dim pt As New MapObjects2.Point
pt.X = 100
pt.Y = 100
pts.Add pt
pt.X = 400
pt.Y = 100
pts.Add pt
pt.X = 250
pt.Y = 400
pts.Add pt
pt.X = 100
pt.Y = 100
pts.Add pt
poly.Parts.Add pts
The Points object is equivalent to the MultiPoint shape type in ESRIs ArcView GIS. If a
shapefile is created in ArcView, with the MultiPoint shape type, each feature from this file will
be returned in MapObjects as a Points object. The converse is also true; i.e. a GeoDataset
created in MapObjects and populated with Points objects will be read as a MultiPoint
Shapefile in ArcView.
Properties
Count Extent
Methods
Polygon Object
A Polygon object represents a geometric shape that has three or more vertices and forms a
closed ring. A Polygon may consist of one or more discontinuous Parts; a Polygon with two
or more Parts is a multi-part Polygon. Each member of the Parts collection is a Points object
that represents the vertices of the shapes that constitute each Part of the Polygon feature. A
multi-part Polygon is treated as a single shape for methods such as SearchShape.
You can return the bounding rectangle of a Polygon through its Extent property. In addition,
you can return the area and perimeter of a Polygon with the Area and Perimeter read-only
properties and you can use the Centroid property to return the centroid of a polygon as a
Point object. You can use the DistanceTo method to return the distance in map units to
another Point, Points, Line, Polygon, or Rectangle object. The geometric methods Buffer,
Difference, Intersect, ExclusiveOr and Union are supported for Polygons. To return the set
of Points at which another object crosses the Polygon, use the GetCrossings method.
You can create Polygon objects in Visual Basic with code like this:
Dim poly as New MapObjects2.Polygon
Note that in order to add points that represent vertices to a new Polygon object you must first
create a Points object, which represents the vertices of a part of the Polygon. Each vertex of
the part should be added using a Point object. You should ensure that the last vertex of each
part closes the ring, i.e. it is coincident with the first vertex. Once you have built up the part,
add the Points object to the Parts collection of the Polygon. This can be done in Visual Basic
with code like this:
Dim poly as New MapObjects2.Polygon
Dim pts As New MapObjects2.Points
Dim pt As New MapObjects2.Point
pt.X = 100
pt.Y = 100
pts.Add pt
pt.X = 400
pt.Y = 100
pts.Add pt
pt.X = 250
pt.Y = 400
pts.Add pt
pt.X = 100
pt.Y = 100
pts.Add pt
poly.Parts.Add pts
Properties
Count Extent
Methods
PopulateWithDatums Method
Applies To Strings Collection
Description Populates a Strings collection with the names and integer values of all Datum constants.
Syntax object.PopulateWithDatums
The object placeholder represents an object expression that evaluates to the name of a String
collection.
Remarks The values added to the Strings collection by this method include a name and integer value
for each DatumConstant.
The resultant Strings collection can be used to display a list of all pre-defined Datum types,
for example in a combo box. A user may then select a required Datum from the list, and the
pre-defined Datum type can be parsed from the selected string.
PopulateWithGeographicCoordSys Method
Applies To Strings Collection
Description Populates a Strings collection with the names of all Geographic coordinate system constants.
Syntax object.PopulateWithGeographicCoordSys
The object placeholder represents an object expression that evaluates to the name of a String
collection.
Remarks The values added to the Strings collection by this method include a name and integer value
for each GeographicCoordSysConstant.
The resultant Strings collection can be used to display a list of all pre-defined GeoCoordSys
types, for example in a combo box. A user may then select a required GeoCoordSys from the
list, and the pre-defined GeoCoordSys type can be parsed from the selected string.
PopulateWithGeoTransformations Method
Applies To Strings Collection
Description Populates a Strings collection with the names of all Geographic transformation constants.
Syntax object.PopulateWithGeoTransformations
The object placeholder represents an object expression that evaluates to the name of a String
collection.
Remarks The values added to the Strings collection by this method include a name and integer value
for each GeographicTransformationConstant.
The resultant Strings collection can be used to display a list of all pre-defined
GeoTransformation types, for example in a combo box. A user may then select a required
GeoTransformation from the list, and the pre-defined GeoTransformation type can be
parsed from the selected string.
PopulateWithMeridians Method
Applies To Strings Collection
Description Populates a Strings collection with the names of all PrimeMeridian constants.
Syntax object.PopulateWithMeridians
The object placeholder represents an object expression that evaluates to the name of a String
collection.
Remarks The values added to the Strings collection by this method include a name and integer value
for each DatumConstant.
The resultant Strings collection can be used to display a list of all pre-defined
PrimeMeridian types, for example in a combo box. A user may then select a required
PrimeMeridian from the list, and the pre-defined PrimeMeridian type can be parsed from
the selected string.
PopulateWithParameters Method
Applies To Strings Collection
Description Populates a Strings collection with all of the parameters that describe the components of a
given Projection.
Part Description
Remarks The values added to the Strings collection by this method include a name and integer value
for each ParameterTypeConstant for that ProjectionConstant.
The resultant Strings collection can be used to display a list of all pre-defined Parameter
types, for example in a combo box. A user may then select a required Parameter from the list,
and the pre-defined Parameter type can be parsed from the selected string.
PopulateWithProjectedCoordSys Method
Applies To Strings Collection
Description Populates a Strings collection with the names of all ProjCoordSys constants.
Syntax object.PopulateWithProjectedCoordSys
The object placeholder represents an object expression that evaluates to the name of a String
collection.
Remarks The values added to the Strings collection by this method include a name and integer value
for each ProjectedCoordSys Constant.
The resultant Strings collection can be used to display a list of all pre-defined ProjCoordSys
types, for example in a combo box. A user may then select a required ProjCoordSys from the
list, and the pre-defined ProjCoordSys type can be parsed from the selected string.
PopulateWithProjections Method
Applies To Strings Collection
Description Populates a Strings collection with the names of all Projection constants.
Syntax object.PopulateWithProjections
The object placeholder represents an object expression that evaluates to the name of a String
collection.
Remarks The values added to the Strings collection by this method include a name and integer value
for each ProjectionConstant.
The resultant Strings collection can be used to display a list of all pre-defined Projection
types, for example in a combo box. A user may then select a required Projection from the list,
and the pre-defined Projection type can be parsed from the selected string.
PopulateWithSpheroids Method
Applies To Strings Collection
Description Populates a Strings collection with the names of all Spheroid constants.
Syntax object.PopulateWithSpheroids
The object placeholder represents an object expression that evaluates to the name of a String
collection.
Remarks The values added to the Strings collection by this method include a name and integer value
for each SpheroidConstant.
The resultant Strings collection can be used to display a list of all pre-defined Spheroid types,
for example in a combo box. A user may then select a required Spheroid from the list, and the
pre-defined Spheroid type can be parsed from the selected string.
PopulateWithUnits Method
Applies To Strings Collection
Description Populates a Strings collection with the names of all Unit constants.
Syntax object.PopulateWithUnits
The object placeholder represents an object expression that evaluates to the name of a String
collection.
Remarks The values added to the Strings collection by this method include a name and integer value
for each UnitConstant.
The resultant Strings collection can be used to display a list of all pre-defined Unit types, for
example in a combo box. A user may then select a required Unit from the list, and the pre-
defined Unit type can be parsed from the selected string.
PrimeMeridian Constants
MapObjects defines the following constants for use with the Type property of a
PrimeMeridian object.
PrimeMeridian Object
The PrimeMeridian object defines the prime meridian, the line of zero longitude for coordi-
nates in a geographic coordinate system (GeoCoordSys object).
Properties
See Also Projection Object, GeoCoordsys Object, Datum Object, Spheroid Object, Unit Object
PrimeMeridian Property
Applies To GeoCoordSys Object
Description Sets or returns a value that identifies the PrimeMeridian upon which a GeoCoordSys object
is based.
Part Description
Example This example uses the PrimeMeridian property to check the PrimeMeridian property of
maplayers with geographic coordinate systems. Maplayers which are not projected, or have
the same datum as that chosen in the ComboBox, remain visible. Maplayers having a geo-
graphic coordinate system with the same datum as that chosen in the ComboBox are made
invisible. To try this example, paste the code into the Declarations section of a form containing
a Map named Map1 that contains at least one MapLayer, and a ComboBox named Combo1.
MapLayers should have thier CoordinateSystems property set. Press F5, and choose a datum
from the ComboBox.
Option Explicit
If Check1.Value = 1 Then
If any layer in the map has a prime meridian > 32 or <-10,
make it invisible.
For Each curLayer In Map1.Layers
If Not curLayer.CoordinateSystem.IsProjected Then
If (curLayer.CoordinateSystem.PrimeMeridian.Longitude < -10) _
Or (curLayer.CoordinateSystem.PrimeMeridian.Longitude > 32) Then
curLayer.Visible = False
End If
End If
Next curLayer
Else
For Each curLayer In Map1.Layers
curLayer.Visible = True
Next curLayer
End If
Map1.Refresh
End Sub
This code can be used to apply two GeoCoordSys objects, having two
different datums, to two MapLayers. You may wish to use your own
projection objects which are appropriate for your datasets.
Private Sub Form_Load()
End Sub
PrintMap Method
Applies To Map Object
The PrintMap method syntax has the following object qualifier and arguments:
Part Description
docName A string expression that evaluates to the name of an item in the printer
queue.
landscape A boolean expression that determines the orientation of the Map as specified
in Settings.
Setting Description
ImageLayers in the Map controls Layers collection have their Transparent property set to
True, then these too will not be visible.
See Also CopyMap Method, ExportMap Method, ExportMap2 Method, OutputMap Method,
OutputMap2 Method, PrintMap Method
Example This example uses the PrintMap method to print the visible extent of a Map in a form to the
default printer. To try this example, paste the code into the Declarations section of a form
containing a CommandButton named Command1 and a Map named Map1 that contains at
least one MapLayer, and then press F5 and click the button.
Option Explicit
ProjCoordSys Object
A projected coordinate system describes positions on the earth using a coordinate system
based on X and Y coordinate values. The coordinate system is projected from a spheroidal
approximation of the earth, based on a geographical coordinate system. The GeoCoordSys
property of a ProjCoordSys object defines which geographical coordinate system the
ProjCoordSys is projected from. The way in which the projection is calculated is defined in
the Projection property. The units of the coordinate system are defined in the Unit property.
A standard projected coordinate system can be created by setting the Type property with
ProjectedCoordSysConstants which include nearly one thousand pre-defined coordinate
systems.
Properties
IsProjected Projection
Methods
GetParameter
See Also Map Object, MapLayer Object, Projection Object, GeoCoordsys Object
ProjectedCoordSys Constants
MapObjects defines over nine hunderd and fifty constants for use with the Type property of a
ProjCoordSys object.
Projection Constants
MapObjects defines the following constants for use with the Type property of a Projection
object.
Projection Object
A projection is used by a projected coordinate system to specify the mathematical
transformation that is used to convert geographic coordinates to projected coordinates.
Properties
Projection Property
Applies To ProjCoordSys Object
Description Sets or returns a value that identifies the Projection upon which a ProjCoordSys object is
based.
Part Description
Remarks The Projection property contains a Projection object specifying the mathematical method
used to project locations from a geographical to a projected coordinate system.
RampColors Method
Applies To ClassBreaksRenderer Object, ZRenderer Object
Description Assigns a color to the first and last categories of a renderer object and interpolates the color
for each intervening category.
Part Description
Records Property
Applies To MapLayer Object, Table Object
Part Description
Remarks Visual Basic has its own Recordset class, so when using a MapObjects Recordset, be sure to
explicitly declare the class, for example:
Dim recs as New MapObjects2.Recordset
The Recordset returned by the Records property is a new object. If your program needs to
carry out a set of operations on a Recordset, you should make sure that it references the same
object throughout the sequence. The following Visual Basic example demonstrates this by
using a local Recordset object, recs, to reference the records of the MapLayer object,
new_layer.
recs.MoveFirst
While Not recs.EOF
recs.MoveNext
Wend
new_layer.Records.MoveFirst
While Not new_layer.Records.EOF
new_layer.Records.MoveNext
Wend
Example This example uses the Records property to access the Recordset of a MapLayer. The code
iterates through all the records of the recordset and flashes the shape of each feature of the
MapLayer. To try this example, paste the code into the Declarations section of a form contain-
ing a CommandButton named Command1 and a Map named Map1 that has at least one
MapLayer. Press F5 and click Command1.
Option Explicit
Recordset Object
A Recordset object represents the records associated with a GeoDataset or the records that
result from running a query. When you create a Recordset, you position the current record
position at its first record. The Fields property returns a collection of Field objects that
comprise the Recordset. You can navigate through the Recordset with the MoveNext
method, back up one record with the MovePrevious method, or move to the first record of the
Recordset with the MoveFirst method. The Count property returns the number of records in
the Recordset. The EOF property returns True as soon as you have moved past the last record
of the Recordset.
The default property of a Recordset is its Fields collection, and the default property of a Field
object is the Value property. You can simplify your code by taking advantage of these defaults.
For example, the following lines of code each return the value of the Population field in the
current record of a Recordset:
x = myRecordSet.Fields(POPULATION).Value
x = myRecordSet(POPULATION)
You can use the CalculateStatistics method to create a Statistics object based on a Field
name in the Recordset. Once you have created the Statistics object, you can return some basic
statistical values for the Field.
If the Recordset is Updateable, you can use the Edit method to allow updates on the current
record. The EditMode property indicates the state of editing for the current record. To delete
a record in the Recordset, use the Delete method. To create a new record in the Recordset,
use the AddNew method. The Update method saves the current record and any changes you
have made to it. If you want to discard a change to a record before updating, you can use the
CancelUpdate method to cancel any pending updates. To re-open the underlying table as
read-only after performing edits, use the StopEditing method. If you are creating a new
Recordset, you can use the TableDesc property to return the field characteristics of an
existing Recordset, effectively using them as a template for the new Recordset. Set the
AutoFlush property to False to prevent changes from being automatically flushed on a write
action. This greatly enhances performance when writing shapefiles.
If the Recordset supports transactions, then you can use the Edit method in a similar way to
carry out transactional editing on an external database table. You should first call the
StartTransaction method on your Recordset, and then carry out your edits. When you have
finished your editing, you can call either the CommitTransaction method if you wish to save
your changes to the data set, or RollbackTransaction to leave the data set the way it was
before you started your transaction.
Remarks To distinguish a MapObjects Recordset from a Visual Basic Recordset, fully qualify the class
name in declarations. For example:
Dim MyRecordset as MapObjects2.Recordset
Properties
EditMode SupportsTransactions
Methods
Delete MovePrevious
Rectangle Object
A Rectangle object represents a geometric shape with four edges and four right angles. You
can return the dimensions of a Rectangle object with the Height and Width parameters and
return its Center as a Point object. In addition, you can set and return its position and
dimensions with its Top, Left, Bottom and Right properties.
A Rectangle object can also represent a cuboid. By default, a Rectangle has a Depth of zero.
To set its Depth, use the Floor and Ceiling properties. You can use a three-dimensional
Rectangle as an argument to the SearchShape method for MapLayers that contain features
with Z values.
You can manipulate the size or dimension of Rectangle objects with the Inset,
ScaleRectangle, Intersect, or Union methods. Use the IsPointIn method to test if a point
falls within a Rectangle, and Intersects to test whether two Rectangle objects intersect one
another. You can use the DistanceTo method to return the distance in map units to another
Point, Points, Line, Polygon, or Rectangle object. To return the set of Points at which
another object crosses the Rectangle, use the GetCrossings method.
You can create Rectangle objects in Visual Basic with code like this:
Dim rect as New MapObjects2.Rectangle
Properties
Methods
Refresh Method
Applies To Map Object, TrackingLayer Object
Part Description
rect A Rectangle object representing an area within the map extent. If given
then only this area within the TrackingLayer will be refreshed. Applies to a
TrackingLayer object only.
Setting Description
False MapObjects only redraws the areas of the TrackingLayer that have been
made invalid by moving GeoEvent objects prior to the last redraw.
Remarks Any change you make to a GeoEvent will redraw the TrackingLayer of the map. If you want
to make the change immediately visible, you can use the Refresh method. This is only
necessary if you want to update the TrackingLayer prior to performing some other computa-
tions that may require a perceptible amount of time. Normally, you wont need to use the
Refresh method for this purpose.
The rectangle argument cannot be applied to this method on Map objects. Use the
RefreshRect method on the Map control instead.
Example This example uses the Refresh method to draw the Map again with a randomly assigned new
color for the topmost MapLayer. To try this example, paste the code into the Declarations
section of a form containing a CommandButton named Command1 and a Map named Map1
that contains at least one MapLayer. Press F5, then click Command1.
Option Explicit
RefreshCount Property
Applies To Map Object
Description Returns or sets a value that determines the rate at which the features of a Map draw.
Part Description
Remarks MapObjects draws features of a Map offscreen and throughout the drawing process it updates
the screen. The RefreshCount specifies how often MapObjects updates the screen during the
drawing process. If MapObjects has 1000 vertexes to draw and the Map objects
RefreshCount is 500, then the application will refresh the screen twice. A higher
RefreshCount results in faster draw times because there is less updating. A lower
RefreshCount results in slower draw times, but a smoother appearance.
Example This example uses the RefreshCount property to control the rate at which the features of a
Map draw. To try this example, paste the code into the Declarations section of a form contain-
ing three Label controls named Label1, Label2, and Label3, a Slider named Slider1, and a
Map named Map1 that contains at least one MapLayer, and then press F5. Drag the slider to
control the setting. The Form_Load code will position all the controls with the exception of
the Map.
Option Explicit
Private Sub Slider1_Click()
Map1.RefreshCount = Slider1.Value
Map1.Refresh
End Sub
.LargeChange = 2500
.SmallChange = 1000
.Top = Map1.Top
.Max = 20000
.Value = 10000
End With
With Label1
.AutoSize = True
.Caption = Slider1.Max
Slider1.Left = Map1.Left + Map1.Width + .Width
.Left = Slider1.Left - Label1.Width
.Top = Slider1.Top
End With
With Label2
.AutoSize = True
.Caption = Slider1.Min
.Left = Slider1.Left - Label2.Width
.Top = Slider1.Top + Slider1.Height - .Height
End With
With Label3
.AutoSize = True
.Caption = Slider1.Value
.Left = Slider1.Left
.Top = Slider1.Top + Slider1.Height + Label3.Height
End With
Width = (Map1.Left * 2) + Map1.Width + Label1.Width + Slider1.Width
End Sub
RefreshLayer Method
Applies To Map Object
Description Forces a repaint of the features in a specified MapLayer and the layers above it.
The RefreshLayer method syntax has the following object qualifier and parts:
Part Description
index Required. A numeric expression that evaluates to the current index position
of the MapLayer in the Layers collection.
rect Optional. A Rectangle Object representing an area within the layer extent. If
given then this only this area within the layer will be refreshed
Remarks The layer at the top is the last layer to draw, the layer at the bottom is the first layer to draw.
This method can be used where a feature has been added to a MapLayer, to update the
information contained on the Map without the need to perform a full Refresh.
This method should be used with care. RefreshLayer will repaint the features currently in the
specified layer. Locations on your Map where features have been removed from the Recordset
are not repainted, potentially resulting in artifacts being left on the Map control until the next
Refresh. Similarly, the movement or editing of features within a MapLayer may result in
artifacts on the Map control until the Map is fully refreshed. The programmer may however
use the RefreshRect method to force a re-paint of these areas of the Map, without the need
for a Refresh of the entire Layers collection.
Example This example uses the RefreshLayer method to repaint the specified layers and all those above
it. To try this example, paste the code into the Declarations section of a form containing a
ListBox named List1 and a Map named Map1 that contains several MapLayers, and then press
F5 and double-click the MapLayer in the ListBox.
Option Explicit
RefreshRect Method
Applies To Map Object
Description Forces a repaint of the region of the specified Rectangle for all layers in the Map.
The RefreshRect method syntax has the following object qualifier and parts:
Part Description
rect A Rectangle object representing an area within the map extent. Only this
area within each layer will be refreshed
Remarks The layer at the top is the last layer to draw, the layer at the bottom is the first layer to draw.
Example This example uses the RefreshRect property to refresh only the new extent of the map control.
To try this example, paste the code into the Declarations section of a form containing a Map
named Map1 that contains at least one MapLayer, and then press F5.
Option Explicit
Map1.Layers(0).Symbol.Color = moBlue
End Sub
End Sub
Remove Method
Applies To GroupRenderer Object, Layers Object, Parts Collection, Points Collection
The Remove method syntax has the following object qualifier and part:
Part Description
Remarks If index does not match any existing member of the collection, an error occurs.
Example This example illustrates the use of the Remove method to remove objects from a Collection
object, in this case, the Layers collection. To try this example, paste the code into the Declara-
tions section of a form containing a CommandButton named Command1 and a Map named
Map1 that has more than one layer and then press F5 and click the button.
Option Explicit
RemoveEvent Method
Applies To TrackingLayer Object
Part Description
index An integer index that indicates which GeoEvent to delete. Index must be a
number from 0 to one less than the value of the EventCount property.
Remarks The first item in the group of GeoEvent objects has index = 0, therefore EventCount is
always one more than the largest index value.
Example This example uses the RemoveEvent method to remove a GeoEvent from the TrackingLayer.
This code removes the GeoEvent whose index is 0, provided there are events left on the
TrackingLayer. To try this example, paste the code into the Declarations section of a form
containing a CommandButton named Command1 and a Map named Map1 that contains at
least one MapLayer and has a TrackingLayer that contains at least one GeoEvent, and then
press F5 and click the button. You may want to add GeoEvents using the code in the AddEvent
method example.
Option Explicit
RemoveRelates Method
Applies To MapLayer Object
Description Drops all relate fields and associated record values from the Recordset of a MapLayer that
were created by an AddRelate method call.
Syntax object.RemoveRelates
Part Description
Renderer Property
Applies To MapLayer Object, GroupRenderer Object
Description Returns or sets a reference to the Renderer of a MapLayer, or the Renderer at the specified
index of a GroupRenderer.
object.Renderer [= renderer]
Part Description
The Renderer method syntax has the following object qualifier and part:
Part Description
Remarks Renderers are creatable objects in MapObjects. In Visual Basic, heres one way to create one
of the kinds of renderers:
Set Map1.Layers(0).Renderer = New MapObjects2.GroupRenderer
Example This example uses the Renderer property to specify what technique to use to draw a
MapLayer. In this case, the code creates a ValueMapRenderer object and associates it with the
MapLayer. Then the code specifies the properties of the Renderer. To try this example, paste
the code into the Declarations section of a form containing a CommandButton named Com-
mand1 and a Map named Map1 that has at least one MapLayer. You may have to modify the
example to change the region field to reflect the name of a field in your GeoDataset. Press
F5 and click the button to redraw the map based on the value of a field.
Option Explicit
ReturnDescription Method
Applies To GeoCoordSys Object, ProjCoordSys Object
Part Description
object An object expression that evaluates to an object in the Applies To list, either
a ProjCoordSys or a GeoCoordSys.
Remarks The ReturnDescription property may be used to return metadata about a ProjCoordSys or
GeoCoordSys object. The ReturnDescription property is similar to the Export method on
the ProjCoordSys and GeoCoordSys objects, but can be used by the developer to access the
projection metadata directly.
Example This example uses the ReturnDescription method of the ProjCoordSys or GeoCoordSys
objects to display projection information. To try this example, paste the code into the Declara-
tions section of a form containing a CommandButton named Command1, and a Map named
Map1, containing one MapLayer which has a coordinate system set. Press F5 and then click
Command1.
Option Explicit
Private Sub Command1_Click()
MsgBox Map1.Layers(0).CoordinateSystem.ReturnDescription, _
vbInformation, MapLayer Projection Information
End Sub
ReturnLineEvent Method
Applies To Line Object
Description Returns an object that represents the Line event that occurs between two specified measures.
Part Description
startMeasure A numeric expression that indicates from which measure the start of the
returned Line should be taken.
endMeasure A numeric expression that indicates from which measure the end of the
returned Line should be taken.
Remarks This method will return a null value where no events are found between the specified mea-
sures. For example, given a Line with measure values between 0 and 50, measured_line,
the following Visual Basic code will determine that line_event has not been set with a new
event.
Dim line_event as MapObjects2.Line
Set line_event = measured_line.ReturnLineEvent(100, 200)
See Also Point Object, Points Collection, Measure Property, Parts Collection
Example This example makes use of the ReturnLineEvent property to return line events occuring on a
user-selected line segment. To try this example, copy the code into the Declarations section of
a Form that contains a Label named Label1, and a Map named Map1 with a MapLayer
containing line features which have line events. Press F5 and click on a line. Right click to
zoom in. The line you selected is drawn in blue, with line events in red. Remember that line
events on the same Line map overlap.
Option Explicit
Dim gLine As New MapObjects2.Line
Dim endM As Double
Dim startM As Double
Dim selLine As MapObjects2.GeoEvent
Get the measure values at the start and end of the line
NB: If the line is a multipart, this is repeated for each
part seperately
Dim itemCount As Integer
Dim partLine As MapObjects2.Points
End If
End Sub
ReturnMeasure Method
Applies To Line Object
Description Returns the measure value of the position on a Line object that occurs closest to a given
Point.
Part Description
Example This example makes use of the ReturnPointEvents property and the ReturnMeasure methods
to draw point events occuring on a user-selected line segment, closest to the point the user
clicked on. To try this example, copy the code into the Declarations section of a Form that
contains a Map named Map1 with a MapLayer containing line features which have point
events and are measured. Press F5 and click on a line.
Option Explicit
ReturnPointEvents Method
Applies To Line Object
Description Returns a Points object containing the set of the point events that occur at the given measure
on a Line object.
Part Description
measure A numeric expression that indicates from which measure the events should
be returned.
Remarks This method will return a null value where no events are found for the specified measure. For
example, given a Line with measure values between 0 and 50, measured_line, the
following Visual Basic code will determine that pt_events has not been set with any new
events.
Dim pt_events as MapObjects2.Points
Set pt_events = measured_line.ReturnLineEvent(100)
Each point in the Points object will have its measure value set to the cumulative distance
along the Line feature to that point from the start of the Line.
Reverse Method
Applies To Points Collection
Syntax object.Reverse
The object placeholder represents an object expression that evaluates to an object in the
Applies To list.
Remarks The Reverse method is useful for altering the direction of splined text.
Example This example uses the Reverse method to change the order of all the members of a collection
of Points, useful for controlling the direction of splined text. To try this example, paste the
code into the Declarations section of a form containing a CheckBox named Check1, a
TextBox named Text1, and a Map named Map1, and then press F5. In the TextBox, specify the
text to display; then track a line to serve as the path for the spline. Toggle Check1 to see the
effect of Reverse.
Option Explicit
Dim moLine As MapObjects2.line
Right Property
Applies To Ellipse Object, Rectangle Object
Description Returns or sets the distance between the internal right edge of an object and the left edge of its
container.
Part Description
Example This example uses the Right property to draw a line that intersects an ellipse at its rightmost
point. To try this example, paste the code into the Declarations section of a form containing a
Map named Map1 and press F5. Drag a circle on the map. The circle draws in red and the line
will draw in blue.
Option Explicit
Dim oEllipse As Ellipse
Dim oPoints As New MapObjects2.Points
Dim oLine As New MapObjects2.line
.Style = moSolidFill
.Color = moRed
.Size = 0
Map1.DrawShape oEllipse, oSymbol draw the ellipse
.SymbolType = moLineSymbol
.Style = moSolidLine
.Color = moBlue
.Size = 2
Map1.DrawShape oLine, oSymbol draw the line
oPoint.x = oEllipse.Right
oPoint.y = oEllipse.Top
oPoints.Add oPoint
Set oPoint = Nothing
oPoint.x = oEllipse.Right
oPoint.y = oEllipse.Bottom
oPoints.Add oPoint
oLine.Parts.Add oPoints
Set oPoint = Nothing
Map1.TrackingLayer.Refresh True
End Sub
RollbackTransaction Method
Applies To Recordset Object
Description Disregards all of the operations that have taken place within the transaction.
Syntax object.RollbackTransaction
Part Description
object An object expression that evaluates to a Recordset object that has an open
transaction.
Remarks The RollbackTransaction method is used at the end of a transaction to discount all edits that
have occurred on the Recordset object since the StartTransaction method was called.
Rotation Property
Applies To TextSymbol Object, Symbol Object
Part Description
Remarks If you provide a RotationField for a LabelRenderer object, the rotation of labels will be
driven by the attribute values. If you do not, then the Rotation property of the TextSymbol
object associated with the LabelRenderer will be used. If you specify SplinedText, any
settings for the Rotation property will be ignored.
Example This example uses the Rotation property to set the rotation angle of some text on a map. To try
this example, paste the code into the Declarations section of a form containing three Label
controls named Label1, Label2, and Label3, a Slider control named Slider1, and a Map named
Map1 that contains at least one MapLayer. Position the Slider so that adequate space for the
labels remains below it. Press F5. Move the Slider to control the angle of rotation.
Option Explicit
Dim oTextSym As New MapObjects2.TextSymbol
If bTextAlreadyDrawn Then
Map1.DrawText MapObjects2, Map1.Extent.Center, oTextSym
End If
bTextAlreadyDrawn = True
End Sub
With oTextSym
.Color = moBlack
.Height = 0 use font size in points, not map units
Set .Font = oFont
End With
With Slider1
.LargeChange = 15
.Max = 360
.TickFrequency = 45
End With
With Label1
.AutoSize = True
.Caption = Slider1.Min default is 0
.Left = Slider1.Left
.Top = Slider1.Top + Slider1.Height
End With
With Label2
.AutoSize = True
.Caption = Slider1.Max
.Left = Slider1.Left + Slider1.Width - Label1.Width
.Top = Label1.Top
End With
With Label3
.AutoSize = True
.Caption = Int((Slider1.Max - Slider1.Min) / 2)
.Top = Label1.Top
.Left = Slider1.Left + (Slider1.Width * 0.5)
End With
End Sub
RotationAngle Property
Applies To Map Object
Description Returns or sets a value that sets the angle at which features are drawn on a Map.
Part Description
Remarks If the RotationAngle property is set to a non-zero angle, you will see the contents of all
MapLayers and ImageLayers rotated. The rotation is measured about the center of the
Maps Extent.
If the map is rotated, the TrackingLayer is also rotated, therefore any shapes which were
drawn on the Map will also be drawn at that rotated angle. However, as a rotated Rectangle
will no longer be rectangular in shape, any rectangles which have been added to the map may
change dimensions. If you wish to preserve the exact dimensions of a rectangle before
rotating a Map, you should first convert that Rectangle to a Polygon.
The RotationAngle property is not supported for ImageLayers for map output. If the
CopyMap, ExportMap, ExportMap2, OutputMap, OutputMap2 or PrintMap methods
are called, any ImageLayers contained within the Map will not be visible.
ImageLayer rotation is not supported for the Windows 95 and 98 platforms. On these
platforms, if a Map control contains an ImageLayer with a non-zero RotationAngle set, the
ImageLayer will not be visible, although other layers will remain visible and rotated.
Example This example uses the RotationAngle property to rotate the map. To try this example, paste the
code into the Declarations section of a form containing two command buttons named Com-
mand1 and Command2, and a Map named Map1 containing at least one map layer, and then
press F5. Click the comand buttons to rotate the map clockwise and anti-clockwise.
Option Explicit
RotationField Property
Applies To LabelRenderer Object, ValueMapRenderer Object
Description Returns or sets the field that contains rotation information for an object
Part Description
Remarks If you provide a RotationField for a LabelRenderer object, the rotation of labels will be
driven by the attribute values. If you do not, then the Rotation property of the TextSymbol
object associated with the LabelRenderer will be used. If you specify SplinedText, any
settings for the Rotation property will be ignored.
Example This example uses the RotationField property to control the angle of rotation of the text
displayed by the LabelRenderer. The RotationField property specifies the name of a field in
the Recordset associated with the MapLayer. The field contains a rotation value in counter-
clockwise degrees for each record. The Field property names the field that will serve as the
source for the text. To try this example, paste the code into the Declarations section of a form
containing a Map named Map1 that contains a MapLayer, two ComboBox controls named
Combo1 and Combo2, two Label controls named Label1 and Label2, and a CommandButton
named Command1. The Form_Load event code will position all the controls except the Map.
Press F5. Select the name of the field that will serve as the rotationField and then select the
name of the field whose values will provide the source of the text for the LabelRenderer. Click
Command1 to display the text.
Option Explicit
Dim oMapRecords As MapObjects2.Recordset
With Combo1
.Left = Label1.Left + (Label1.Width * 1.5)
.Top = Label1.Top
.Text =
.ListIndex = -1
End With
With Combo2
.Left = Combo1.Left
.Top = Label2.Top
.Text =
.ListIndex = -1
End With
With Command1
.Left = Combo1.Left + Combo1.Width * 1.25
.Top = Label1.Top
.Caption = Label
End With
End Sub
ScaleRectangle Method
Applies To Rectangle Object
Part Description
factor A numeric expression that indicates by what factor to scale the object; for
example, 1.5 scales the Rectangle by a factor of one and a half.
Example This example uses the ScaleRectangle method to change the extent of a map. Clicking with the
left mouse button zooms in on the map, whereas clicking with any other mouse button zooms
out. To try this example, paste the code into the Declarations section of a form containing a
Map named Map1 that contains at least one MapLayer. Press F5 and then click on the map.
Option Explicit
ScalingField Property
Applies To ValueMapRenderer Object
Description Returns or sets the Field whose values determine the factor by which to scale the Symbol
associated with the features.
Part Description
Example This example demonstrates the role of the ScalingField property of a ValueMapRenderer. The
example controls the factor by which to scale the symbols associated with the point features of
a MapLayer. To try this example, paste the code into the Declarations section of a form
containing a ListBox named List1 and a Map named Map1 that contains at least one
MapLayer with point features; press F5 and double-click a field name in the list whose values
to use to scale the size of the symbols.
Option Explicit
End Sub
With oRenderer
.SymbolType = moPointSymbol
.Field = FeatureId
.ValueCount = 51
.ScalingField = List1.List(List1.ListIndex)
End With
For l = 0 To oRenderer.ValueCount - 1
oRenderer.Value(l) = l
Next
Map1.Refresh
End Sub
ScrollBars Property
Applies To Map Object
Description Returns or sets a value indicating whether an object can display a horizontal scroll bar and a
vertical scroll bar.
Part Description
value A boolean expression that determines whether the object has scrollbars, as
described in Settings.
Setting Description
True (Default) The Map can have a horizontal and a vertical scroll bar. See
Remarks.
Remarks If ScrollBars is True and the Map controls current Extent is not its FullExtent, a horizontal
scrollbar appears below the bottom of the map and a vertical scrollbar appears to the right of
the maps right border.
If the Map controls current Extent is the same as its FullExtent or contains its FullExtent,
no scroll bars appear, irrespective of the Scrollbars setting.
Scrollbars will not display if the Map control has a WindowMode of WindowlessTransparent
or Windowless Opaque.
Example This example uses the Scrollbars property to toggle whether horizontal and vertical scrollbars
display at the bottom and right edge of a Map when the Extent of the Map is not the same as
its FullExtent. To try this example, paste the code into the Declarations section of a form
containing a CommandButton named Command1 and a Map named Map1 that contains at
least one MapLayer, and then press F5; drag a rectangle to zoom in on the map and then click
Command1.
Option Explicit
Private Sub Command1_Click()
Map1.ScrollBars = Not Map1.ScrollBars
End Sub
SearchExpression Method
Applies To MapLayer Object, Table Object
Part Description
expression A string expression that forms the where clause portion of an SQL state-
ment. Note that MapObjects follows ANSI SQL, not Jet Database Engine
SQL.
Depending on the underlying source of the MapLayer or Table object, the expression may be
case sensitive. If the expression has a length of zero (e.g. the expression string is ),
SearchExpression will return a Recordset containing all of the records in the MapLayer or
Table. If your expression was invalid, the Recordsets EOF property will be True.
SearchExpression does not use database indices stored in separate files to perform the search,
for example dBase indices (*.mdx), or attribute indices from ArcView (*.ain, *.aih). However,
spatial indices are used in MapObjects.
If using particularly large datasets (greater than 100,000 records) for searching, consideration
should be given to storing data in SDE rather than Shapefiles. In SDE, FilterExpression may
be used to perform server-side filtering of records, improving performance.
Use of the ORDERBY keyword is supported for shapefiles, VPF data, CAD files and cover-
ages, but is not supported by SDE, and therefore is not supported for SDE layers in
MapObjects.
As queries are passed into MapObjects as Strings, you may need to control the formatting of
any date arguments in the expression. The following example shows how you can use the
Format function in Visual Basic to format a date argument entered into a TextBox.
Dim strDate As String
strDate = Format(CDate(TextDate.Text), mm/dd/yyyy)
strQuery = Date = & strDate
Dim sel As New MapObjects2.Recordset
Set sel = Map1.Layers(0).SearchExpression(strQuery)
Effectively, the contents of the TextBox are being converted into a Visual Basic Date variable
and then back into a formatted String. The benefit of this is that the date gets parsed and your
program can control its final format.
Example This example uses the SearchExpression Method to select features in a MapLayer with an
SQL statement. To try this example, paste the code into the Declarations section of a form
containing a CommandButton named Command1, a TextBox named Text1, and a Map named
Map1 that has at least one MapLayer whose default color is not Yellow. Press F5, enter a valid
SQL where clause in the TextBox, such as state_name like N% and then click the button to
see the results of your query.
Option Explicit
SearchMethod Constants
MapObjects defines the following constants for use with the SearchShape method of the
MapLayer object.
In the descriptions below, the term search feature is represented in the SearchShape method
syntax by the shape parameter. A multipart searchfeature is treated as a single shape for
seaching.
SearchByDistance Method
Applies To MapLayer Object
Description Creates a Recordset based on a search for all features within a distance of a shape that meet
the criteria in an expression. The expression is an SQL where clause. If you omit the expres-
sion, by passing Nil or , the method returns a Recordset of all features within the specified
distance of the shape.
Part Description
tolerance A numeric expression that evaluates to the distance from the point that the
method uses to determine which features to select.
expression A string expression that forms the where clause portion of an SQL state-
ment. Note that MapObjects follows ANSI SQL, not Jet Database Engine
SQL.
Remarks If you pass a Recordset object as the shape parameter, SearchByDistance will position the
Recordset at the first record and then position the Recordset back at the first record after the
method completes.
For more information, see Visual Basic Helps Comparison of Microsoft Jet Database Engine
SQL and ANSI SQL topic.
Example This example uses the TrackCircle Method and the SearchByDistance Method to select
features in a MapLayer that are partially within an interactively defined distance of a point. To
try this example, paste the code into the Declarations section of a form containing a Map
named Map1 that has at least one MapLayer containing Polygon features whose default color
is not LightYellow. Press F5, then click drag a circle to indicate the selection. Note that the
AfterLayerDraw Event code contains the SearchByDistance method. Also, if you want to
zoom in on the Map, you can use the right mouse to drag a new Extent.
Option Explicit
sym.color = moRed
sym.Style = moLightGrayFill
Map1.DrawShape MyEllipse, sym
End If
End Sub
SearchShape Method
Applies To MapLayer Object
Description Creates a Recordset of all features that meet the both the spatial search criteria specified by
the SearchMethodConstant, and the logical search criteria in an expression. The expression
is an SQL where clause. If you omit the expression, by passing an empty string (), the
method returns a Recordset of all features that meet the spatial search criteria.
Part Description
shape objects, you can specify a Recordset object that represents all or
some of the features of an ESRI shapefile, ARC/INFO coverage, VPF file
or CAD file (you cannot pass a Recordset derived from an SDE layer).
searchMethod A value or constant that indicates the type of spatial search criteria target
features must meet in relation to shape as described in Settings.
expression A string expression that forms the where clause portion of a SQL
statement. Note that MapObjects follows ANSI SQL, not Jet Database
Engine SQL.
Remarks For more information, see Visual Basic Helps Comparison of Microsoft Jet Database Engine
SQL and ANSI SQL.
When performing a search with a multipart Line or Polygon, or a Points object, the parts of
the shape act as a single shape. For example, performing a moContainedBy with a multipart
Polygon, features will only be returned which fully contain all parts of the Polygon.
If you pass a Recordset object as the shape parameter, SearchShape will position the
Recordset at the first record and then position the Recordset back at the first record after the
method completes. You can only pass a Recordset as a shape when searching on a MapLayer
based on a shapefile, coverage, VPF or CAD file.
If you form the query so that it works on a field in a related SDE table, limit the expression to
core SQL grammar for a WHERE clause.
If your MapLayer contains features with Z values, you can use a three-dimensional Rect-
angle as your search shape. Features are selected based on their Z coordinates, in addition to
their X and Y coordinates. Note that moExtentOverlap is the only SearchMethodConstant
that allows three-dimensional searches.
When using SearchShape on a MapLayer derived from an SDE layer, the shape must lie
within the bounds of the MapLayer objects Extent. To ensure your search shape is valid, use
the Intersects method to test if the Extent of the shape may lie outside the Extent of the
MapLayer. If it does, you can use the Intersect method to clip the search shape to the extent
of the MapLayer, before performing the SearchShape method.
Example This example uses the SearchShape method to highlight the features that are adjacent to a
feature on a MapLayer you click. To try this example, paste the code into the Declarations
section of a form containing a Map named Map1 that has a MapLayer with polygon features.
Press F5, then click a feature. Note that the example highlights the original feature in addition
to those features adjacent to it.
Option Explicit
Dim recset1 As MapObjects2.Recordset original polygon
Dim recset2 As MapObjects2.Recordset neighbors
SecondDirection Property
Applies To GeoTransformation Object
Description Returns or sets a value that identifies the direction of the second-stage datum shift on a two-
stage transformation using the GeoTransformation object. The direction value is one of the
GeographicTransformationConstants.
Part Description
Remarks If you are using two different Types on the GeoTransformation, (i.e. you have set both Type
and SecondType) you should set both the Direction and SecondDirection properties appro-
priately.
SecondName Property
Applies To GeoTransformation Object
Description Returns a value that identifies the SecondName of a pre-defined GeoTransformation (i.e. the
name of the second-stage transformation set using the SecondType method)
Part Description
SecondType Property
Applies To GeoTransformation Object
Description Sets or returns a value that identifies the SecondType of the GeoTransformation object.
Part Description
Remarks The SecondType property is used when a geographic transformation is required between two
coordinate systems, neither of which is a WGS 1984 coordinate system. The majority of the
pre-defined Geographic Transformation Constants are either from, or to, this system.
transformation allowing for the different datum that the two coordinate systems are based
upon.
Server Property
Applies To DataConnection Object, Table Object
Description Returns or sets the name of a Server for an SDE DataConnection, or Table.
Part Description
servername A string expression that evaluates to a valid server name for the specified
DataConnection.
Set Method
Applies To Points Object, Parts Object
Description Changes the specified Points collection of a Parts collection to another Points collection or
changes the specified member of a Points collection to another Point.
Part Description
index An integer that represents the position of the member in the Parts collection
or Points collection.
Example This example uses the Set method to change the position of a Point in a collection of Points.
To try this example, paste the code into the Declarations section of a form containing a Map
named Map1, and then press F5. Track a polygon on the Map and then use the right mouse
button to select a vertex to move.
Option Explicit
Dim moPoly As MapObjects2.Polygon
End Sub
fTol = Map1.ToMapDistance(100)
Set oPoints = oPoly.Parts(0)
For i = 0 To oPoints.Count - 1 2
If oPoints(i).DistanceTo(oPoint) < fTol Then
SelectVertex = i
Exit Function
End If
Next
SelectVertex = -1
End Function
If Button = 1 Then
Set moPoly = Map1.TrackPolygon
ElseIf Not moPoly Is Nothing Then
iVertex = SelectVertex(Map1.ToMapPoint(X, Y), moPoly)
If iVertex <> -1 Then
MoveVertex iVertex, moPoly
End If
End If
Map1.TrackingLayer.Refresh True
End Sub
End Sub
SetMeasures Method
Applies To Line Object
Description Calculates a new measure value for every vertex of a Line object.
Part Description
startMeasure A numeric expression that indicates from which measure the start value
should be taken.
endMeasure A numeric expression that indicates from which measure the end value
should be taken.
Remarks This method takes the value startMeasure and applies it to the first vertex of the Line.
Similarly, the endMeasure value is applied to the last vertex of the Line. Each intermediate
vertex is then assigned a measure value by linear interpolation between the startMeasure and
endMeasure values.
SetMeasuresAsLength Method
Applies To Line Object
Description Calculates a measure value for every vertex on a Line object based on the distance of the
vertex from the start of the Line.
Syntax object.SetMeasuresAsLength
Part Description
Remarks The value of the measure on each vertex is calculated using the cumulative distance of the
vertex, along the Line , from the start point of the Line.
SetParameter Method
Applies To ProjCoordSys Object, GeoTransformation Object
The SetParameter method syntax has the following object qualifier and arguments:
Part Description
paramValue A numeric expression specifying the value to be set for the parameter
specified.
ShapeType Constants
MapObjects defines the following type constants to define the different types of shape that are
supported. This constant is for use with MapLayer objects to identify what type of shape is
stored in the layer, or similarly with any unknown shape object to identify what type it is.
Using the read-only ShapeType property on any of these objects returns one of these values:
See Also MapLayer Object, Point Object, Line Object, Polygon Object, Rectangle Object, Ellipse
Object
ShapeType Property
Applies To MapLayer Object, Point Object, Line Object, Polygon Object, Rectangle Object, Ellipse
Object
Description Returns a value that indicates the type of geometric shape associated with a MapLayer or an
individual shape object.
Syntax object.ShapeType
Part Description
Example This example uses the ShapeType property to report on the kind of features stored in each
MapLayer of a Map. To try this example, paste the code into the Declarations section of a
form containing a ListBox named List1, a CommandButton named Command1, and a Map
named Map1 that has at least one MapLayer. Press F5 and click Command1.
Option Explicit
ShowOutline Property
Applies To ChartRenderer Object
Description Determines whether or not the ChartRenderer will outline the slices or bars that form its
charts.
Part Description
boolean A boolean expression specifying whether the slices or bars will have an
outline or not as indicated in Settings.
Setting Description
Size Property
Applies To Symbol Object
Part Description
Example This example uses the Size property to control the size in points of the Symbol representing
features of a MapLayer. To try this example, paste the code into the Declarations section of a
form containing two Label controls named Label1 and Label2, a Slider control named Slider1,
and a Map named Map1 whose topmost MapLayer represents point features. Position the
Slider so that adequate space for the labels remains below it. Press F5. Move the Slider to
control the size of the Symbol.
Option Explicit
End Sub
SizeField Property
Applies To ChartRenderer Object
Description Returns or sets an independent Field used to determine the size of charts (Pie Chart only).
Part Description
Remarks You must set a value for MinPieSize and MaxPieSize to enable the SizeField functionality.
The values in the SizeField are scaled between the minimum and maximum size values.
If you want a constant size for the radius of all pie charts, merely set MinPieSize and
MaxPieSize to the same value or set one of the pie size properties to an arbitrary value and
the other to 0. By default, the ChartRenderer sets the constant size of the radius of all pie
charts to 20 points.
SizeSymbols Method
Applies To ClassBreaksRenderer Object
Description Assigns a size to the Symbol of the first and last categories of a ClassBreaksRenderer object
and interpolates the size for each intervening category.
Part Description
startSize A numeric expression specifying the size of the symbol in points to assign to
the first category, delimited by the value held in the Break(0) property.
endSize A numeric expression specifying the size of the Symbol in points to assign
to the last category, those features whose Field values are greater than
category delimited by Break(BreakCount).
Example This example uses the SizeSymbols method to draw graduated symbols on a Map and it uses
the ShapeType property to specify the kinds of features and consequently the kinds of symbols
to use. The example makes use of data that is specifically named, using the NorthEast sample
data. You will have to change the example to MapLayer and Field names for your data. The
data named Centers represents place points that fall at the center of the data named Coun-
ties. P_OTHER is a numeric field that you should change to the name of a numeric field
appropriate to your data. To try this example, paste the code into the Declarations section of a
form that contains a CommandButton named Command1 and a Map that has two MapLayer
objects as described. Press F5 and click Command1.
Option Explicit
With oClassRend
.SymbolType = moPointSymbol
.Field = P_OTHER
End With
Map1.Refresh
End Sub
SpellingSensitivity Property
Applies To Geocoder Object
Description Returns or sets the value for spelling sensitivity that associates with a Geocoder object.
Part Description
value A numeric expression that represents the value of the spelling sensitivity.
The default SpellingSensitivity value is 70. The value must be in the range
of 0 to 100. (Data type is Single)
Remarks This property controls how much variation in spelling will be allowed when searching for
likely match candidates in the StreetTable, it accepts values between 0 and 100. A low value
will allow Mane, Maine, Main to be treated as match candidates for Main. A higher
value will restrict candidates to exact matches. The default is 70.
The spelling sensitivity does not affect the MatchScore of each candidate. It only controls
how many candidates to be considered. The lower the value, the more likely additional
candidates will be retrieved, and vice versa.
This property only applies to match key fields in SearchQueries which are prefixed with a
question mark.
Spheroid Constants
MapObjects defines over forty constants for use with the Type property of a Spheroid object.
For a complete listing, see the online help.
Spheroid Object
A geographical coordinate system is based upon a spheroidal approximation of the shape of
the earth. To make mathematical calculations easier, the Spheroid used to approximate the
earth is often treated as a true sphere. This assumption can be used for small-scale maps, those
less than 1:5,000,000. At this scale, the difference between a sphere and a Spheroid cannot be
detected on a map.
The earth cannot be accurately represented by a true sphere however, so to maintain accuracy
for larger-scale maps (scales of 1:1,000,000 or larger), the Earth must be treated as a Spher-
oid, which has semimajor and semiminor axes of different lengths.
Properties
See Also Projection Object, GeoCoordsys Object, PrimeMeridian Object, Datum Object, Unit
Object
Spheroid Property
Applies To Datum Object
Description Sets or returns a value that identifies the Spheroid upon which the Datum object is based.
Part Description
Example This example demonstrates how the Spheroid property of the Datum object may be used to
filter MapLayers. To try this example, paste the code into the Declarations section of a new
Form which has a combobox named Combo1 and a checkbox named Check1. Also, there you
should add a Map named Map1, which has at least one MapLayer, each having a coordinate
system set. Then press F5, try selecting and deselecting the Checkbox, and selecting different
spheroids form the combobox.
Option Explicit
Dim theSphere As String
Dim spheres As New MapObjects2.Strings
Dim userSphere As String
Map1.Refresh
End Sub
End Sub
spheres.PopulateWithSpheroids
Combo1.Clear
Dim i As Integer
For i = 1 To spheres.Count
Combo1.AddItem spheres(i - 1)
Next i
Combo1.ListIndex = 0
Check1.Caption = Show only layers having & Combo1.Text _
& spheroid
End Sub
SplinedText Property
Applies To LabelRenderer Object
Description Returns or sets a value indicating whether a LabelRenderer object will spline labels associ-
ated with line features.
Part Description
Setting Description
True (Default) The LabelRenderer object will spline the label associated with
each line feature.
False The LabelRenderer object will draw the label at the center point of the
bounding box of each feature.
If SplinedText is True, the LabelRenderer object uses the shape of the line feature as a guide
for splining the text; however, if the MapLayer feature is a point or polygon, the
LabelRenderer object ignores the value of SplinedText and displays the label at the center
point of the features bounding box.
If SplinedText is True, any settings for the Rotation property will be ignored.
SqueezeFactor Property
Applies To Geocoder Object
Description Returns or sets a value used to identify how much of a road is used for placing
AddressLocations from a successful GenerateCandidates or BatchMatch.
Part Description
value A numeric expression that represents the percentage of street length that a
point is shifted inward from the line segments two end points. (Data type is
Double.)
Remarks SqueezeFactor values may range from 0 to less than 100. The default SqueezeFactor is 0
indicating that AddressLocations are found along the full length of each line segment
representing a road.
Standardizer Object
An Standardizer object allows you to standardize individual address strings or street intersec-
tions.
Before matching an address, the address string must undergo two processes of standardization.
Firstly the address string needs to be broken into a standard set of fields (called match keys),
and secondly those fields need to be converted into appropriate standard values such as N for
North or Nrth. These fields will then be compared to fields in the specified street table in
order to determine the corresponding geographic location.
To create a valid Standardizer, you must specify the appropriate standardization rules using the
StandardizingRules property. MapObjects provides a set of standardization rules, contained
in .stn files. Select the one that is suitable for the type of address you want to standardize.
The .stn file looks for other files with its same base name. Some files also point to other tables
(such as prefix.tbl). So it is important that you know all the files for the set of standardization
rules you are using, and place them all in the same directory as the .stn file you specify in the
StandardizingRules property.
Generally, an address standardization will also require files with .dct, .mat .pat and .cls
extensions.
A Standardizer object normally uses one standardization rule set to parse and standardize an
address. The standardization rule command file can be set to the objects StandardizingRules
property. However, if you want to geocode a street intersection, you must also set the
IntersectionStandardizingRules property. If no intersection is considered, this property can
be left empty.
You can create a Standardizer object and set the rule command files in Visual Basic with
code like this:
To verify that the Standardizer is set up properly, you can test the value of the Valid property.
Use the LastError property to return an error code.
Properties
FieldName LastError
FieldValue StandardizingRules
Methods
StandardizeAddress
Example This example demonstrates the use of the Standardizer object and its properties and methods.
To try this example, paste the code into the Declarations section of a form that contains two
ListBoxes named List1 and List2 respectively. Substitute the path strings, if necessary, to point
to your GeoRules directory. Then press F5 and see the result of standardization.
Option Explicit
If (stan.StandardizeAddress(address1)) Then
stan.FieldValue(ZN) = 53702
List1.AddItem Standardization of an Address String
List1.AddItem
List1.AddItem (Address = & address1)
List1.AddItem
List1.AddItem (Match Key Field Name & vbTab & Field Value)
List1.AddItem
f = stan.FieldCount
For i = 0 To f - 1
name = stan.FieldName(i)
List1.AddItem vbTab & name & vbTab & vbTab & stan.FieldValue(name)
Next i
End If
If (stan.StandardizeAddress(address2)) Then
The ZN field for Zone has to be set every time after an address
is standardized
stan.FieldValue(ZN) = 53702
List2.AddItem Standardization of an Intersection String
List2.AddItem
List2.AddItem (Address = & address2)
List2.AddItem
List2.AddItem (Match Key Field Name & vbTab & Field Value)
List2.AddItem
f = stan.FieldCount
For i = 0 To f - 1
name = stan.FieldName(i)
List2.AddItem vbTab & name & vbTab & vbTab & stan.FieldValue(name)
Next i
End If
End Sub
Standardizer Property
Applies To Geocoder Object
Description Sets the Standardizer property of the Geocoder object to a Standardizer object. This
property is write-only.
Part Description
Remarks When using a Geocoder to perform address matching, you must assign a valid Standardizer
in order for the address matching to be successful.
StartMeasureField Property
Applies To EventRenderer Object
Description Returns or sets the field which specifies at which Measure value, along a line feature, an event
starts.
Part Description
Remarks The StartMeasureField property is used for rendering both Point and Line events. If you
have specified SymbolType to be moPointSymbol, the StartMeasureField is taken as the
Measure value of the event. If you have specified SymbolType to be moLineSymbol, the
StartMeasureField is taken as the measure at which the line event begins.
StartTransaction Method
Applies To Recordset Object
Syntax object.StartTransaction
Part Description
Remarks If you only require read access to an SDE layer, you do not need to open a transaction.
Statistics Object
A Statistics object represents the result of a calculation on a numeric Field of a Recordset
using the Recordset objects CalculateStatistics method. Once youve created a Statistics
object, you can return the following statistical properties: Max (maximum), Min (minimum),
Mean , StdDev (standard deviation), and Sum. In addition, the Count property returns the
number of records in the Recordset.
Properties
StdDev Property
Applies To Statistics Object
Description Returns a value that indicates the standard deviation calculated by a Statistics object.
Part Description
value A double data type specifying the maximum value calculated by the Statis-
tics object.
Remarks To create a Statistics object whose statistical properties you can return, use the Recordset
objects CalculateStatistics method, for example:
Set stats = Map1.Layers(0).Records.CalculateStatistics(tot_vote)
See Also CalculateStatistics Method, Statistics properties
StopEditing Method
Applies To Recordset Object
Syntax object.StopEditing
Part Description
Remarks If an application has a GeoDataset open for writing, other applications may not be able to get
its associated Recordset for spatial and logical queries. The Recordset may become avail-
able, once the writing application re-opens the underlying table as read-only again by invoking
the StopEditing method on the Recordset.
StreetSide Constants
MapObjects defines the following StreetSide constants for the AddressLocation objects
StreetSide property.
StreetSide Property
Applies To AddressLocation Object
Description Returns a value that indicates on which side of the street MapObjects found a match for an
AddressLocation object.
Part Description
variable An numeric expression that will hold the street side constant (data type
integer).
Remarks The StreetSide property should only be used when the Geocoder has been set up to match
individual street sides. For example, the us_addr match rules set specifies match variables
FromLeft, FromRight, ToLeft and ToRight. Only if these MatchVariables are linked with
appropriate fields in the StreetTable should the StreetSide property be used.
StreetTable Property
Applies To Geocoder Object
Description Sets the StreetTable property of the Geocoder object to a GeoDataset that contains a street
network. This property is write-only.
Part Description
Remarks The StreetTable property references a GeoDataset containing information about street
features. The GeoDataset must represent a shapefile, as geocoding with MapObjects requires
the addition of a geocoding index file, which can only be created on a shapefile or coverage.
A StreetTable GeoDataset may be a shapefile containing Line features, where each record
represents a street. The GeoDataset will have a Shape Field containing the Line features, and
also address attributes such as ZIP code, City, and Street Name held in other fields.
Each type of GeoDataset feature (line, polygon, and point) has a typical format for addresses.
1. Linear features
Urban StreetTables typically have four house number fields ranging from low to high for each
side of a street segment. The range indicates the possible numbers that could fall within a
particular block, and the numbers are divided into even numbers on one side of the street and
odd numbers on the other.
In addition to these fields, you may also wish to use information such as postal zip codes and
city names to differentiate street addresses in different zones. A zone is usually specified by
the left zones zip code and the right zones zip code for a street segment. Street name infor-
mation may also be split over more than one field. A StreetTable with clearly defined fields
will be more successful for geocoding against.
For example, the feature attribute fields in the GeoDataset of the Redlands sample shapefile
are:
L_F_ADD 29700 House numbers go from this value on the left-hand-side of the
road
R_F_ADD 29701 House numbers go from this value on the right-hand-side of the
road
PREFIX North Road name prefix such as North in North Greenspot Road
SUFFIX North Road suffix which lies after road type, such as North in
Greenspot Rd North
2. Polygon features
Land parcels represented by polygon features can be identified by, for example, postal zip or
zip+4 codes. The formats for these address types are:
For example, the feature attribute fields in the GeoDataset of the Redlands sample shapefile
are:
3. Point features
Point features may also have descriptive addresses or identifiers, for example well ID,
building name or light pole number. The address of a point feature usually contains one
component:
Strings Collection
Strings is a standard collection that includes a set of unique string data types. The objects
Add method returns False if the string is a duplicate of an existing member of the collection.
You can use the Unique property to control whether a string that is a candidate to be added to
a Strings collection must be unique before it can be added. You can remove all members of
the collection with the Clear method. You can return the index of a string in the collection
with Find. The default property of a Strings collection is Item.
You can create Strings collections in Visual Basic with code like this:
Dim s as New MapObjects2.Strings
Properties
Count Unique
Methods
Add PopulateWithMeridians
Clear PopulateWithParameters
Item PopulateWithProjectedCoordSys
PopulateWithDatums PopulateWithProjections
PopulateWithGeographicCoordSys PopulateWithSpheroids
PopulateWithGeoTransformations PopulateWithUnits
Style Property
Applies To Symbol Object
Part Description
Settings The settings for value when the object is a marker symbol (SymbolTypeConstant is
moPointSymbol) are MarkerStyleConstants.
The settings for value when the object is a line symbol (SymbolTypeConstant is
moLineSymbol) are LineStyleConstants.
The settings for value when the object is a fill symbol (SymbolTypeConstant is
moFillSymbol) are FillStyleConstants.
Example This example uses the Style property to control the FillStyle of the Symbol used to render
polygon features of a MapLayer. To try this example, paste the code into the Declarations
section of a form that contains a control array of 4 OptionButton controls, named Option1
(add one option control, make sure its highlighted, press CTRL+C, press CRTL+V, click yes,
repeat as required). Also, add to the form a Map control named Map1 that contains a
MapLayer with polygon features. For the OptionButton, set its Index property to 0 in the
Control Properties dialog box to create a control array of one element, and then press F5.
Click each OptionButton to see each different style.
Option Explicit
Sum Property
Applies To Statistics Object
Description Returns a value that indicates the sum calculated by a Statistics object.
Syntax object.Sum
Part Description
value A double data type specifying the maximum value calculated by the Statis-
tics object.
Remarks To create a Statistics object whose statistical properties you can return, use the Recordset
objects CalculateStatistics method, for example:
Set stats = Map1.Layers(0).Records.CalculateStatistics(tot_vote)
See Also CalculateStatistics Method, Statistics properties
SupportsTransactions Property
Applies To Recordset Object
Description Returns a value that indicates whether a Recordset object supports transactions.
Syntax object.SupportsTransactions
Part Description
Value Description
Remarks Only SDE layers support transactions from MapObjects, therefore this property will identify
the Recordset as belonging to an SDE layer.
Example This example demonstrates how you might connect to SDE and check if a particular dataset
supports transactions. To try this example, paste the code into the Declarations section of a
new Form which has five textboxes named Text1 to Text5, with five corresponding Labels
named Label1 to Label5. Also, add a CommandButton named Command1 and a CheckBox
named Check1. Then press F5, enter appropriate values in the TextBoxes to connect to your
SDE instance, and click Command1.
Option Explicit
dc.Server = Text1.Text
dc.User = Text2.Text
dc.Password = Text3.Text
dc.Database = Text4.Text
lyr.GeoDataset = dc.FindGeoDataset(Text5.Text)
Set dc = Nothing
Set lyr = Nothing
Set recs = Nothing
End Sub
Symbol Object
A Symbol object consists of attributes that control how a features or graphic shape is dis-
played. Depending on the kind of feature or shape youre working with, you can specify the
particular SymbolType and Style of the Symbol; for example, if the feature is a Line, you can
set the characteristics of the line to be solid or a dashed or dotted pattern. You can set the Size
property of a Symbol object in points. Similarly you can set use the Color property to set the
color of the Symbol using a variety of techniques.
When setting the properties of a new Symbol, you should set the SymbolType property first.
When you change the SymbolType, the Symbol is reset, and all the other Symbol properties
will become the default for the specified SymbolType.
If a symbol references a Font, you can set the CharacterIndex of the Font youre using to
specify a particular character. When you use the Symbol object in association with a Point
feature Symbol , you can set the angle to rotate the Symbol with the Rotation property. Using
the OutlineColor property, you can set the color of the outline of a Symbol associated with
Polygon objects.
A Symbol object is a creatable object. You can create a Symbol object in Visual Basic with
code like this:
Dim s As New MapObjects2.Symbol
To specify your own custom Symbol object use the Custom property.
Properties
Custom Rotation
Symbol Property
Applies To ClassBreaksRenderer Object, MapLayer Object, ValueMapRenderer Object,
LabelRenderer Object, TrackingLayer Object, EventRenderer Object, LabelPlacer
Object, ZRenderer Object
Part Description
Remarks Use the Symbol property to get the symbol associated with an object. You can set or return a
Symbols Color, Font (where applicable), Size, or Style.
When you apply the Symbol property to a LabelRenderer object, you return a reference to a
TextSymbol object.
When you apply the Symbol property to a TrackingLayer object, you can associate a Symbol
with one or more GeoEvent objects.
The first item in the group of symbols has index = 0, and SymbolCount is always one more
than the largest index value.
Example This example uses the Symbol property to return the Symbol associated with a MapLayer and
then report the value of the Symbol objects Color property. To try this example, paste the
code into the Declarations section of a form that has a CommandButton named Command1
and a Map named Map1 that has at least one MapLayer; then press F5. Click Command1 to
return the value of the Color property.
Option Explicit
End Sub
SymbolCount Property
Applies To TrackingLayer Object, LabelRenderer Object
Description Returns or sets the number of Symbol objects associated with an object.
Part Description
value A numeric expression that evaluates to an integer that is always one more
than the largest index value of the Symbol property.
Example This example demonstrates the use of the SymbolCount property in the context of the
TrackingLayer. You can disassociate the Symbol objects associated with the GeoEvent objects
on the TrackingLayer by setting the SymbolCount property to 0. To try this example, paste the
code into the Declarations section of a form containing two CommandButton controls named
Command1 and Command2 and a Map named Map1 that contains at least one MapLayer, and
then press F5 and click the map. Note that if you click the map with the left mouse button, the
GeoEvent draws with a red symbol and if you click the map with the right mouse button, the
GeoEvent draws with a green symbol. Once youve added some GeoEvent objects, click the
Hide button to set SymbolCount to 0 and then click Show to re-establish the Symbol defini-
tions and reset the SymbolCount property.
Option Explicit
Command2.Caption = Show
End Sub
Map1.TrackingLayer.SymbolCount = 2
the following properties will display when you click the left
button
With Map1.TrackingLayer.Symbol(0)
.Color = moRed
.Style = moTrueTypeMarker
.Font = oFont
.Size = 18
.CharacterIndex = 139
End With
the following properties will display when you click the right
button
With Map1.TrackingLayer.Symbol(1)
.Color = moDarkGreen
.Style = moTrueTypeMarker
.Font = oFont
.Size = 18
.CharacterIndex = 140
End With
End Sub
SymbolHeight Property
Applies To LabelPlacer Object
Description Returns or sets the symbol height which the LabelPlacer will take into account when perform-
ing placement.
Part Description
value An integer in points that represents the space reserved for the features
symbol in the horizontal direction.
Remarks Commonly used when the LabelPlacer renders point features, the SymbolHeight value
represents a diameter, that is, a value of 72 indicates a distance of 36 points (one-half inch)
above and below the feature. The LabelPlacer will position the label for the feature so that it
does not conflict with the specified SymbolHeight.
If it has been set, SymbolHeight will be used before other settings to determine where a label
may be placed.
SymbolField Property
Applies To LabelRenderer Object, EventRenderer Object
Description Returns or sets the field that contains Symbol index information for a LabelRenderer object.
Part Description
Remarks Using the values stored in the SymbolField, you can specify a variety of TextSymbols to use
to draw labels with a single LabelRenderer object.
Example This example uses the SymbolField property to set the symbol used to render the text dis-
played by the LabelRenderer. The SymbolField property specifies the name of a field in the
Recordset associated with the MapLayer. The field contains a value for each record that
provides an index into the symbols established for the LabelRenderer. This example assumes
that the SymbolField contains values 0, 1, and 2. The Field property names the field that will
serve as the source for the text. To try this example, paste the code into the Declarations
section of a form containing a Map named Map1 that contains a MapLayer, two ComboBox
controls named Combo1 and Combo2, two Label controls named Label1 and Label2, and a
CommandButton named Command1. The Form_Load event code will position all the controls
except the Map. Press F5. Select the name of the field that will serve as the SymbolField and
then select the name of the field whose values will provide the source of the text for the
LabelRenderer. Click Command1 to display the text.
Option Explicit
Dim moRecset As MapObjects2.Recordset
With oFnt0
.Name = Arial
.Size = 9
.Italic = True
End With
With oFnt1
.Name = Courier New
.Size = 8
End With
With oFnt2
.Name = Arial
.Bold = True
.Size = 10
End With
With oLayer
.SymbolField = Combo1.List(Combo1.ListIndex)
.Field = Combo2.List(Combo2.ListIndex)
.SymbolCount = 3
Set .Symbol(0).Font = oFnt0
.Symbol(0).Color = moLimeGreen
Set .Symbol(1).Font = oFnt1
.Symbol(1).Color = moRed
Set .Symbol(2).Font = oFnt2
End With
Map1.Layers(0).Renderer = oLayer
Map1.Refresh
End If
End Sub
End Sub
SymbolIndex Property
Applies To GeoEvent Object
Description Returns or sets the index of the Symbol on the TrackingLayer associated with the GeoEvent.
Part Description
index A numeric expression that specifies the index of an item in the group of
symbols associated with the TrackingLayer.
Remarks The first item in the group of symbols has index = 0, and the TrackingLayer objects
SymbolCount property is always one more than the largest index value. When the
TrackingLayer is created, its SymbolCount is 1, you can immediately start adding events
with a SymbolIndex of 0.
Example This example uses the SymbolIndex property to set the symbol of the most recently added
GeoEvent on a Map, and also gives the option of adding a tag to that GeoEvent. To try this
example, paste the code into the Declarations section of a form containing a CommandButton
named Command1, a TextBox named Text1, and a Map named Map1 that contains at least one
MapLayer and then press F5. Add one or more GeoEvent objects to the Maps TrackingLayer
by clicking on the Map and then click Command1. The text from the TextBox is added as the
Tag to the last GeoEvent if you choose Yes in hte second message box.
Option Explicit
With Map1.TrackingLayer
If .EventCount > 0 Then
iMsg = Change most recently added GeoEvents symbolIndex from
tMsg = Add a tag to GeoEvent
End If
End With
End Sub
oFont.Name = Wingdings
oFont.Bold = False
Map1.TrackingLayer.SymbolCount = 2
the following properties will display when you click the left
button
With Map1.TrackingLayer.Symbol(0)
.Color = moRed
.Style = moTrueTypeMarker
.Font = oFont
.Size = 18
.CharacterIndex = 139
End With
the following properties will display when you click the right
button
With Map1.TrackingLayer.Symbol(1)
.Color = moDarkGreen
.Style = moTrueTypeMarker
.Font = oFont
.Size = 18
.CharacterIndex = 140
End With
End Sub
SymbolType Constants
MapObjects defines the following type constants for use with Symbol objects. The
SymbolType property returns these values.
SymbolType Property
Applies To ClassBreaksRenderer Object, Symbol Object, ValueMapRenderer Object, ZRenderer
Object
Description Returns or sets a value that indicates the type of Symbol associated with an object.
Part Description
Example This example uses the SymbolType Property and Constants to determine the type of features
in each MapLayer of a Map. Note that the LayerType constant is used to determine whether
the layer is a MapLayer rather than an ImageLayer. To try this example, paste the code into the
Declarations section of a form containing a CommandButton named Command1 and a Map
named Map1 that has at least one MapLayer. Press F5, then click Command1.
Option Explicit
SymbolWidth Property
Applies To LabelPlacer Object
Description Returns or sets the symbol width which the LabelPlacer will take into account when perform-
ing placement.
Part Description
value An integer in points that represents the space reserved for the features
symbol in the horizontal direction.
Remarks Commonly used when the LabelPlacer renders point features, the SymbolWidth value
represents a diameter, that is, a value of 72 indicates a distance of 36 points (one-half inch) to
the left and to the right of the feature. The LabelPlacer will position the label for the feature
so that it does not conflict with the specified SymbolWidth.
If it has been set, SymbolHeight will be used before other settings to determine where a label
may be placed.
Example This example uses the SymbolHeight and SymbolWidth properties of the LabelPlacer to
control where to position relation to the symbols of point features. To try this example, paste
the code into the Declarations section of a form that contains a Map control named Map1,
three CommandButtons named Command1, Command2 and Command3, and two TextBoxes
named Text1, Text2 and Text3.. The example assumes the topmost MapLayer is based on the
USA capitals shapefile and the bottommost MapLayer is based on the the USA states shapefile
in the sample data. Press F5 and enter a value for the offset in the TextBox. Click the Set
SymbolHeight button.
Option Explicit
Set Map1.Extent = r
LabelPlacer.Field = CITY_NAME
default symbol
LabelPlacer.DefaultSymbol.Height = Map1.FullExtent.Height / 200
Set LabelPlacer.DefaultSymbol.Font = fnt
LabelPlacer.AllowDuplicates = False
End Sub
If Button = 1 Then
Map1.Extent = Map1.TrackRectangle
Else
Map1.Pan
End If
End Sub
Table Object
A Table object is a read-only data access object. A Table object represents a collection of
related data values that are organized into rows and columns. This object corresponds with a
table in a relational database.
The Table object can access tables from a number of sources: Microsoft Jet databases,
Indexed Sequential Access Method (ISAM) databases, INFO, SDE and ODBC. MapObjects
uses Data Access Objects (DAO 3.5) to access both Jet and ISAM databases. Formats of
ISAM databases include dBase, Microsoft FoxPro, and Paradox. In addition, DAO drivers
also allow access to text file databases and Microsoft Excel or Lotus 1-2-3 worksheets. Note
that even if the data source of the Table object is file-based, for example a dBase file, the file
suffix should not be included in the Name property.
The records in a Table can be accessed through the Recordset object returned by the Records
property. The SearchExpression method applied to a Table object will return a Recordset of
those records meeting the expressions criteria.
The Table object can be used in the AddRelate method for MapLayer objects, the
EventTable property of an EventRenderer object, the PlaceNameTable property of a
PlaceLocator object, and as input to the BatchMatch method of a Geocoder object.
If you are writing your application in Visual Basic, you should distinguish the MapObjects
Table object from a Visual Basic Table object by fully qualifying the class name in declara-
tions; for example:
Dim MyTable as New MapObjects2.Table
Properties
Name Records
Methods
SearchExpression
See Also MapLayer Object, AddRelate Method, EventTable Property, PlaceNameTable Property,
StreetTable Property
TableDesc Object
A TableDesc is an object that represents a description of the Fields collection of a Recordset.
You can use this object when you create a new Recordset object. For each Field of the
Recordset, you can return or set properties where appropriate, i.e. within the limits of the
GeoDataset from which the Recordset is derived. These properties are the FieldLength, the
FieldName, the FieldPrecision, the FieldScale, and the FieldType.
You can set the number of fields that you want to define by specifying the FieldCount
property. Once youve defined the Fields that will be associated with the Recordset, you can
add a GeoDataset to a DataConnection object, invoking the DataConnection objects
AddGeoDataset method, using the newly created TableDesc object as a parameter.
For international applications you can set the code page for a TableDesc object with the
CodePage property.
You can create TableDesc objects in Visual Basic with code like this:
Dim desc as New MapObjects2.TableDesc
Properties
TableDesc properties
TableDesc Property
Applies To Recordset Object
Description Returns a TableDesc object that describes the field characteristics of a Recordset. The
property is read-only.
Syntax object.TableDesc
Part Description
Example This example uses the TableDesc property to return the TableDesc object of a Recordset in
order to return some information about the Recordset. To try this example, paste the code into
the Declarations section of a form containing a ListView control named ListView1 and a Map
named Map1 that has a MapLayer. Press F5.
Option Explicit
Set td = Map1.Layers(0).Records.TableDesc
For i = 0 To td.FieldCount - 1
Set itm = ListView1.ListItems.Add(, , td.FieldName(i))
Select Case td.FieldType(i)
Case 0
ftype = None
Case 3
ftype = Long
Case 5
ftype = Double
Case 7
ftype = Date
Case 8
ftype = String
End Select
itm.SubItems(1) = ftype
Next i
End Sub
Tag Property
Applies To Map Object, MapLayer Object, ImageLayer Object, ClassBreaksRenderer Object,
DotDensityRenderer Object, LabelRenderer Object, ValueMapRenderer Object,
GeoEvent Object, ZRenderer Object, EventRenderer Object
Description Returns or sets any extra data needed for your program. Unlike other properties, the value of
the Tag property is not used by Visual Basic; you can use this property to identify objects.
Part Description
expression A string expression identifying the object. The default is a zero-length string
().
You can use this property to assign an identification string to an object without affecting any of
its other property settings or causing side effects. The Tag property is useful when you need to
check the identity of a control that is passed as a variable to a procedure.
Example This example uses the Tag property in combination with a ValueMapRenderer to provide a
way to toggle between two different Renderers for the same MapLayer depending on the scale
of the Map. When the map displays the layer at state-level scale, it uses one
ValueMapRenderer; when the map displays the MapLayer at county-scale, it uses a second
ValueMapRenderer. To try this example, paste the code into the Declarations section of a form
containing a CommandButton named Command1 and a Map named Map1 that contains at
least one MapLayer that has similar data to the example. Press F5. Click-drag a rectangle to
zoom in to the map. Click Command1 to zoom to the full extent of the Map.
Option Explicit
Dim oCountyRenderer As New MapObjects2.ValueMapRenderer
Dim oStateRenderer As New MapObjects2.ValueMapRenderer
End If
Map1.Extent = Map1.FullExtent
MsgBox Switched to state-level renderer, vbExclamation
End Sub
Sub Form_Load()
With oStateRenderer
.Tag = State
.Field = State_Name
End With
With oCountyRenderer
.Tag = County
.Field = Cnty_Name
End With
oMapRecords.MoveFirst
oCountyRenderer.ValueCount = oNames(1).Count
oStateRenderer.ValueCount = oNames(0).Count
End Sub
TextSymbol Object
A TextSymbol object consists of attributes that control how text is rendered. The Symbol
property of a LabelRenderer object returns a TextSymbol. You can set the font associated
with the TextSymbol using the Font property and its color with the Color property. To
position a TextSymbol relative to a label point, set its HorizontalAlignment and
VerticalAlignment properties.
You can set the angle of rotation of a TextSymbol with the Rotation property. To set the
height of a TextSymbol in map units you can specify a value for the Height property. If the
value of Height is 0.0, then the size of the TextSymbol is the equivalent value in points of the
Size of the TextSymbol objects Font. To adjust the gap between text characters so that the
text will fit between two points, either by stretching it or shrinking it, use the Fitted property.
You can create TextSymbol objects in Visual Basic with code like this:
Dim s as New MapObjects2.TextSymbol
Properties
Methods
TextSymbol methods
ToGeoCoordSys Property
Applies To GeoTransformation Object
Part Description
ToMapDistance Method
Applies To Map Object
The ToMapDistance method syntax has the following object qualifier and argument:
Part Description
Remarks If you have changed the Scale units of your Map container: The ToMapDistance method
is dependant upon the ScaleMode of the Map controls container. However, the internal
control units of a Map control are Twips, and therefore the ToMapDistance converts units
from Twips to Map units. In Visual Basic, if the Map controls container has a different
ScaleMode, use the ScaleX and ScaleY methods to convert X and Y coordinates before using
the ToMapDistance method.
If using a ScaleMode of Pixels: Note that whereas most scale units are constant (e.g. Centi-
meters, Inches) giving identical ScaleX and ScaleY values, a ScaleMode of Pixels may have
different ScaleX and ScaleY values, as pixels are not perfectly square. Therefore, when
converting a distance by the ScaleX or ScaleY method, ensure that the method you choose is
appropriate.
Example This example uses the ToMapDistance method to convert control units to map units in order to
perform a radius search. To try this example, paste the code into the Declarations section of a
form containing a TextBox named Text1 and a Map named Map1 that contains at least one
MapLayer, and then press F5 and enter a value in the TextBox and click the Map to highlight
features that fall partially within the selection circle.
Option Explicit
Dim recset As MapObjects2.Recordset
Dim el As New MapObjects2.Ellipse
dist = Map1.ToMapDistance(Text1.Text)
If the form has units which are not Twips, then we should first
convert the X and Y coordinates to twips before passing them to the
ToMapPoint method
If Form1.ScaleMode <> vbTwips Then
X = Form1.ScaleX(X, vbTwips, Form1.ScaleMode)
Y = Form1.ScaleX(Y, vbTwips, Form1.ScaleMode)
dist = Form1.ScaleX(dist, vbTwips, Form1.ScaleMode)
End If
Set pt = Map1.ToMapPoint(X, Y)
sym.SymbolType = moFillSymbol
sym.Style = moLightGrayFill
sym.Color = moRed
Map1.DrawShape el, sym
End If
End Sub
ToMapPoint Method
Applies To Map Object
The ToMapPoint method syntax has the following object qualifier and arguments:
Part Description
Remarks If you have changed the Scale units of your Map container: The ToMapPoint method is
dependant upon the ScaleMode of the Map controls container. However, the internal control
units of a Map control are Twips, and therefore the ToMapPoint converts units from Twips to
Map units. In Visual Basic, if the Map controls container has a different ScaleMode, use the
ScaleX and ScaleY methods to convert X and Y coordinates before using the ToMapPoint
method.
Example This example uses the ToMapPoint method to display the coordinates in map units of a
position on a map. ToMapPoint returns a Point object whose X and Y properties are in map
units. The example displays either the coordinates of a point clicked on the map in map units
or the points coordinates in control units. To try this example, paste the code into the Declara-
tions section of a form containing a Map named Map1 that contains at least one MapLayer,
and then press F5 and click the mouse on the map without holding the SHIFT key down.To
display control units, hold the SHIFT key down and click the map.
Option Explicit
If the form has units which are not Twips, then we should first
convert the X and Y coordinates to twips before passing them to
the ToMapPoint method
If Form1.ScaleMode <> vbTwips Then
X = Form1.ScaleX(X, vbTwips, Form1.ScaleMode)
Y = Form1.ScaleX(Y, vbTwips, Form1.ScaleMode)
End If
Top Property
Applies To Ellipse Object, Rectangle Object
Description Returns or sets the distance between the internal top edge of an object and the top edge of its
container.
Part Description
Example This example uses the Top property to control the position of a MapControl and other controls
on the form at initialization and when you resize the form. To try this example, paste the code
into the Declarations section of a form containing a Map named Map1 that contains at least
one MapLayer, a Label named Label1, and a ComboBox named Combo1. Position the Label
and the ComboBox beneath the bottom edge of the Map. Press F5. This example provides a
simple feature location mechanism. When you click on the ComboBox the map zooms to the
feature. You may want to change the code so that it references a character field other than
Name in Form_Initialize and Combo1_Click.
Option Explicit
Dim oMapRecords As MapObjects2.Recordset
oMapRecords.MoveNext
Loop
Form_Resize
Set oMapRecords = Nothing
End Sub
With Map1
.Extent = oMapRecords(Shape).Value.Extent
.Refresh
.FlashShape oMapRecords(Shape).Value, 3
End With
Set oMapRecords = Nothing
End Sub
TrackCircle Method
Applies To Map Object
Part Description
Remarks The user should press and hold the mouse button in the center of the required Ellipse, then
drag the mousepointer to produce an Ellipse of the required size, and then release the mouse
button. Note that the TrackCircle method only rubber-bands an Ellipse when the
mousepointer is moved horizontally over the Map. Moving the mousepointer in the vertical
direction does not affect the size of the Ellipse.
The TrackCircle method returns an Ellipse that is a circle. If you wish to rubber-band a shape
which is an Ellipse with different axes, you can use the TrackRectangle method to rubber-
band a Rectangle. The create a new Ellipse object, and set its Left, Right, Top and Bottom
properties equal to those properties of the Rectangle.
TrackingLayer Object
A TrackingLayer object represents a layer in a Map that depicts geographically referenced
phenomena whose position may change. These phenomena are referred to as events, and are
represented by GeoEvent objects.
To add GeoEvent objects to a Map objects TrackingLayer use the AddEvent property; to
remove an individual event, use the RemoveEvent method. To remove all events on the
TrackingLayer, use the Clear method. You can return the number of GeoEvent objects that
are on the TrackingLayer with the EventCount property and you can reference each
GeoEvent with the Event property.
Each event has a Symbol. Any number of events may be drawn with the same Symbol object.
You can control whether the entire TrackingLayer is visible or hidden independently of the
rest of the map by setting the objects Visible property. When you create a TrackingLayer, its
SymbolCount is 1, before adding more Symbol objects to the Symbol property array, change
the SymbolCount property.
Properties
EventCount
Methods
ClearEvents
TrackingLayer Property
Applies To Map Object
Syntax object.TrackingLayer
The object placeholder represents an object expression that evaluates to a Map control.
Remarks You can use the TrackingLayer to display and manipulate GeoEvents, geographically
referenced phenomena whose position may change.
Example This example uses the TrackingLayer property to return the TrackingLayer object and report
some information about it. To try this example, paste the code into the Declarations section of
a form containing a Label named Label1 and a Map named Map1 that contains at least one
MapLayer, and then press F5. Click on the map to add GeoEvents to the Tracking Layer.
Option Explicit
Set pt = Map1.ToMapPoint(X, Y)
Map1.TrackingLayer.AddEvent pt, 0
iEvents = Map1.TrackingLayer.EventCount
If iEvents = 1 Then
Label1.Caption = iEvents & GeoEvent on the Map
Else
TrackLine Method
Applies To Map Object
Description Rubber-bands a multi-point line on the Map and returns a Line object.
Part Description
Remarks The user should click to start the Line, and continue to click to add vertices to that Line, and
then double-click to end the Line.
Example This example uses the TrackLine method to draw a line on a map. To try this example, paste
the code into the Declarations section of a form containing a Map named Map1 that contains
at least one MapLayer, and then press F5 and click-drag a line on the map.
Option Explicit
Dim ln As MapObjects2.Line
TrackPolygon Method
Applies To Map Object
Part Description
Remarks The user should click to start the Polygon, and continue to click to add vertices to that
Polygon, and then double-click to end the Polygon.
Note that a Polygon has identical start and end vertices. However, you do not need to click
back at your start vertex when using the TrackPolygon method, as MapObjects will add the
final vertex when the Polygon is ended.
Example This example uses the TrackPolygon method to draw a polygon on a map. To try this example,
paste the code into the Declarations section of a form containing a Map named Map1 that
contains at least one MapLayer, and then press F5 and click-drag a polygon on the map.
Option Explicit
sym.OutlineColor = moRed
Map1.DrawShape poly, sym
End If
End Sub
TrackRectangle Method
Applies To Map Object
Part Description
Remarks The user should press and hold the mouse button to start the Rectangle, then drag the
mousepointer to the opposite corner of the shape as required, and then release the mouse
button to end the Rectangle.
Transform Method
Applies To GeoCoordSys Object, ProjCoordSys Object
Description Transforms a shape object from one coordinate system to the coordinate system of the
GeoCoordSys or ProjCoordSys object upon which the method is defined.
The Transform method syntax has the following object qualifier and arguments:
Part Description
newShape A variable that has been declared as an shape object. Supported object
types are Point, Line, Polygon, Rectangle objects and Points collections.
object An object expression that evaluates to an object in the Applies To list. This
defines the coordinate system that the shape should be transformed to.
fromCoordSys An object expression that evaluates to an object in the Applies To list. This
specifies the coordinate system that fromShape is currently projected in.
fromShape An object expression that evaluates to a shape object of type Point, Line,
Polygon, Rectangle or a Points collection. This must be the same object
type as newShape.
densifyTol Optional. When the shape is transformed, it may be necessary to add new
vertices to define the new objects shape. Use this argument to restrict the
density of the vertices that are created. This value is of type Double. If not
specified, then no new vertices will be added.
geoTrans Optional. If the object and fromCoordSys parameter have different datum,
then this argument should be set to a GeoTransformation object that maps
between the two coordinate systems. This will cause the coordinates of
newShape to be changed to the Datum of object during the transformation.
If not specified, the coordinates of newShape will remain in the Datum of
fromCoordSys. NB. If a geoTrans object is used, the Z values on all points
for the newShape will be modified appropriately.
Example This example shows the use of the Transform method on the ProjCoordSys object, to trans-
form a particular shape from the coordinate system of the MapLayer to another coordinate
system. To try this example, paste the code into the Declarations section of a new Form
containing a Map named Map1, one Label named Label1, and one Command Button named
Command1. Edit the code appropriately to add a sample MapLayer, and ensure a sutiable
coordinate system is set on it. Press F5, and click on a shape on Map to highlight it. The press
the CommandButton to see that shape transformed to the selected coordinate system.
Option Explicit
Variables holding the selected feature
Dim theShape As Object
Dim transShape As Object
Dim recs As New MapObjects2.Recordset
Map1.Refresh
End If
End Sub
If recs.Count = 1 Then
Set theShape = recs.Fields(Shape).Value
Set transShape = Nothing
Map1.Refresh
End If
Transparent Property
Applies To ImageLayer Object
Description Returns or sets a value indicating whether the ImageLayer will be displayed with a transpar-
ent color.
Part Description
Setting Description
False (Default) The ImageLayer will be displayed with each color visible.
Remarks When setting the Transparent property to True, you should set the TransparentColor
property to an appropriate value.
The Transparent property is not supported for map output, and must be set to False if the
CopyMap, ExportMap, ExportMap2, OutputMap, OutputMap2 or PrintMap methods
are used.
Example This example uses the Transparent and TransparentColor properties to control areas of an
ImageLayer which are displayed as transparent. To try this example paste the code into the
Declarations section of a form containing a CheckBox named Check1, a label named Label1,
and a Map named Map1 containing one ImageLayer. The map control should be set to
windowless opaque. Now the map control is owned by the form window and this allows the
forms point method to retrieve a colour from the map control. Press F5 and click-drag a
rectangle to zoom in. Use the left mouse button to select which color should be set to transpar-
ent. Toggle the check box to determine whether this transparent property is used when the map
is displayed on screen.
Option Explicit
If Button = 1 Then
xf = x + Map1.Left
yf = y + Map1.Top
cv = Point(xf, yf)
extract the red, green and blue values
r = cv Mod &H100
g = (cv / &H100) Mod &H100
b = (cv / &H10000) Mod &H100
Label1 = Str$(cv) & : & CStr(r) & , & CStr(g) & , & _
CStr(b)
Map1.Layers(0).TransparentColor = cv
Map1.Refresh
End If
End Sub
TransparentColor Property
Applies To ImageLayer Object
Description Returns or sets a color value that will be transparent when an ImageLayer is displayed, if the
Transparent property is set to True.
Part Description
color A value or constant that determines the color of pixels which are to be
displayed as transparent. The default TransparentColor is White.
Settings For more information on color settings, see the Color settings topic in the online help.
Remarks The TransparentColor property may be used when an image has an outline or a background
that you do not want to display. For example, in a series of satellite photographs, each image
may have outlines that overlap onto the next image. By setting the background color to
transparent, you can display these images together on a Map.
After changing the TransparentColor, you should Refresh the Map to see your changes.
Type Property
Applies To Field Object, Datum Object, GeoCoordSys Object
Returns or sets a value that indicates the type of the object. The Type property is used with
Field objects to indicate the operational type or data type of the field.
The Type property is also used with objects that relate to map projections and coordinate
systems, and allows these objects to be specified using a standard definition. A type setting is
made by reference to a constant appropriate for the object. The constants use the POSC
(Petrochemical Open Software Corporation) integer codes.
Part Description
value A numeric expression that specifies the type of the object, as described in
Settings.
Settings The settings for value should be selected from the appropriate list of constants for the object
whose type is being set. These are:
Example This example uses the Type Property to determine the field type of each member of the Fields
collection of a Recordset associated with a MapLayer. Note the use of the FieldType Con-
stants. To try this example, paste the code into the Declarations section of a form containing
two OptionButtons named Option1 and Option2, a ListBox named List1, and a Map named
Map1 that has at least one MapLayer. Press F5, then choose either of the two OptionButtons to
list the corresponding field types.
Option Explicit
End Sub
List1.Clear
End Sub
List1.Clear
End Sub
Union Method
Applies To Point Object, Points Collection, Line Object, Polygon Object, Rectangle Object, Ellipse
Object
Description Returns a shape that represents the geometric Union of two Shape objects of the same
dimension.
Part Description
resultShape An object expression that evaluates to a Shape object. (See Remarks). Will
contain the resulting Shape after the Union.
object An object expression that evaluates to an object in the Applies To list. This
is the first of the two Shape objects whose Union is to be calculated.
unionShape An object expression that evaluates to an object in the Applies To list. This
is second of the two Shape objects whose Union is to be calculated, and
should be of the same dimension as object (See Remarks).
Remarks If the two Shapes do not have a valid Union, the resultShape will be Nothing.
Only certain combinations of shape are valid, and the return result will be a different object
type depending on the nature of the objects processed. The following table summarizes the
valid combinations and possible return results.
Polygon Polygon
Ellipse
Polygon Polygon
Ellipse
Polygon Polygon
Ellipse
Where the resultShape could be more than one object type (e.g. Rectangle or Polygon), then
use an interim Object and then test the result using its ShapeType property to see what type of
object it is.
You cannot use the Union method with a self-intersecting Polygon. If you do, an exception is
raised in Visual Basic, specifying Error 5000, Valid Object expected as argument. You can
however use a self-intersecting Line.
See Also Buffer Method, Difference Method, Intersect Method, XOr Method
Example This example uses the Union method to allow the user to union rectangles, ellipses and
polygons. The user point and the new shape generated by the Union operation are added to the
tracking layer as GeoEvents. To try this example, paste the code into the Declarations section
of a form containing a Map named Map1 that has at least one MapLayer, and 3 OptionButtons
named Option1, Option 2, and Option3. Press F5, and choose an option, then click on the
map.
Option Explicit
Dim shape1 As Object
Dim shape2 As Object
Dim union As Boolean
If Button = 2 Then
Dim r As New MapObjects2.Rectangle
Set r = Map1.TrackRectangle
Map1.Extent = r
Exit Sub
End If
Rectangle union
If Option1.Value Then
Dim rect As New MapObjects2.Rectangle
Dim eventRect As New MapObjects2.GeoEvent
Ellipse union
ElseIf Option2.Value Then
Dim elli As New MapObjects2.Ellipse
Dim theExt As New MapObjects2.Rectangle
Dim eventElli As New MapObjects2.GeoEvent
Polygon union
ElseIf Option3.Value Then
Dim poly As New MapObjects2.Polygon
Dim eventPoly As New MapObjects2.GeoEvent
Set poly = Map1.TrackPolygon
Set eventPoly = Map1.TrackingLayer.AddEvent(poly, 0)
Call doUnion(poly)
End If
End Sub
Map1.TrackingLayer.SymbolCount = 2
With Map1.TrackingLayer.Symbol(0)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moRed
.OutlineColor = moRed
End With
With Map1.TrackingLayer.Symbol(1)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moBlue
.OutlineColor = moBlue
End With
End Sub
Unique Property
Applies To Strings Collection
Description Returns or sets a value that ensures that the strings in a Strings collection are unique.
Part Description
Setting Description
Remarks Strings is case-sensitive, it considers Maine and MAINE distinct, unique strings, conse-
quently, an attempt to add both strings would be successful, whereas if you attempted to add
Massachusetts twice, on your first attempt, the Add method would return True, however, on
your second attempt, the method would return False and only the first string would be added
to the collection.
To add multiple instances of the same string to a Strings collection, set Unique to False.
Example This example uses the Unique property to control whether a string that is a candidate to be
added to a Strings collection must be unique before it can be added. The Strings collection and
the Unique property are commonly used in association with Renderers, especially the
ValueMapRenderer; however in this example the Strings collection merely populates the
ListBox for illustration purposes only. To try this example, paste the code into the Declarations
section of a Form that contains a TextBox named Text1, a ListBox named List1, a CheckBox
named Check1, and a Map named Map1. Press F5 and enter some text in the TextBox. Press
Enter to signal the end of the text. Add additional text strings. Try to add one of the same text
strings again. Click on the CheckBox to remove the check mark, and now try add the same text
again.
Option Explicit
strs.Unique = Check1.Value
sChar = Chr(KeyAscii)
If Asc(sChar) = 13 Then
strs.Add Text1.Text
List1.Clear
For Each vStr In strs
List1.AddItem vStr
Next
Text1.Text =
End If
End Sub
Unit Constants
MapObjects defines the following constants for use with the Type property of a Unit object.
Unit Object
A Unit object is used to define the units of measurement used in a GeoCoordSys or
ProjCoordSys coordinate system object. The Unit object can be defined by reference to a
pre-defined UnitConstant using the Type property, or alternatively by setting the Factor
property to specify the conversion factor between meters and a user-defined unit.
Properties
See Also Unit Constants, Projection Object, GeoCoordsys Object, PrimeMeridian Object, Spheroid
Object, Datum Object
Unit Property
Applies To GeoCoordSys Object, ProjCoordSys Object
Description Sets or returns a value that identifies the Unit upon which a coordinate system is based.
Part Description
Example This example reads the Unit property of a MapLayer which has a coordinate system
previsouly defined. To try this example, paste the code into the Declarations section of a form
containing a Map which contains a MapLayer with a previously set coordinate system
(ProjCoordSys or GeoCoordSys), and a Label named Label1. Now press F5.
Option Explicit
Else
Label1.Caption = Units of MapLayer: & .Unit.name
End If
End With
End Sub
Updatable Property
Applies To Recordset Object
Description Returns a value that indicates whether changes can be made to a Recordset object.
Syntax object.Updatable
Part Description
Value Description
Remarks If the Updatable property returns True this indicates that MapObjects is currently able to gain
exclusive write access to the data source underlying the Recordset. MapObjects will not
perform edits on a shapefile that has been opened for editing by another application. Alterna-
tively, a value of True indicates that the Recordset represents an SDE layer that the applica-
tion may edit.
If the return value is False then either the data source underlying the Recordset is read-only;
of a type that MapObjects cannot edit, e.g. an ARC/INFO coverage or an attribute table data
source; or that the data source is currently being edited by another application.
See Also Edit Method, Update Method, Delete Method, EditMode Property
Update Method
Applies To Recordset Object
Description Saves the current record and any changes you have made to it.
Syntax object.Update
Part Description
Remarks If you do not use Edit first, an error occurs when you use Update or attempt to change a
fields value.
See Also Edit Method, Update Method, Delete Method, EditMode Property
UpdateMeasures Method
Applies To Line Object
Description Calculates a measure value for every vertex on a Line object that has a null value, either by
interpolation or extrapolation.
Syntax object.UpdateMeasures
Part Description
Remarks The measure of a vertex with a null value that has vertices on both sides with non-null values
will be set using linear interpolation. Where a vertex has more than one non-null measure
value on one side, and no non-null measure values on the other side, its measure will be set
using linear extrapolation. If a Line object has only one non-null measure value, all vertices
will receive this value. For a Line object with no non-null measures, all vertices will be set to
zero.
UpdateWhileDrawing Property
Applies To ImageLayer Object
Description Returns or sets a value indicating whether the Map updates while the application draws the
ImageLayer.
Part Description
boolean A boolean expression specifying whether the Map updates while the
application draws the ImageLayer, as described in Settings.
Setting Description
True (Default) The Map will update while the application draws the
ImageLayer.
False The Map will not update while the application draws the ImageLayer.
Example This example uses the UpdateWhileDrawing property to control whether the Map will update
while the application draws an ImageLayer. To try this example paste the code into the
Declarations section of a form containing a CheckBox named Check1 and a Map named
Map1, whose bottom layer is an ImageLayer. Press F5 and click-drag a rectangle to zoom in.
Use the right mouse button to zoom to the full extent of the map. Toggle the check box to
determine whether to update the Map while drawing the ImageLayer.
Option Explicit
Private Sub Check1_Click()
With Map1
If .Layers(.Layers.Count - 1).LayerType = moMapLayer Then
MsgBox Bottom layer must be an ImageLayer, vbCritical, _
UpdateWhileDrawing Example
End
End If
If Check1.Value = 1 Then
.Layers(.Layers.Count - 1).UpdateWhileDrawing = True
ElseIf Check1.Value = 0 Then
.Layers(.Layers.Count - 1).UpdateWhileDrawing = False
End If
.Refresh
End With
End Sub
UseDefault Property
Applies To EventRenderer Object, LabelPlacer Object, ValueMapRenderer Object
Description Returns or sets a value that indicates whether or not a renderer should use the DefaultSymbol
to draw the field values that are not listed explicitly.
Part Description
value A boolean expression that determines whether the Renderer should use the
DefaultSymbol to draw the field values that are not listed explicitly, as
described in Settings.
Setting Description
True The renderer will use the symbol specified in the DefaultSymbol property.
False The renderer will not use the symbol specified in the DefaultSymbol
property.
User Property
Applies To DataConnection Object, Table Object
Description Returns or sets the name of a User for an SDE DataConnection or an ODBC Table.
Part Description
username A string expression that evaluates to a valid user name for the specified
object.
Valid Property
Applies To ImageLayer Object, MapLayer Object, Geocoder Object, Standardizer Object
Part Description
Value Description
Example This example uses the Valid property to determine whether an ImageLayer or a MapLayer can
be added to a Map. To try this example, paste the code into the Declarations section of a form
that contains a CommandButton named Command1 and a Map named Map1 that has at least
one MapLayer or ImageLayer; press F5 and then click Command1.
Option Explicit
Else
MsgBox No layers available, vbExclamation, MapObjects2
End If
End Sub
Value Property
Applies To Field Object, ValueMapRenderer Object, EventRenderer Object, LabelPlacer Object
Description Returns or sets the value of an object, or sets a value at the specified index in the Value
collection.
object.Value [= value]
The Value property syntax for a Field object has these parts:
Part Description
Part Description
value A string expression that evaluates to the required value for the renderer.
Remarks You can access individual field values for records in a Recordset at the current record
position using the Value property of a Field object. For example, the following code returns a
Variant containing the value of the ID field for the current record.
Dim varValue As Variant
varValue = myRecordSet.Fields(ID).Value
The Variant data type stores whole numbers as Long values, which have an upper limit of
2,147,483,647 and a lower limit of 2,147,483,648. Some supported data sources can store
whole numbers that are beyond these limits. If MapObjects encounters a value in a Field of
FieldType moLong that cannot be held as a Long value it will raise an error. This can be
trapped for and appropriate action taken. One solution is to return the value as a String, using
the ValueAsString function, and convert it to a floating-point data type. In Visual Basic this
can be done using the CDbl function, as follows.
Dim dblVal As Double
dblVal = CDbl(lyr.Records.Fields(ID).ValueAsString)
Setting a Value in the value array of an EventRenderer, LabelPlacer or ValueMapRenderer
indicates which Symbol is used by the Renderer to draw each feature. For example, the code
below would assign a blue symbol to those features with Smith in the Name Field, and a red
symbol to those with Jones.
With myEvRend
.Field = Name
.ValueCount = 2
.Value(0) = Smith Value 0 is drawn with Symbol 0
.Symbol(0).Color = moRed
.Value(1) = Jones
.Symbol(1).Color = moBlue
End With
See Also Type Property
Example This example uses the Value property to return the value of a specified field for each record of
a MapLayers recordset. To try this example, paste the code into the Declarations section of a
form containing a ComboBox named Combo1, a ListBox named List1, and a Map named
Map1 that contains at least one MapLayer. Press F5 and choose the name of a Field in the
ComboBox.
Option Explicit
ValueAsString Property
Applies To Field Object
Part Description
value A variable declared to be of string data type that contains a string represen-
tation of the value contained in the Field.
Example This example uses the ValueAsString property to populate a column of Field values, regardless
of their type, when you click a feature to identify it. To try this example, paste the code into
the Declarations section of a form containing a Map named Map1 that has at least one
MapLayer and a listview control named listview1. Press F5, then click a feature to identify it.
Option Explicit
With ListView1
.View = lvwReport
.ListItems.Clear
oItem.SubItems(1) = oField.ValueAsString
Next
End With
End If
End Sub
ValueCalculation Property
Applies To ZRenderer Object
Description All shapes other than a Point object have multiple vertices and so may have multiple values
for Z in any given shape. The ValueCalculation property allows either the Maximum,
Minimum or Mean Z value for a shape to be used for rendering
Part Description
Example This example show the use of the ValueCalculation property of a Z Renderer. To try this
example, paste the code into the Decalarations section of a form Containing a Map named
Map1, a CommandButton named Command1 and 3 OptionButtons named Option1, Option2
and Option3. The Map should have one maplayer, consisting of polygons which have Z
values. Press F5 and click the command button. Try choosing the different options to render
using different value calaulations. Try changing the fBreakVal numbers to suit the Z values in
your dataset.
Option Explicit
Dim oZRend As New MapObjects2.ZRenderer
End Sub
ValueCount Property
Applies To ValueMapRenderer Object, EventRenderer Object, LabelPlacer Object
Description Returns or sets the number of values of its Field property that a renderer will assign a Symbol.
Part Description
value An integer from 0 to the number of values of its Field property that will be
symbolized by the renderer.
Example This example uses the ValueCount property to create a map that displays all features that have
the same attribute value in the same color. To try this example, paste the code into the Declara-
tions section of a form containing a ListBox named List1, and a Map named Map1 that
contains at least one MapLayer, and then press F5 and click a field name in the list whose
unique values to display.
Option Explicit
sFldname = List1.List(List1.ListIndex)
iterate through the records and accumulate values
Do While Not moRecs.EOF
strs.Add moRecs(sFldname).ValueAsString
moRecs.MoveNext
Loop
ValueField Property
Applies To LabelPlacer Object
Description Returns or sets the Field in the Recordset of the rendered MapLayer that contains values
which will be matched against entries in the value array.
Part Description
Remarks The ValueField property should be set to a name of a Field in the MapLayers Recordset.
The named Field should contain a range of values value indicating which TextSymbol from
the Symbol array is used to draw the labels. In the example code, the sample dataset contains
a field named CFCC containing road classification data. By setting the ValueField property
to CFCC, and providing a Value and Symbol, features with the value A31 are labeled with
larger text.
By setting the ValueCount property you can determine how many values of its ValueField
property the LabelPlacer will provide a Symbol for, i.e. the size of the Symbol array.
ValueMapRenderer Object
A ValueMapRenderer is an object that represents a way of symbolizing features of a
MapLayer by drawing a Symbol for each unique data value. You can specify the type of
Symbol to associate with the ValueMapRenderer, depending on what kinds of features are
associated with the MapLayer, by setting the SymbolType property. By setting its
ValueCount property you can determine how many values of its Field property the
ValueMapRenderer will provide a symbol for. In addition, you can set the UseDefault
property to indicate whether or not the ValueMapRenderer should use the DefaultSymbol to
draw the field values that are not listed explicitly.
If you are using the ValueMapRenderer with a MapLayer that contains Point features, you
can specify the name of a field as the RotationField, whose values you can use to set the
number of counter-clockwise degrees to rotate the Symbol associated with the feature and you
can specify the name of a field as the ScalingField, whose values you can use to set a factor
by which to scale the Symbol associated with the feature.
A ValueMapRenderer may have up to 32,767 different Values in the value array. You may
set the Field property to equal any field in the MapLayer which contains numeric or string
values. Boolean data type is not supported in a ValueMapRenderer.
Developers familiar with ARC/INFO label feature classes will recognize that these two latter
properties map well onto two pseudo items associated with labels, $ANGLE and $SCALE. If
you base the MapLayer youre working with on an ARC/INFO point coverage, you can set a
property and refer to the coverages pseudo items using the name of the pseudo item without
the preceding dollar sign ($), for example $SCALE should be referenced as SCALE.
Properties
VerticalAlignment Property
Applies To TextSymbol Object
Description Returns or sets a value that determines the vertical alignment of text for a TextSymbol object.
Part Description
Note that only the Top, Bottom, Center and Baseline AlignmentConstants are valid for
VerticalAlignment.
Visible Property
Applies To ImageLayer Object, MapLayer Object, TrackingLayer Object
Part Description
Setting Description
Example This example uses the Visible property to toggle whether a MapLayer displays when you
refresh a Map. To try this example, paste the code into the Declarations section of a form
containing a CommandButton named Command1 and a Map named Map1 that contains at
least one MapLayer. Press F5 and click the button to toggle whether the first MapLayer is
visible.
Option Explicit
If Map1.Layers(0).Visible Then
Command1.Caption = Hide
Else
Command1.Caption = Show
End If
Map1.Refresh
End Sub
VisibleRegion Property
Applies To Map Object
Description Allows the shape of a Map control to be changed to that of a specific shape object. The
resultant effect is that only the areas of the MapLayers or ImageLayers contained in the
Map controls Layer collection which fall within the shape specified will be drawn.
Part Description
shape An object of type Polygon, Rectangle or Ellipse. This defines the visible
region of the map.
Remarks When a VisibleRegion is set, the Map extent itself remains rectangular. Areas of the Map
control outside the VisibleRegion become transparent, and reveal the objects below them, for
example the container form, or other controls.
The shape should be defined in the same units as the Maps container object. For example,
when setting the VisibleRegion of a Map placed on a Form with a ScaleMode of centimeters,
the shape should be defined in centimeters. Care should be taken to ensure the shape is
defined in the correct coordinate system. Multipart shapes are not supported for the
VisibleRegion property.
This property is write-only. If setting a Maps VisibleRegion, ensure that ScrollBars are
disabled.
The VisibleRegion property is not supported for map output, when the CopyMap,
ExportMap, ExportMap2, OutputMap, OutputMap2 or PrintMap methods are used, the
full area of the Map canvas will be output.
See Also Polygon Object, Rectangle Object, Ellipse Object, Extent Property
Example This example uses the VisibleRegion change the shape of the map visible to the user. To try
this example, paste the code into the Declarations section of a form containing a Map named
Map1 containing at least one map layer, and then press F5. Click on the map to track a
polygon. When you finish the polygon by double-clicking, the map should only be visible
inside the polygon you just drew.
Option Explicit
newPoly.Parts.Add tempParts
Set Map1.VisibleRegion = newPoly
End Sub
Width Property
Applies To Ellipse Object, Rectangle Object
Syntax object.Width
Part Description
Return Values The property returns a numeric expression specifying the dimension of an object. Measure-
ments are from the center of the objects border so that objects with different border widths
align correctly. Width is in the scale units of the objects container, that is, map units.
Example This example uses the Width property to control whether or not a MapLayer displays. Before
the layers of the map are drawn, the visibility of the first layer is established based on the
current zoom level. If the current map Extent is less than half the FullExtent, the first layer
becomes visible. Zooming in causes more map content to be displayed. To try this example,
paste the code into the Declarations section of a form containing a Map named Map1 that
contains at least two MapLayers. Layers(0) should contain more detail than Layers(1).Press
F5. You can drag a box on the Map to zoom in.
Option Explicit
If oRect.Height = 0 Then
MsgBox Drag a box to zoom in, vbInformation
Else
Map1.Extent = oRect
End If
End Sub
WindowMode Constants
MapObjects defines the following type constants for use with the WindowMode property of
Map objects.
moTransparent 2 Only the foreground of the Map is drawn, i.e. the features
in the Maps Layers collection. Like Opaque mode,
Windowed controls will be drawn on top of it, irrespective
of their relative Z order. Z order is respected between
other windowless controls. Unlike Opaque mode, controls
positioned behind the Map will be visible through parts of
the Map which have no features.
WindowMode Property
Applies To Map Object
Description Returns or sets the way that a Map control is rendered on its container form.
Syntax object.WindowMode
Remarks Windowless controls are not supported by Visual C++ or Visual Basic for Applications.
ScrollBars are not supported in either of the Windowless modes (Opaque or Transparent).
DragFiles and DropFiles events are not supported for Windowless Map controls. Mouse
cursors used for Windowless controls should be Windows standard cursors.
The WindowMode of a Map control may only be changed during design time.
A refresh of a Windowless Transparent Map control will only redraw features in the
MapLayer, therefore panning and zooming in may result in artifacts remaining in areas of the
Map which have not been re-drawn. If your application does not refresh the entire Map area,
a solid filled rectangle may be placed on the form behind the Map control. This will force the
entire area to be re-drawn. Panning on a Windowless Transparent Map control will change the
background of the Map control to the current BackColor.
X, Y Properties
Applies To Point Object
Description Return or set the coordinates of an object. The horizontal coordinate is the X property and the
vertical coordinate is the Y property. In the case of a GeoEvent, the properties are read-only.
object.Y [= value]
Part Description
Example This example uses the X and Y properties to report the location of a moving GeoEvent object
on a Tracking Layer. To try this example, paste the code into the Declarations section of a
form containing a Timer named Timer1, a Label named Label1, a CheckBox named Check1,
and a Map named Map1 that contains at least one MapLayer. Press F5. The code positions the
GeoEvent at the center of the Map initially. Click on the check box to toggle the GeoEvent
motion on and off.
Option Explicit
With Map1.TrackingLayer.Event(0)
Label1.Caption = .x & , & .y report the coordinates
End With
End Sub
XOffsetField Property
Applies To LabelRenderer Object
Description Returns or sets the Field that contains horizontal offset distance information for a
LabelRenderer object.
Part Description
Remarks The property is especially useful when rendering ARC/INFO annotation features.
XOr Method
Applies To Point Object, Points Collection, Line Object, Polygon Object, Rectangle Object, Ellipse
Object
Description Returns a shape that represents the symmetrical difference (eXclusive OR) of two shape
objects of the same dimension i.e. the resulting shape will be equivalent to the Difference of
the Union and the Intersection of the two shapes.
Part Description
resultShape An object expression that evaluates to a shape object. (See Remarks). Will
contain the resultant shape that represents the symmetrical difference.
object An object expression that evaluates to an object in the Applies To list. This
is the first of the two shape objects whose symmetrical difference is to be
calculated.
xorShape An object expression that evaluates to an object in the Applies To list. This
is second of the two shape objects whose symmetrical difference is to be
calculated, and should be of the same dimension as object (See Remarks).
Remarks If the two Shapes do not have a valid Xor, the resultShape will be Nothing.
Only certain combinations of shape are valid, and the return result will be a different object
type depending on the nature of the objects processed. The following table summarizes the
valid combinations and possible return results.
Polygon Polygon
Ellipse
Polygon Polygon
Ellipse
Polygon Polygon
Ellipse
Where the resultShape could be more than one object type (e.g. Rectangle or Polygon), then
use an interim object and then test the result using its ShapeType property to see what type of
object it is, as in the Visual Basic code fragment below:
Dim resultShape as Object
resultShape = myPolygon.Intersect(secondPolygon,myLayer.Extent)
MsgBox Result of Intersect is a & resultShape .ShapeType
You cannot use the XOr method with a self-intersecting Polygon. If you do, an exception is
raised in Visual Basic, specifying Error 5000, Valid Object expected as argument. You can
however use a self-intersecting Line.
Example This example uses the ExclusiveOr method to allow the user to perform Exclusive Or opera-
tions lines. The line and the new shape generated by the Intersect operation are added to the
tracking layer as GeoEvents. Note, an intersection of two lines may be a point, many points, or
a line. Care must be taken to add events to the tracking layer using the appropriate symbol for
the resultant shape type. To try this example, paste the code into the Declarations section of a
form containing a Map named Map1 that has at least one MapLayer, press F5, and then click
on the map to track two lines.
Option Explicit
Dim shape1 As Object
Dim shape2 As Object
Dim exclOr As Boolean
If Button = 2 Then
Dim r As New MapObjects2.Rectangle
Set r = Map1.TrackRectangle
Map1.Extent = r
Exit Sub
End If
Line difference
Dim poly As New MapObjects2.Polygon
Dim eventLine As New MapObjects2.GeoEvent
Set poly = Map1.TrackPolygon
Set eventLine = Map1.TrackingLayer.AddEvent(poly, 0)
Call doXor(poly)
End Sub
exclOr = False
Map1.TrackingLayer.SymbolCount = 2
With Map1.TrackingLayer.Symbol(0)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moCyan
.OutlineColor = moCyan
End With
With Map1.TrackingLayer.Symbol(1)
.SymbolType = moFillSymbol
.Style = moGrayFill
.Color = moMagenta
.OutlineColor = moMagenta
End With
End Sub
YOffsetField Property
Applies To LabelRenderer Object
Description Returns or sets the Field that contains vertical offset distance information for a
LabelRenderer object.
Part Description
Remarks The property is especially useful when rendering ARC/INFO annotation features.
Z Property
Applies To Point Object
Part Description
Example This example demonstrates how a Z values may be assigned to point objects, by allowing the
user to specify a Z value for a selected vertex in a polygon. To try this example, paste the code
into the Declarations section of a form containing a Map named Map1, two TextBoxes named
Text1 and Text2, and two corresponding labels named Label1 and Label2. Press F5. Track a
polygon on the Map using the left mouse button. Click on a vertex with the right mouse button
to assign the Z value currently in the text box.
Option Explicit
Dim moPoly As MapObjects2.Polygon
Polygon) As Integer
Find the vertex of the polygon closest to the user selected point
Dim fTol As Double
Dim oPoints As MapObjects2.Points
Dim i As Integer
fTol = Map1.ToMapDistance(Text1.Text)
Set oPoints = oPoly.Parts(0)
For i = 0 To oPoints.Count - 1 2
If oPoints(i).DistanceTo(oPoint) < fTol Then
SelectVertex = i
Exit Function
End If
Next
SelectVertex = -1
End Function
Create a polygon
If Button = 1 Then
Set moPoly = Map1.TrackPolygon
End If
End If
End If
End If
Map1.TrackingLayer.Refresh True
End Sub
End Sub
Map1.Extent = oRect
Label1.Caption = Tolerance
Label2.Caption = Z Value
Text1.Text = 100
Text2.Text = 5
End Sub
ZRenderer Object
A ZRenderer is an object that represents a way of symbolizing the Z values of features in a
MapLayer. It does this by drawing different symbols for each category of Z values. You can
set the number of breaks between categories with the BreakCount property. There is always
one more category than the number of breaks, so if you set BreakCount to be 2, there will be
three categories. The Z values of a feature are used to calculate the category it falls into. The
method of calculation can be set using the ValueCalculation property. This property takes
one of three ZValueCalcConstants.
The ZRenderer assigns a symbol to a category using the indexed Symbol property. You can
assign a specific Symbol to each category. You can specify the type of Symbol to associate
with the ClassBreaksRenderer, depending on what kinds of features are associated with the
MapLayer, by setting the SymbolType property. If you want, you can use the RampColors
method to assign a start color to the first class and an end color to the last class. The
ClassBreaksRenderer will interpolate colors for intervening classes.
A ZRenderer is a creatable object in MapObjects. In Visual Basic, heres one way to create a
ZRenderer:
Set Map1.Layers(0).Renderer = New MapObjects2.ZRenderer
See Also Field Object, Recordset Object, Symbol Object, ClassBreaksRenderer Object
Properties
Methods
RampColors
ZValueCalc Constants
MapObjects defines the following type constants for use with ZRenderer objects. The read-
write ValueCalculation property returns or sets this value.