ProgrammersReference.pdf

June 15, 2018 | Author: Bráulio Lima | Category: Esri, Copyright, Technology, Computing, Software
Report this link


Description

MapObjectsProgrammer's Reference cover.p65 1 6/24/99, 10:27 AM Copyright © 1996, 1999 Environmental Systems Research, Institute, Inc. All Rights Reserved. Printed in the United States of America. 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. The information contained in this document is subject to change without notice. U.S. GOVERNMENT RESTRICTED/LIMITED RIGHTS 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. ProgrammersReference.pmd 1 10/28/2004, 10:00 AM Introduction This book is an alphabetic reference that contains a list of the objects, methods, properties and events associated with the MapObjects® Custom Control. Each entry includes a description, a syntactical summary, remarks, references to other entries, and in some cases, example code, written in Microsoft® Visual Basic®. 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. Document Conventions and Programming Style The MapObjects Programmer’s Reference uses typographic conventions in it’s descriptions, and a programming style in it’s examples, similar to those used in the Visual Basic documenta- tion. Consult the Microsoft Visual Basic Programmer’s Guide or the Microsoft Visual Basic Language Reference for a listing of these conventions and programming guidelines. ProgrammersReference.pmd 2 10/28/2004, 10:00 AM Contents 3 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 ProgrammersReference.pmd 3 10/28/2004, 2:48 PM 4 MapObjects Programmer’s Reference 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 ProgrammersReference.pmd 4 10/28/2004, 2:42 PM Contents 5 ConnectError Property 114 Connection Property 115 ConnectionError Constants 116 CoordinateSystem Property 127 CopyMap Method 128 Count Property 129 Custom Property 130 Database Property 131 DataConnection Object 131 Datum Constants 132 Datum Object 133 Datum Property 133 DblClick Event 135 DefaultSymbol Property 135 Delete Method 137 DeleteGeoDataset Method 138 DensificationTolerance Property 140 Depth Property 141 Difference Method 142 Direction Constants 145 Direction Property 146 Disconnect Method 150 DistanceTo Method 150 DistanceToSegment Method 152 DotColor Property 154 DotDensityRenderer Object 156 DotSize Property 156 DotValue Property 157 DragDrop Event 159 DragFiles Event 159 DragOver Event 162 DragState Constants 163 ProgrammersReference.pmd 5 10/28/2004, 2:42 PM 6 MapObjects Programmer’s Reference DrawBackground Property 163 DrawError Event 166 DrawingCanceled Event 167 DrawShape Method 167 DrawText Method 169 DropFiles Event 170 Edit Method 171 EditMode Constants 172 EditMode Property 172 Ellipse Object 173 Enabled Property 173 EnableGIF Method 174 EnableTIFFLZW Method 175 EndMeasureField Property 175 EnhancedGeocodingError Constants 176 EOF Property 178 EraseIndices Method 179 Event Property 179 EventCount Property 181 EventRenderer Object 182 EventRouteIDField Property 185 EventTable Property 186 Export Method 186 ExportMap Constants 189 ExportMap Method 190 ExportMap2 Method 191 ExtendedError Property 192 ExtendedErrorString Property 193 Extent Property 193 Factor Property 194 FeatureRouteIDField Property 196 Field Object 197 ProgrammersReference.pmd 6 10/28/2004, 2:42 PM Contents 7 Field Property 197 FieldCount Property 199 FieldLength Property 200 FieldName Property 201 FieldPrecision Property 202 Fields Collection 202 Fields Property 203 FieldScale Property 203 FieldType Constants 204 FieldType Property 205 FieldValue Property 207 File Property 208 FillStyle Constants 209 FilterExpression Property 210 FilterFields Property 214 FilterOperator Property 214 FilterOrder Constants 217 FilterOrder Property 217 FilterShape Property 218 Find Method 219 FindAllPlaceNames Method 220 FindApproximateMatches Method 225 FindArcInfoCoordinateSystem Method 225 FindCoordinateSystem Method 227 FindEvent Method 228 FindGeoDataset Method 229 Fitted Property 230 FittedField Property 232 FlashShape Method 235 Flattening Property 235 Flip Property 236 Floor Property 238 ProgrammersReference.pmd 7 10/28/2004, 2:42 PM 8 MapObjects Programmer’s Reference Font Property 239 FromGeoCoordSys Property 240 FromMapDistance Method 241 FromMapPoint Method 242 FullExtent Property 243 FullRedrawOnPan Property 244 GenerateCandidates Method 246 Geocoder Object 246 GeocodeSuccess Constants 252 GeoCoordSys Object 252 GeoCoordSys Property 253 GeoDataset Object 255 GeoDatasets Collection 255 GeoDatasets Property 255 GeoEvent Object 257 GeographicCoordSys Constants 258 GeographicTransformation Constants 258 GeographicTransformation Property 258 GeoTransformation Object 260 GetCrossings Method 265 GetParameter Method 267 GotFocus Event 269 GroupRenderer Object 269 HasMeasure Property 272 HasZ Property 273 Height Property 274 HeightField Property 275 HorizontalAlignment Property 277 hWnd Property 281 ImageLayer Object 283 Index Property 284 Indexed Property 286 ProgrammersReference.pmd 8 10/28/2004, 2:42 PM Contents 9 IndexEvents Property 287 IndexExtent Property 291 IndexStatus Constants 292 IndexStatus Method 292 IndexType Constants 293 Insert Method 293 Inset Method 295 Intersect Method 297 IntersectionMatchRules Property 300 IntersectionMatchVariable Property 300 IntersectionMatchVariableCount Property 301 IntersectionStandardizingRules Property 301 Intersects Method 302 InvalidateIndex Method 304 IsCustom Property 304 IsFullyMeasured Property 306 IsPointIn Method 308 IsProjected Property 310 Item Method 310 KeyDown Event 312 KeyPress Event 313 LabelPlacer Object 313 LabelRenderer Object 316 LastError Property 318 Layers Collection 322 Layers Property 322 LayerType Constants 323 LayerType Property 323 Left Property 324 Length Property 325 LevelField Property 326 Line Object 329 ProgrammersReference.pmd 9 10/28/2004, 2:42 PM 10 MapObjects Programmer’s Reference LineStyle Constants 330 LinkGroup Constants 331 ListIndices Method 331 Locate Method 331 LocateCandidate Method 332 Location Property 333 Longitude Property 337 LostFocus Event 339 Map Control 339 MapLayer Object 342 MarkerStyle Constants 343 MaskColor Property 343 MaskLabels Property 345 MatchRules Property 346 MatchScore Property 350 MatchVariable Property 354 MatchVariableCount Property 354 MatchVariableField Property 355 MatchVariableIntersectionLink Property 355 MatchWhenAmbiguous Property 356 Max Property 357 MaxFileBuffer Property 357 MaxLevel Property 359 MaxPieSize Property 359 Mean Property 360 Measure Property 360 Method Constants 362 Method Property 364 Min Property 364 MinimumMatchScore Property 365 MinLevel Property 365 MinPieSize Property 366 ProgrammersReference.pmd 10 10/28/2004, 2:42 PM pmd 11 10/28/2004. 2:42 PM . Contents 11 MinWidth Property 367 MouseDown. Mouse Up Events 368 MouseMove Event 369 MousePointer Constants 370 MousePointer Property 371 Move Method 372 MoveFirst Method 374 MoveNext Method 375 MovePrevious Method 377 MoveTo Method 378 MoveToBottom Method 379 MoveToTop Method 380 MultiplyMeasures Method 382 Name Property 383 NoNullValue Method 384 NormalizationField Property 386 NullValue Property 387 Offset Method 387 Offset Property 388 OffsetMeasures Method 395 OutputMap Method 397 OutputMap2 Method 398 Outline Property 399 OutlineColor Property 401 Pan Method 402 ParameterType Constants 402 Parts Collection 404 Parts Property 405 Password Property 406 Perimeter Property 408 PlaceAbove Property 408 PlaceBelow Property 410 ProgrammersReference. pmd 12 10/28/2004. 12 MapObjects Programmer’s Reference PlaceLocator Object 411 PlaceNameTable Property 412 PlaceOn Property 412 Point Object 413 Points Collection 414 Polygon Object 415 PopulateWithDatums Method 417 PopulateWithGeographicCoordSys Method 417 PopulateWithGeoTransformations Method 418 PopulateWithMeridians Method 418 PopulateWithParameters Method 419 PopulateWithProjectedCoordSys Method 419 PopulateWithProjections Method 420 PopulateWithSpheroids Method 420 PopulateWithUnits Method 421 PrimeMeridian Constants 421 PrimeMeridian Object 422 PrimeMeridian Property 422 PrintMap Method 424 ProjCoordSys Object 425 ProjectedCoordSys Constants 426 Projection Constants 426 Projection Object 428 Projection Property 428 RampColors Method 429 Records Property 429 Recordset Object 431 Rectangle Object 432 Refresh Method 433 RefreshCount Property 435 RefreshLayer Method 436 RefreshRect Method 438 ProgrammersReference. 2:42 PM . 2:42 PM .pmd 13 10/28/2004. Contents 13 Remove Method 439 RemoveEvent Method 439 RemoveRelates Method 440 Renderer Property 441 ReturnDescription Method 443 ReturnLineEvent Method 443 ReturnMeasure Method 446 ReturnPointEvents Method 448 Reverse Method 449 Right Property 450 RollbackTransaction Method 451 Rotation Property 452 RotationAngle Property 454 RotationField Property 455 ScaleRectangle Method 458 ScalingField Property 458 ScrollBars Property 460 SearchExpression Method 461 SearchMethod Constants 463 SearchByDistance Method 465 SearchShape Method 467 SecondDirection Property 469 SecondName Property 470 SecondType Property 471 Server Property 472 Set Method 472 SetMeasures Method 475 SetMeasuresAsLength Method 475 SetParameter Method 476 ShapeType Constants 476 ShapeType Property 477 ShowOutline Property 478 ProgrammersReference. 2:42 PM .pmd 14 10/28/2004. 14 MapObjects Programmer’s Reference Size Property 479 SizeField Property 480 SizeSymbols Method 481 SpellingSensitivity Property 482 Spheroid Constants 483 Spheroid Object 483 Spheroid Property 484 SplinedText Property 486 SqueezeFactor Property 487 Standardizer Object 488 Standardizer Property 490 StartMeasureField Property 491 StartTransaction Method 492 Statistics Object 492 StdDev Property 493 StopEditing Method 493 StreetSide Constants 494 StreetSide Property 494 StreetTable Property 495 Strings Collection 497 Style Property 498 Sum Property 499 SupportsTransactions Property 500 Symbol Object 501 Symbol Property 502 SymbolCount Property 503 SymbolHeight Property 505 SymbolField Property 506 SymbolIndex Property 509 SymbolType Constants 511 SymbolType Property 511 SymbolWidth Property 512 ProgrammersReference. Contents 15 Table Object 515 TableDesc Object 516 TableDesc Property 516 Tag Property 518 TextSymbol Object 520 ToGeoCoordSys Property 521 ToMapDistance Method 521 ToMapPoint Method 523 Top Property 525 TrackCircle Method 526 TrackingLayer Object 527 TrackingLayer Property 528 TrackLine Method 529 TrackPolygon Method 530 TrackRectangle Method 531 Transform Method 531 Transparent Property 535 TransparentColor Property 537 Type Property 538 Union Method 540 Unique Property 544 Unit Constants 545 Unit Object 547 Unit Property 547 Updatable Property 548 Update Method 549 UpdateMeasures Method 549 UpdateWhileDrawing Property 550 UseDefault Property 551 User Property 552 Valid Property 553 Value Property 554 ProgrammersReference. 2:42 PM .pmd 15 10/28/2004. 16 MapObjects Programmer’s Reference ValueAsString Property 556 ValueCalculation Property 558 ValueCount Property 560 ValueField Property 561 ValueMapRenderer Object 562 VerticalAlignment Property 563 Visible Property 563 VisibleRegion Property 565 Width Property 566 WindowMode Constants 567 WindowMode Property 568 X. Y Properties 569 XOffsetField Property 571 XOr Method 571 YOffsetField Property 574 Z Property 575 ZRenderer Object 578 ZValueCalc Constants 579 ProgrammersReference.pmd 16 10/28/2004. 2:42 PM . 2:42 PM .pmd 17 10/28/2004. MapObjects Programmer’s Reference 17 ProgrammersReference. Points Object.ShowOpen ProgrammersReference. Remarks The Add method will only return a Boolean variable if the object is a MapObjects Strings or Layers 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.shp)|*. 18 MapObjects Programmer’s Reference Add Method Applies To Parts Collection. item An expression of any type that specifies the member to add to the collection. You can use the MoveTo and MoveToBottom methods to change the position of a member of the collection. Strings Collection.Add (item) The Add method syntax has the following parts: Part Description variable A boolean expression that indicates whether item was added successfully. Move to a folder containing ESRI shapefiles and open the file. To try this example. Item Method Example This example uses the Add method to add MapLayer objects to a Map. object An object expression that evaluates to an object in the Applies To list. Option Explicit Private Sub Command1_Click() Dim oConnect As New DataConnection Dim oDataset As GeoDataset Dim sName As String Dim oLayer As MapObjects2. GroupRenderer Object. 10:00 AM . When you add a MapLayer or an ImageLayer to a Layers collection. Syntax [Set variable] = object. you’re adding it to the beginning or top of the collection. Layers Object Description Adds a member to a collection object.Filter = “ESRI Shapefiles (*. a CommandButton named Command1 and a Map named Map1 and then press F5 and click Command1. consequently its index is 0 and the numeric index of previously added members of the collection increment by one.pmd 18 10/28/2004. Strings or Layers collections only. See Also Count Property. paste the code into the Declarations section of a form containing a CommonDialog control.shp” CommonDialog1.MapLayer CommonDialog1. FileTitle) _ . Remarks Care should be taken when adding GeoEvents of different shape types to the TrackingLayer. ProgrammersReference. but given the SymbolIndex of a symbol with an incorrect SymbolType.Layers. MapObjects Programmer’s Reference 19 If Len(CommonDialog1.AddEvent( shape. Polygon.FindGeoDataset(sName) If oDataset Is Nothing Then Exit Sub Set oLayer = New MapLayer oLayer.4) Set oDataset = oConnect.FileTitle.pmd 19 10/28/2004. shape An object expression that evaluates to a Point. MapObjects will add the GeoEvent using the correct SymbolType. Len(CommonDialog1. Line.Database = CurDir If Not oConnect. but the default properties of that SymbolType will be used. If a GeoEvent is added.GeoDataset = oDataset Map1. symbolIndex) The AddEvent method syntax has these parts: Part Description variable An object expression that evaluates to a GeoEvent object. or a Points collection. or Ellipse object.Add oLayer End Sub AddEvent Method Applies To TrackingLayer Object Description Creates a new GeoEvent based on a given shape. Syntax Set variable = object. object An object expression that evaluates to a TrackingLayer object.Connect Then Exit Sub sName = Left(CommonDialog1. symbolIndex An integer index that indicates with which Symbol to draw the GeoEvent.FileName) = 0 Then Exit Sub oConnect. 10:00 AM . The method draws the GeoEvent using the Symbol referenced by the SymbolIndex property. Rectangle. TrackingLayer. that GeoEvent will be drawn with a black circle Symbol.AddEvent pt. the GeoEvent is marked with a red symbol.Size = 18 . which is added to the TrackingLayer as a GeoEvent. Note that if you click the map with the left mouse button. Option Explicit Private Sub Map1_MouseDown(Button As Integer. If you click the map with the right mouse button.Polygon Set poly = Map1. To try this example.1 End If End Sub Private Sub Form_Load() ‘ defines two Symbols for the TrackingLayer Dim fnt As New StdFont fnt. The addition of GeoEvents as different shapes is also demonstrated. 10:00 AM . y As Single) If Button = 1 Then Dim pt As MapObjects2.Symbol Object Example This example uses the AddEvent method to place a GeoEvent on the TrackingLayer of a map interactively.TrackingLayer.Point Object. you must then track a polygon. This code adds the GeoEvent to the TrackingLayer at the location(s) you click.CharacterIndex = 129 End With ProgrammersReference. if you add a Point as a GeoEvent to a TrackingLayer. _ x As Single. Button . Button .ToMapPoint(x.TrackingLayer.AddEvent poly.TrackingLayer.Style = moTrueTypeMarker . but use a SymbolType of moFillSymbol.SymbolCount = 2 ‘the following properties will display when you click the ‘left button With Map1. and then press F5 and click the map.Symbol(0) .TrackPolygon Map1.Name = “Wingdings” fnt.Font = fnt . Shift As Integer.Point Set pt = Map1. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer.Bold = False Map1.pmd 20 10/28/2004. y) Map1. See Also GeoEvent Object. 20 MapObjects Programmer’s Reference For example.1 ElseIf Button = 2 Then Dim poly As MapObjects2.Color = moRed . In Visual Basic.GeoDataset ProgrammersReference. name A string expression that evaluates to the name of the GeoDataset object to add to the DataConnection. your application can test for this as follows: Dim gdNew as MapObjects2. only the Point. HasM The AddGeoDataset method syntax has these parts: Part Description object An object expression that evaluates to a DataConnection object. If MapObjects fails to create a new GeoDataset. HasZ. HasM Optional.Symbol(1) . shapeType The type of feature represented in the GeoDataset as described in Settings. 10:00 AM .pmd 21 10/28/2004. TableDesc An object expression that evaluates to a TableDesc object. HasZ Optional.Color = moBlue . If True. A boolean expression. shapeType. Points. MapObjects Programmer’s Reference 21 ‘the following properties will display when you click the ‘right button With Map1. A boolean expression. the data source of the DataConnection object must be a folder to which your application has write access. Line and Polygon shape types are valid. the GeoDataset to be added will be able to store shapes with Z values. Syntax object. the method will return nil.TrackingLayer. the GeoDataset to be added will be able to store shapes with Measure values.AddGeoDataset name. Remarks The AddGeoDataset method creates a new GeoDataset stored as a Shapefile. Note that as the new GeoDataset will be stored as a Shapefile. TableDesc. Settings The values for shapeType are ShapeTypeConstants. To successfully create a new GeoDataset.Style = moGrayFill End With End Sub AddGeoDataset Method Applies To DataConnection Object Description Creates a new GeoDataset object and adds it to a DataConnection.SymbolType = moFillSymbol . If True. If you intend to use geographic data created in MapObjects with older applica- tions. PolyLineM. 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. For each feature added. paste the code into the Declarations section of a form containing a CommonDialog control named CommonDialog1. To try this example.GeoDataset Dim sName As String Dim Desc As New TableDesc Dim dc As New DataConnection ProgrammersReference. 10:00 AM . See the ESRI Shapefile Technical Description for more details. providing the coordinates and map units of the new MapLayer. the code invokes the AddNew and Update methods to populate the fields of the Recordset. The TableDesc properties define three additional fields in the Recordset. This layer will serve as a background layer. a CommandButton named Command1 and Map named Map1 that contains a MapLayer or an ImageLayer. tdNew) If gdNew Is Nothing Then Debug. Option Explicit Dim moSymbol As New MapObjects2. adding it to the Map.1 and MapObjects 2.” End If The HasZ and HasM arguments can be used to specify whether the new GeoDataset has support for Z and Measure values. In addition. PolygonM or MultiPointM. older applications may not be able to read such Shapefiles. PolygonZ or MultiPointZ. GeoDatasets with support for Measure values are created as Shapefiles with shape types of PointM. Polygon or MultiPoint.0. When you’ve added the polygons you want.Print “Failed to create GeoDataset. and track polygons by clicking on the map. moShapeTypePoint _ . PolyLineZ. PolyLine. In some cases. TableDesc Object 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.pmd 22 10/28/2004.AddGeoDataset(“Test”.Symbol Dim moPolygons As New Collection Private Sub Command1_Click() Dim gds As MapObjects2. 22 MapObjects Programmer’s Reference Set gdNew = myDataConnection. See Also GeoDataset Object. GeoDatasets with support for Z values (and. a double-click signals the end of a polygon. Shapefiles with support for Z and Measure values are only fully supported as of ArcView 3. These arguments are optional and default to False. Click F5. click the Save button to specify the name of the shapefile. the code associates the GeoDataset with a MapLayer. if required. Measure values) are created as Shapefiles with shape types of PointZ. GeoDatasets without support for Z or Measure values are created as Shapefiles with shape types of Point. 10:00 AM .Database = CurDir If Not dc.GeoDataset = gds ProgrammersReference.DefaultExt = “.FieldScale(2) = 3 End With Set gds = dc.shp” .FieldType(0) = moString .FieldScale(1) = 3 .4) End With With Desc ‘ define three additional fields . MapObjects Programmer’s Reference 23 Dim lyr As New MapObjects2.MapLayer Dim lPoly As Long With CommonDialog1 .FieldName(1) = “Area” . Desc) If gds Is Nothing Then Exit Sub ‘ invalid file Set lyr.FileName) = 0 Then Exit Sub ‘ cancel dc.pmd 23 10/28/2004.shp” .FieldCount = 3 ‘set the field names .Connect Then Exit Sub ‘ bad dataConnection ‘ remove the extension sName = Left(.shp)|*.FieldLength(0) = 16 ‘ set the number of digits used in the field .FieldPrecision(2) = 15 ‘ set the number of digits to the right of the decimal point .FieldType(1) = moDouble .FileTitle.FieldName(0) = “Name” .FieldName(2) = “Perimeter” ‘ set the type of field . Len(.FieldType(2) = moDouble ‘ set the length of a character field . moPolygon.ShowSave If Len(.AddGeoDataset(sName.FileTitle) .Filter = “ESRI Shapefiles (*.FieldPrecision(1) = 15 . Add lyr Map1.Records .AddNew .Style = moSolidFill .OLE_HANDLE) Dim oPoly As MapObjects2.Perimeter .Fields(“Shape”).DrawShape oPoly.Area . 24 MapObjects Programmer’s Reference Map1. Shift As Integer.Rectangle Dim oPoly As New MapObjects2.Count <> 0 Then For Each oPoly In moPolygons Map1.Caption = “Save” End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.Polygon If moPolygons.Value = moPolygons(lPoly).Value = moPolygons(lPoly).pmd 24 10/28/2004.Value = “Name “ & lPoly .Refresh True ProgrammersReference.Add oPoly Map1. x _ As Single.Count With lyr.SymbolType = moFillSymbol .Value = moPolygons(lPoly) .TrackingLayer. 10:00 AM .Color = moPaleYellow End With Command1.TrackPolygon moPolygons.Fields(“Perimeter”). moSymbol Next End If End Sub Private Sub Map1_MouseDown(Button As Integer. y As Single) Dim oRect As MapObjects2.Refresh For lPoly = 1 To moPolygons.Polygon If Button = 1 Then Set oPoly = Map1.Layers.Update End With Next End Sub Private Sub Form_Load() With moSymbol .Fields(“Name”).Fields(“Area”). if no other field needs to be indexed for the query variable. MapObjects Programmer’s Reference 25 Else Set oRect = Map1.AddIndex (fieldName. for example. indexType) The AddIndex Method syntax has these parts: Part Description variable A boolean expression that indicates whether an index is specified correctly.ScaleRectangle 0. Settings The settings for indexType are IndexTypeConstants: Remarks All logical indices have to be defined before the indices are built using the BuildIndices method. This field is optional and you can use an empty string (two double quotes).Extent oRect. there will be more options available when defining a search query if more logical indices are specified.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. 10:00 AM . IndexType A value or constant that specifies the type of index as defined in the IndexTypeConstants. Multiple logical indices can be specified. object An object expression that evaluates to an object in the Applies To list.pmd 25 10/28/2004. left ZIP and right ZIP. fieldName A string expression that specifies the name of the field in the StreetTable’s GeoDataset. Syntax Set variable = object. This option is used if more than one Field is indexed as one query variable. The AddIndex method defines which Fields are indexed. secondaryFieldName A string expression that specifies the name of the Field in the StreetTable’s GeoDataset. secondaryFieldName. and the type of index which is built. ProgrammersReference.5 Map1. 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. For example. When you have added indices to a Geocoder object. IndexType Constants Example This example demonstrates the use of the AddIndex. it is common to index street name and ZIP or city name Fields. IndexStatus Method. and Command3. two streets in different cities may have the same name. ListIndices Method. Option Explicit Dim geo As New MapObjects2. 26 MapObjects Programmer’s Reference For a large street network.Geocoder ‘Set global variables with field names in the StreetTable ‘Modify if fields names in StreetTable are different Private Const m_FromLeft = “L_f_add” Private Const m_FromRight = “R_f_add” Private Const m_ToLeft = “L_t_add” Private Const m_ToRight = “R_t_add” Private Const m_PreDir = “Prefix” Private Const m_PreType = “Pre_type” Private Const m_StreetName = “Name” Private Const m_StreetType = “Type” Private Const m_SufDir = “Suffix” Private Const m_LeftZone = “Cityl” Private Const m_RightZone = “CityR” Private Sub Command1_Click() ‘Build indices using the AddIndex and BuildIndices methods If Not geo.pmd 26 10/28/2004. EraseIndices Method. so you may want to search on both street name and ZIP fields. based on those indices. A normal (mgIndexTypeNormal) index can be used on any field in the StreetTable. paste the code into the Declarations section of a form that contains a Map named Map1 and three CommandButtons named Command1. Next to the three buttons. BuildIndices. Command2. Label2 and Label3. for example street names.IndexStatus = _ MapObjects2. ListIndices. You may like to use a Soundex (mgIndexTypeSoundex) index on fields which can be misspelled. Substitute appropriate values for the data paths. the SearchQueries property should be defined accordingly. EraseIndices and IndexStatus methods. See Also BuildIndices Method. SearchQueries Property. add three Labels named Label1.IndexStatusConstants. To try this example. 10:00 AM . Then press F5 and click each button to see what will happen.mgIndexExists Then ProgrammersReference. ” Else Label2. mgIndexTypeSoundex) Then MsgBox “Cannot build geocoding index. _ mgIndexTypeNormal) Then MsgBox “Cannot build geocoding index.pmd 27 10/28/2004. vbCritical Exit Sub End If If Not geo. vbCritical Exit Sub End If If Not geo.ListIndices ProgrammersReference.EraseIndices Then Label2. MapObjects Programmer’s Reference 27 If Not geo. m_RightZone.Strings Set l = geo. _ mgIndexExists Then If geo.”.Caption = “Indices are built.AddIndex(m_StreetName. “”.Caption = “No indices to remove” End If End Sub Private Sub Command3_Click() ‘Show the indices information using the ListIndices method Dim i As Integer Dim msg As String Dim l As New MapObjects2. 10:00 AM .IndexStatusConstants.AddIndex(m_LeftZone.”.BuildIndices(True) Then MsgBox “Cannot build geocoding index.” End If End Sub Private Sub Command2_Click() ‘Remove the index file if it exists and not read-only using ‘the EraseIndices method If geo.”.” End If Else Label1.” End If Else Label2.Caption = “Can’t remove indices.Caption = “Index already exists.IndexStatus = MapObjects2.Caption = “Indices are removed. vbCritical Exit Sub Else Label1. 28 MapObjects Programmer’s Reference If geo.Caption = “” Label3.Color = moBlue Map1.IndexStatus = MapObjects2.Caption = “” dc.Caption = “Show Indices” Label1.count & “ _ logical index/indices.pmd 28 10/28/2004.Caption = “Remove Indices” Command3.DataConnection Dim gd As Object Dim lyr As New MapLayer Command1.Connected Then MsgBox “dc.Connect If Not dc.Add lyr geo.1 msg = msg & l.Database = “C:\Program Files\ESRI\MapObjects2\ _ Samples\Data\Redlands” dc.GeoDataset = gd lyr. including:” & vbCrLf For i = 0 To l.Layers.count .StreetTable = gd ‘Change the path below to ones appropriate for your data geo.IndexStatusConstants.MatchRules = “C:\Program Files\ESRI\MapObjects2\ _ ProgrammersReference.Caption = “Build Indices” Command2.Symbol.Caption = msg End Sub Private Sub Form_Load() Dim dc As New MapObjects2.Item(i) & vbCrLf Next i Else msg = “No indices are found” End If Label3.Caption = “” Label2. 10:00 AM .connected error” End End If Set gd = dc.FindGeoDataset(“Redlands”) lyr. _ mgIndexExists Then msg = “The index file contains “ & l. MapObjects Programmer’s Reference 29 GeoRules\us_addr1. After you modify the new record. No changes are made to the data set until you use the Update method.MatchVariableField(“PreType”) = m_PreType geo.MatchVariableField(“LeftZone”) = m_LeftZone geo. use the Update method to save the changes and add the record to the Recordset. SearchByDistance.pmd 29 10/28/2004. or SearchExpression.MatchVariableField(“PreDir”) = m_PreDir geo. Invoke AddNew on complete Recordset objects only.MatchVariableField(“FromRight”) = m_FromRight geo. Make sure that any editing operations your program carries out are made to the same Recordset object for which you called the AddNew method.MatchVariableField(“ToRight”) = m_ToRight geo.MatchVariableField(“FromLeft”) = m_FromLeft geo.MatchVariableField(“StreetName”) = m_StreetName geo. MapObjects will issue a run-time error if you invoke AddNew on a Recordset that represents a subset of a MapLayer object’s Recordset created by one of the following Recordset methods: SearchShape.MatchVariableField(“ToLeft”) = m_ToLeft geo. Syntax object. 10:00 AM . if any. The safest approach is to create a ProgrammersReference.MatchVariableField(“StreetType”) = m_StreetType geo.MatchVariableField(“RightZone”) = m_RightZone End Sub AddNew Method Applies To Recordset Object Description Creates a new record for a Recordset object.mat” ‘ Link the Match Variables to fields in the StreetTable geo.AddNew The AddNew property syntax has these parts: Part Description object An object expression that evaluates to a Recordset object.MatchVariableField(“SufDir”) = m_SufDir geo. 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. See Also Geocoder Object. an AddressLocation object is re- turned. MatchScore Property. you might decide to provide a means for manual intervention in order to match the address. and side of the street with the StreetSide property if applicable.Update Else MsgBox “AddNew failed. called new_layer: Dim recs As MapObjects2. ProgrammersReference. StreetSide Property AddRelate Method Applies To MapLayer Object Description Creates a relate between the Recordset associated with a MapLayer and the Recordset of another Table. If your MatchScore is low. 10:00 AM . on which all the editing operations are carried out. MapObjects finds the geographic location of an address by searching the Geocoder object’s StreetTable.Records If recs.pmd 30 10/28/2004. When you locate a successfully matched address using LocateCandidate. you can return the Location of the address as a Point object.Updatable Then recs. 30 MapObjects Programmer’s Reference local Recordset object. You can return the status of the matched AddressLocation by reading its MatchScore property. The following Visual Basic example shows how this can be done for a given MapLayer.AddNew If recs.EditMode = moEditAdd Then ‘ Add new feature and attributes recs.” End If End If See Also Recordset Object Example See AddGeoDataset Method AddressLocation Object An AddressLocation object represents the results of an address match.Recordset Set recs = new_layer. Standardizer Object Properties Location Property. If the match was successful. The default value for checkFields is True. If they do. sourceTable. checkFields (Optional) A boolean expression specifying whether the AddRelate method performs additional checks on the Fields of the Table before attempting the relate. this last set of checks will not be carried out and AddRelate will succeed if the first sets of checks are successful. do the specified Fields exist? 3. If either the toField or fromField is not of a supported type then AddRelate will return False. Certain ODBC drivers do not ProgrammersReference. 10:00 AM . fromField A string expression that evaluates to the name of a Field in sourceTable. does a request to build an index on the toField return successfully? If one or more of these conditions are true. If checkFields is false. The following checks are made: 1. toField A string expression that evaluates to the name of a Field in the Recordset associated with the MapLayer. then AddRelate will succeed. If not. If so. fromField. When checkFields is True. the AddRelate method carries out further checks against the toField in the sourceTable. is the toField indexed? 3. it may not be possible for MapObjects to carry out the last set of checks. sourceTable An object expression that evaluates to a Table object that contains the data to relate to the MapLayer object’s Recordset. Is the toField the key field of the sourceTable? 2.[checkFields as Boolean]) The AddRelate method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 31 10/28/2004. If not. checks are performed on the sourceTable to ensure that the relate is possible. Does the Table actually exist? 2. character/string fields and Boolean fields. Remarks When the AddRelate method is used.AddRelate( toField. are they supported relate types? The supported relate types: are numeric fields. MapObjects Programmer’s Reference 31 Syntax object. and the relate will not be successful. See Remarks below. Depending on the database that contains the sourceTable. The following checks are carried out: 1. dbf)|*. Press F5.FileName. In this case. two CommandButton controls named Command1 and Command2. If the user specified in the User property of the Table object does not have sufficient privileges.pmd 32 10/28/2004.Table CommonDialog1.field Private Sub Command1_Click() Dim fName As String Dim dName As String Dim relTable As New MapObjects2.dbf” CommonDialog1. you’ll have to create an index on the field in the sourceTable. Option Explicit Dim recset As MapObjects2. In these cases. relTable. paste the code into the Declarations section of a form containing a CommonDialog control named CommonDialog1. a ListBox named List1.Layers(0).Recordset Dim f As MapObjects2.Clear Set recset = Map1. dName. In addition.Records ProgrammersReference. 10:00 AM .Layers(0). 32 MapObjects Programmer’s Reference support the necessary functionality to determine these conditions.dbf) DataSource named the same as the folder that contains the dBase Table that you want to relate to the MapLayer.ShowOpen SplitFN CommonDialog1. “COUNTRY”) Then List1. and a Map named Map1 that has a MapLayer.AddRelate(“ABBREVNAME”.Name = fName ‘ field names in next line are hard-coded If Map1. This should be done with care. See Also Table Object 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 object’s Recordset. If the Recordset has more than 100 records. particularly with large data sets. the checkFields parameter should be set to False. It also uses the RemoveRelates method to drop all the related fields. then click Com- mand1. You’ll see the additional fields in the ListBox. The example assumes that you have a Microsoft dBase Driver (*. as the performance of any relate without an index may be inefficient. for example when carrying out a relate to an Oracle view. fName ‘ assumes the ODBC DataSource name is the directory name relTable.Database = dName relTable. 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. you’ll have to change the field names that you pass as parameters to AddRelate.Filter = “dBASE files (*. To try this example. MapObjects can not carry out the required indexing operations. you may wish to set checkFields to False in order to carry out the relate. Clear For Each f In recset.Layers(0).Fields List1.Caption = “Remove Relates” End Sub Sub SplitFN(pathName As String. nLastPos .AddItem f.Name Next f Else MsgBox “ “ End If End Sub Private Sub Command2_Click() Map1.Fields List1.Layers(0). vbDirectory) fName = Right(pathName. Len(pathName) . 10:00 AM .Layers(0). nLastPos As Integer ‘ find the last occurrence of a file separator ‘ in the path nCurPos = 0 Do nLastPos = nCurPos nCurPos = InStr(nCurPos + 1.AddItem f. dName As String.Fields List1.Records For Each f In recset.Name Next f Command1.pmd 33 10/28/2004.1) dName = Dir(dirName. MapObjects Programmer’s Reference 33 For Each f In recset.Records List1. “) Loop Until nCurPos = 0 If nLastPos = 0 Then Exit Sub dirName = Left(pathName.Name Next f End Sub Private Sub Form_Load() Set recset = Map1.AddItem f. pathName. fName As String) Dim dirName As String Dim nCurPos As Integer.Caption = “Add Relate” Command2.nLastPos) End Sub ProgrammersReference.RemoveRelates Set recset = Map1. pmd 34 10/28/2004. and then press F5. hDC A handle provided by the Microsoft Windows operating environment to the device context of the Map.Layers(index). ByVal hDC As stdole. To try this example. Syntax Private Sub object_AfterLayerDraw(ByVal index As Integer. ByVal _ canceled As Boolean. Remarks You can use the hDC to refer to the handle for an object’s device context. ByVal canceled As Boolean. index An integer that uniquely identifies a member of the Layers collection.OLE_HANDLE) The AfterLayerDraw event syntax has these parts: Part Description object An object expression that evaluates to a Map. 10:00 AM . BeforeTrackingLayerDraw Event Example This example illustrates when the AfterLayerDraw Event occurs. the code displays a simple message that indicates the name of the layer. ProgrammersReference. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. This provides a value to pass to Windows API calls.Name.OLE_HANDLE) MsgBox “Completed drawing “ & Map1. See Also AfterTrackingLayerDraw Event. Prior to drawing each layer on the Map. ByVal hDC As Stdole. Option Explicit Private Sub Map1_AfterLayerDraw(ByVal index As Integer. _ vbInformation End Sub AfterTrackingLayerDraw Event Applies To Map Object Description Occurs when a Map completes drawing all the GeoEvent objects on its TrackingLayer. 34 MapObjects Programmer’s Reference AfterLayerDraw Event Applies To Map Object Description Occurs when a Map finishes drawing a specified layer. BeforeLayerDraw Event. TrackingLayer. paste the code into the Declara- tions section of a form containing a Map named Map1 that contains at least one MapLayer. Shift As Integer.Point Set pt = Map1. 0 Map1. MapObjects Programmer’s Reference 35 Syntax Private Sub object_AfterTrackingLayerDraw(ByVal hDC As Stdole. Remarks You can use the hDC to refer to the handle for an object’s device context. _ X As Single.TrackingLayer.OLE_HANDLE) Dim msg As String Select Case Map1. 10:00 AM . and then press F5. To try this example. This provides a value to pass to Windows API calls.pmd 35 10/28/2004. Option Explicit Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ stdole. Click on the Map to add GeoEvent objects. BeforeLayerDraw Event. “MapObjects” End Sub Private Sub Map1_MouseDown(Button As Integer.TrackingLayer.TrackingLayer.AddEvent pt. Clicking on the map adds a GeoEvent to the TrackingLayer. BeforeTrackingLayerDraw Event Example This example demonstrates when the AfterTrackingLayerDraw Event occurs.Refresh True End Sub ProgrammersReference. Y) Map1.EventCount & “ GeoEvents on _ the TrackingLayer” End Select MsgBox msg. hDC A handle provided by the Microsoft Windows operating environment to the device context of the Map.OLE_HANDLE) The AfterTrackingLayerDraw event syntax has these parts: Part Description object An object expression that evaluates to a Map.ToMapPoint(X. vbInformation.EventCount Case 0 msg = “No GeoEvents on the TrackingLayer yet” Case 1 msg = “One GeoEvent on the TrackingLayer” Case Else msg = Map1. Y As Single) Dim pt As MapObjects2. See Also AfterLayerDraw Event. The event code reports on the number of GeoEvent objects on the TrackingLayer. Syntax object. TextSymbol Object AllowDuplicates Property Applies To LabelRenderer Object. moAlignRight 4 H Align the right side of the text with the feature. moAlignBaseline 6 V Align the baseline of the text with the feature.pmd 36 10/28/2004. moAlignLeft 3 H Align the left side of the text with the feature. H Align the center of the text with the feature. Constant Value Use with Description moAlignTop 1 V Align the top of the text with the feature. 10:00 AM . See Also 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. moAlignBottom 2 V Align the bottom of the text with the feature. moAlignCenter 5 V.AllowDuplicates [= boolean] The AllowDuplicates property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. ProgrammersReference. 36 MapObjects Programmer’s Reference 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. MapObjects Programmer’s Reference 37 boolean A boolean expression specifying whether the LabelRenderer or LabelPlacer object will draw duplicate labels if it has already drawn a label with the same text. and Check3. It uses the DrawBackground property to control whether the features of the MapLayer draw.SymbolCount = 1 ProgrammersReference. Check2. paste the code into the Declarations section of a form containing a Map named Map1 that contains a MapLayer that displays polygon features. just make sure to leave enough room below the map on the Form. To try this example. It uses the AllowDuplicates property to control whether a LabelRenderer object will draw more than one instance of the same text to a MapLayer.Recordset Dim oRenderer As New MapObjects2.Renderer = oRenderer With oRenderer . See Also TextSymbol Object Example This example uses three of the LabelRenderer properties to control the appearance of the text drawn by the renderer. 10:00 AM .Name = “Arial” ‘set up the LabelRenderer Set Map1. False The object will not draw duplicate labels. a ListBox named List1. its actual default is True. and a CommandButton named Command1.LabelRenderer If List1. Press F5 and double-click the name of a Field that will serve as the source or the text.ListIndex <> -1 Then ‘must have a field selected ‘use a TrueType Font oFont. three CheckBox controls named Check1. Settings The settings for boolean are: Setting Description True (Default) The object will draw duplicate labels.Layers(0). Note that while the example initializes AllowDuplicates to False.pmd 37 10/28/2004. Option Explicit Private Sub List1_DblClick() Dim sFldname As String Dim oFont As New StdFont Dim oRecs As MapObjects2. Toggle the check box controls to set the properties. It also uses the SplinedText property to control whether text splines when the MapLayer displays line features. The code will position and size the controls. as described in Settings. ListIndex) .Left = Check1.Font = oFont .Value .Left Check3.Left = List1.List(List1. 38 MapObjects Programmer’s Reference .AllowDuplicates = Check1.Left + List1.SplinedText = Check3.Left = Map1.Symbol(0).Symbol(0).Width + 100 Check2.08 sFldname = List1.Symbol(0).Value . 10:00 AM .DrawBackground = Check2.Color = moBlack .pmd 38 10/28/2004.Extent.Height * 0.Field Command1.Left = Check1.Value .Caption = “Splined text” List1.Left Check1.Caption = “Allow duplicate labels” Check2.Left ProgrammersReference.Caption = “Draw background” Check3.Caption = “Full Extent” Check1.Height = Map1.Field = sFldname ‘text values stored in this field End With Map1.Refresh ‘redraw the map ‘disassociate objects Set oFont = Nothing Set oRecs = Nothing Set oRenderer = Nothing End If End Sub Private Sub Check1_Click() List1_DblClick End Sub Private Sub Check2_Click() List1_DblClick End Sub Private Sub Check3_Click() List1_DblClick End Sub Private Sub Form_Load() Dim oField As MapObjects2. Y As Single) If Button = 1 Then Map1.Left = Check1.Extent = Map1.Height Check3.Top + Check2.Top = Check1.pmd 39 10/28/2004.Extent = Map1.Top + Map1.Width + Check2.Width = Check3. 10:00 AM . Shift As Integer. Syntax object.Height Check1. MapObjects Programmer’s Reference 39 Command1.Value = 0 ‘AllowDuplicates initialized to False Check2.Width = Check1. _ X As Single.Left List1.Name Next End Sub Private Sub Map1_MouseDown(Button As Integer.Top = List1.Width = Check2.Width Check3.Height + 100 Check1.Top = Check2.Width + Check3.Top + Check1.TrackRectangle Else Map1.Value = 1 ‘DrawBackground initialized to True Check3.Records.Layers(0).Width + Check1.Top + Check3.Top Check2.Height Command1.Fields List1.Width Check2.Top = Map1.Width Check1.AddItem oField.FullExtent End Sub AllowSharing Property Applies To GeoDataset Object Description Returns or sets a value indicating whether other applications may write to the GeoDataset object.AllowSharing [= shared] The AllowSharing property syntax has these parts: ProgrammersReference.Pan End If End Sub Private Sub Command1_Click() Map1.Top = Check3.Value = 1 ‘SplinedText initialized to True For Each oField In Map1. Constant Value Description moFlat 0 (Default) Flat. and the MapObjects applica- tion is not editing the Recordset (see the EditMode property page).pmd 40 10/28/2004. If a GeoDataset has already been opened by another application for editing. Paints the map with three-dimensional effects. perfor- mance may be slower when using a GeoDataset with its AllowSharing property is set to True. mo3D 1 3D. as described in Settings. 10:00 AM . Appearance Property ProgrammersReference. See Also Map Object. when a GeoDataset is returned its AllowSharing property is set to False. As neither MapObjects nor the computer’s operating system can efficiently cache files that have been opened with shared write privileges. then MapObjects will return the GeoDataset with its AllowSharing property set to True. Paints the map without visual effects. shared A boolean expression specifying whether other applications may write to the GeoDataset object. By default. See Also Recordset Object. 40 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to a GeoDataset object. Settings The settings for shared are: Setting Description True Shares to other applications for writing to the GeoDataset object. set the AllowSharing property to True after it is returned. 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. False (Default) Shares to other applications for reading the GeoDataset object. Table Object Example See MaxFileBuffer Property Appearance Constants MapObjects defines the following constants for use with the Appearance property of a Map object. If you wish other applications to be able to edit the GeoDataset. as de- scribed in Settings. value A value of double data type equating to the area of the Polygon. ProgrammersReference. Settings The settings of Appearance are AppearanceConstants. To try this example.Appearance [= value] The Appearance property syntax has these parts: Part Description object An object expression that evaluates to a Map. See Also Perimeter Property 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.Area [=value] The Area property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. MapObjects Programmer’s Reference 41 Appearance Property Applies To Map Object Description Returns or sets the paint style of a Map object at run time. Press F5 and click on a polygon. value A value or constant that determines the appearance of an object. ScrollBars Property Area Property Applies To Polygon Object Description Returns the area of an object in square map units. See Also BackColor Property. Read-only at run time. Syntax object. 10:00 AM . copy the code into the Declarations section of a Form that contains a Map named Map1 that contains a MapLayer with polygon features. Syntax object. BorderStyle Property.pmd 41 10/28/2004. Field Set oPoint = Map1.Centroid. 10:00 AM .Area & vbCr & _ “Perimeter: “ & .ToMapPoint(x.Value.FlashShape oFld. area An object expression that evaluates to a Rectangle object.EOF Then Set oFld = oRecset(“shape”) Map1. The property is read-only at both design time and run time. y) Set oRecset = Map1. “”) If Not oRecset. Syntax object.Centroid. 42 MapObjects Programmer’s Reference Option Explicit Private Sub Map1_MouseDown(Button As Integer. _ x As Single.pmd 42 10/28/2004.Value MsgBox “Area: “ & .Layers(0).MoveFirst ‘reset the cursor ‘report the results With oFld. ProgrammersReference.Recordset Dim oPoint As MapObjects2. 4 oRecset. _ moPointInPolygon.y End With End If End Sub AreaOfInterest Property Applies To MapLayer Object Description Returns the default area of interest for a MapLayer object.Perimeter & vbCr & _ “Centroid X: “ & .AreaOfInterest [= area] The AreaOfInterest property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.x & vbCr & _ “Centroid Y: “ & .SearchShape(oPoint. Shift As Integer. y As Single) Dim oRecset As MapObjects2.Point Dim oFld As MapObjects2. as described in Settings. _ x As Single.AutoFlush [= boolean] The AutoFlush property syntax has these parts: Part Description object An object expression that evaluates to a Recordset object. boolean A boolean expression specifying whether changes to the Recordset are automatically made on each write. MapObjects Programmer’s Reference 43 Remarks For MapLayer objects based on shapefiles. Drag a rectangle to zoom in and press Command1 to zoom to the extent of the topmost MapLayer. Extent Property Example This example uses the AreaOfInterest property to zoom to the extent of a MapLayer. The area of interest for an SDE layer may be a subset of the entire layer extent.TrackRectangle End Sub 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. Shift As Integer. 10:00 AM . the area of interest is the same as the Extent.AreaOfInterest End Sub Private Sub Map1_MouseDown(Button As Integer.Extent = Map1.Layers(0). Option Explicit Private Sub Command1_Click() Map1.pmd 43 10/28/2004. See Also Rectangle Object. y As Single) Map1.Extent = Map1. Changes are automatically flushed on each write. To try this example. Press F5. Syntax object. 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. Settings The settings for boolean are: Setting Description True (Default). ProgrammersReference. See Also Recordset Object.TrackPolygon Set moRecset = Map1. The example makes use of the AutoFlush method to optimize the write operations. then press F5.Color = moYellow End With Map1.OLE_HANDLE) Dim oSym As New MapObjects2.Layers(0).Recordset Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.Style = moSolidFill . _ moEdgeTouchOrAreaIntersect. Note that this example creates a hard-coded shapefile named shptemp in the current path.pmd 44 10/28/2004.Symbol If moRecset Is Nothing Then Exit Sub With oSym . AutoFlush should be set to True. Setting AutoFlush to True will flush the file. 44 MapObjects Programmer’s Reference False Changes are not automatically flushed on each write. 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.DrawShape moRecset.SearchShape(moPoly. as will StopEditing or releasing the Recordset object. Option Explicit Dim moPoly As MapObjects2. Shift As Integer. For updates to be reliably seen as they occur. oSym Call MakeShapeFromSelection(moRecset) Set moRecset = Nothing End Sub Private Sub Map1_MouseDown(Button As Integer. To try this example. “”) ProgrammersReference. 10:00 AM . Track a polygon shape to select the features you want to save to a new shapefile. _ x As Single. Edit Property Example This example uses the SearchShape method to select features in order to create a new shapefile based on the Recordset the method returns. y As Single) Set moPoly = Map1.SymbolType = moFillSymbol . Remarks Setting AutoFlush to False will result in performance improvements for “batch” type opera- tions such as creating new Shapefiles.Polygon Dim moRecset As MapObjects2. Layers.Value = oField.AutoFlush = True ‘flush the file End If MsgBox “Shapefile written to “ & CurDir.pmd 45 10/28/2004.you may wish to ‘change ‘this path to a more suitable location.Recordset) Dim oTable As MapObjects2.Fields(oField.DataConnection Dim oLayer As New MapObjects2. _ moPolygon.GeoDataset Dim oConnection As New MapObjects2.AutoFlush = False ‘optimize by not flushing ‘changes automatically Do While Not oRecset.Value Next .Database = CurDir If oConnection.MoveNext Loop otemprecs.AddGeoDataset(“shptemp”.TrackingLayer.Records otemprecs.Connect Then Set oTable = oRecset.EOF With otemprecs .TableDesc Dim oDataset As MapObjects2.Layers(“shptemp”).Update End With oRecset.Name).Add oLayer oRecset.TableDesc Set oDataset = oConnection. MapObjects Programmer’s Reference 45 moRecset.Refresh True End Sub Private Sub MakeShapeFromSelection(ByVal oRecset As _ MapObjects2.MoveFirst Set otemprecs = Map1.Field Dim otemprecs As MapObjects2.Fields . vbInformation _ ProgrammersReference.MoveFirst Map1.Recordset ‘Check out the path of your current directory .GeoDataset = oDataset Map1.MapLayer Dim oField As MapObjects2. oTable) If oDataset Is Nothing Then Exit Sub Set oLayer. oConnection.AddNew For Each oField In moRecset. 10:00 AM . Also. Remarks A Spheroid is based on the two radii of an Ellipse.Visible = True Map1. To try this example. value A double value that specifies the length of the semimajor Axis of the Spheroid.Extent = Map1.Layers. Then press F5.Spheroid Dim theDatum As New MapObjects2. connecting the centre of the earth with either pole.Remove 1 Map1.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.Layers(“shptemp”). The vertical axis (the Polar axis).Datum ProgrammersReference. and click Command1. may also be referred to as the PrimeMeridian. and defines the semimajor axis of the earth.Layers(“shptemp”). Option Explicit Private Sub Command1_Click() Dim theSphere As New MapObjects2. Syntax object. and the longer as the semimajor. enter different values in the two textboxes. there you should add a Map named Map1 containing one MapLayer which has a GeoCoordSys set. the shorter of which is referred to as the semiminor axis. and a CommandButton named Command1. The line of latitude midway between the poles of the earth is called the Equator. “Shapefile Exported” Map1. paste the code into the Declarations section of a new Form which has two textboxes named Text1 and Text2. 46 MapObjects Programmer’s Reference . See Also Datum Object Example This example demonstrates how the Flattening and Axis properties of the Spheroid object may be changed. 10:00 AM .Axis [= value ] The Axis property syntax has these parts: Part Description object An object expression that evaluates to a Spheroid object.pmd 46 10/28/2004. BorderStyle Property.Text theSphere.Datum.Flattening Command1. _ GeoCoordSys.Type theDatum.Layers(0).Layers(0).Layers(0). _ GeoCoordSys.Type = Map1.Spheroid.CoordinateSystem.CoordinateSystem.Refresh End Sub Private Sub Form_Load() Text1.Type theSphere.pmd 47 10/28/2004. 10:00 AM .Flattening = Text2.Layers(0).GeoCoordSys theSphere. ScrollBars Property Syntax object.Datum = theDatum Map1.Text theDatum._ GeoCoordSys. color A value or constant that determines the color of the background of the Map control. ProgrammersReference.Type = Map1.Caption = “Set New Values” End Sub BackColor Property Applies To Map Object Description Returns or sets the background color for a Map See Also Appearance Property.Type theGCS.Spheroid.Datum.Spheroid = theSphere theGCS.Layers(0).Datum.Layers(0).Text = Map1.GeoCoordSys _ .CoordinateSystem.CoordinateSystem. MapObjects Programmer’s Reference 47 Dim theGCS As New MapObjects2.Type = Map1.Datum.Datum.Axis = Text1.Spheroid.CoordinateSystem.Axis Text2.Spheroid.Text = Map1.CoordinateSystem = theGCS Map1.Spheroid.BackColor [= color] The BackColor property syntax has these parts: Part Description object An object expression that evaluates to a Map. _ GeoCoordSys. 10:00 AM .Caption = “Black” Else Map1. Any features in MapLayers with the same color as the BackColor property will also be rendered transparent.Caption = “Black” 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. 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. as the background of the Map is transparent.pmd 48 10/28/2004.BackColor = moBlack Then Map1. the BackColor will not be used.BackColor = moBlack Command1.Caption = “White” End If End Sub Private Sub Form_Load() Command1. Example This example uses the BackColor property to toggle the background color of a Map. ProgrammersReference.BackgroundRenderer [= renderer] The BackgroundRenderer property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.BackColor = moWhite Command1. This can be any of the renderers in the See Also list. renderer An object expression that evaluates to a MapObjects renderer object. 48 MapObjects Programmer’s Reference Settings See ColorConstants Remarks Note that when using a Map control with it’s WindowMode property set to Windowless Transparent. Option Explicit Private Sub Command1_Click() If Map1. Syntax object. To try this example. Renderer.Value = 1) Map1. 10:00 AM . two CheckBox controls named Check1 and Check2. In Visual Basic.Renderer = New MapObjects2. set the Renderer property to Nothing.Extent r.MaskLabels = (Check2. ChartRenderer Object. See Also ClassBreaksRenderer Object. paste the code into the Declarations section of a form that contains a CommandButton named Command1. Press F5. Option Explicit Dim g_StreetRenderer As New MapObjects2.Renderer.Renderer.Value = vbChecked Then ‘ re-attach the group renderer Set Map1. Symbol Object.Layers(0).5 Map1. ValueMapRenderer Object.pmd 49 10/28/2004.Refresh End Sub Private Sub Check2_Click() Map1.BackgroundRenderer = Nothing End If Map1. To try this example. MapObjects Programmer’s Reference 49 Remarks A Renderer is a creatable object in MapObjects.Layers(0). DotDensityRenderer Object.ValueMapRenderer To draw with a single symbol.Refresh End Sub Private Sub Command1_Click() Dim r As Rectangle Set r = Map1. here’s one way to create one of the kinds of renderers: Set Map1. ZRenderer Object Example This example uses a GroupRenderer to serve as the BackgroundRenderer of a LabelPlacer to render a street network.Layers(0).Layers(0).LabelPlacer Private Sub Check1_Click() If Check1.BackgroundRenderer Set Map1.Renderer.BackgroundRenderer = g_StreetRenderer Else ‘ detach the group renderer Set g_StreetRenderer = Map1.Extent = r End Sub Private Sub Form_Load() ProgrammersReference. You can click-drag to zoom in or use the right-mouse button to pan. 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.GroupRenderer Dim LabelPlacer As New MapObjects2.ScaleRectangle 1.Layers(0). BackColor = 14811135 ‘ set an initial extent Dim r As New Rectangle r.Color = moNavy ‘ create a font to be used by the LabelPlacer Dim fnt As New StdFont fnt.75 Set Map1.Name = “Times” fnt.Right = -117.Font = fnt LabelPlacer.Top = 34.0285801368372 r.ValueCount = 1 LabelPlacer.Bold = True Set LabelPlacer.Layers(0).Caption = “Use GroupRenderer as BackgroundRenderer” Command1.160018438746 r.047951088234 r.183964079772 r.Value = vbUnchecked ‘ set a backcolor for the map Map1.Renderer = LabelPlacer LabelPlacer.Bottom = 34.AllowDuplicates = False ‘ add a specific value for major roads LabelPlacer.FullExtent.Field = “NAME” LabelPlacer.ValueField = “CFCC” LabelPlacer.DefaultSymbol.Value(0) = “A31” fnt.Layers(0).LabelPlacer Set Map1.Bold = False ‘ setup the LabelPlacer Dim LabelPlacer As New MapObjects2.Height / 100 ProgrammersReference.Extent = r ‘ default color for the layer Map1. 10:00 AM .Font = fnt LabelPlacer.Caption = “Zoom Out” Check2.Caption = “Mask Labels” Check2.Symbol.Height / 150 Set LabelPlacer.Left = -117. 50 MapObjects Programmer’s Reference Check1.Symbol(0).ScaleRectangle 0.Symbol(0).DrawBackground = True ‘ default symbol LabelPlacer.Height = Map1.DefaultSymbol.pmd 50 10/28/2004.FullExtent.Height = Map1. masklabels = True LabelPlacer. _ x As Single. 10:00 AM .Value = Checked End Sub Private Sub Map1_MouseDown(Button As Integer.ValueCount = 1 vR.SymbolType = moLineSymbol vR.Symbol(0).pmd 51 10/28/2004.DefaultSymbol.Field = “CFCC” vR.Color = moLightGray vR. MapObjects Programmer’s Reference 51 ‘ mask the labels ‘ labelPlacer.Field = “CFCC” vR. y As Single) If Button = 1 Then Map1.Add vR ‘next renderer for the group Check1.Size = 2 vR. Shift As Integer.DefaultSymbol.DefaultSymbol.Symbol(0).TrackRectangle Else Map1.BackColor ‘ create a group renderer to act as the background ‘ renderer for the LabelPlacer and populate it with ‘ two renderers to draw the streets Set LabelPlacer.Pan End If End Sub ProgrammersReference.Color = moWhite g_StreetRenderer.Size = 6 vR.SymbolType = moLineSymbol vR.Size = 6 g_StreetRenderer.Value(0) = “A31” vR.Add vR ‘first renderer for the group ‘ setup a value map renderer to draw the exterior ‘ part of the road Set vR = New ValueMapRenderer vR.BackgroundRenderer = g_StreetRenderer ‘ create a renderer for the interior part of the ‘ roads Dim vR As New ValueMapRenderer vR.MaskColor = Map1.Extent = Map1.Color = moRed vR.DefaultSymbol. Field(0) = “Males” .pmd 52 10/28/2004. If no BarHeight is specified a default value of 20 points is used.ChartType = moBar . paste the code in the Declarations section of a form that contains two TextBoxes named Text1 and Text2. If any of the data the ChartRenderer renders has a negative value. you should change the values in the Field property array.BarWidth = Text2. To try this example. then the full size of the chart will be twice the BarHeight.Color(1) = moGreen . you can change the values of the dimensions of the bar charts and then click Command1 to display them.ChartRenderer Private Sub Command1_Click() With cr . therefore if needed. Option Explicit Dim cr As New MapObjects2.BarHeight = Text1. Press F5 to run the example.FieldCount = 2 .BarHeight [= value] The BarHeight property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Text . 52 MapObjects Programmer’s Reference BarHeight Property Applies To ChartRenderer Object Description Returns or sets the full height of the bar chart in points.Field(1) = “Females” . This example assumes the MapLayer is the USA Counties sample data.Color(0) = moRed . 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. a CommandButton named Command1 and a Map named Map1 that contains a MapLayer that has numeric data to render. Syntax object. See Also BarWidth Property 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.Text End With ProgrammersReference. 10:00 AM . See Also BarHeight Property ProgrammersReference.Item(0).pmd 53 10/28/2004.5 ext.Right = -73. Shift As Integer.Renderer = cr Text1. If no BarWidth is specified a default value of 20 points is used. y As Single) If Button = 1 Then Map1. x _ As Single.Extent = Map1.TrackRectangle Else Map1.Pan End If End Sub BarWidth Property Applies To ChartRenderer Object Description Returns or sets the full width of the bar chart in points.Bottom = 40 Map1.Extent = ext End Sub Private Sub Map1_MouseDown(Button As Integer.5 ext.BarWidth [= value] The BarWidth property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Rectangle ext. 10:00 AM .Top = 41 ext.Left = -74.Layers.Caption = “Show Renderer” Dim ext As New MapObjects2. Syntax object.Text = 30 Text2. Remarks All the bars of the bar chart will be scaled to fit within the specified BarWidth value.Text = 15 Command1. MapObjects Programmer’s Reference 53 Map1.Refresh End Sub Private Sub Form_Load() Set Map1. value An integer that represents the full width of the bar chart in points. For example. the addressField may contain records such as ‘380 New York St’. outputTable. Syntax Set variable = object.BatchMatch (addressTable. streetFields) The BatchMatch method syntax has these parts: Part Description variable A numeric expression that specifies the number of records have been matched. or by connecting to a file. and creates a Shapefile containing the results of the BatchMatch.pmd 54 10/28/2004. The members of the collection are the names of the StreetTable fields to write to outputTable. 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. dataConnection. object An object expression that evaluates to an object in the Applies To list. specify the field in the Geocoder object’s BatchMatchVariable field property dataConnection A DataConnection object whose Database property contains the location in which to write outputTable. 54 MapObjects Programmer’s Reference Example See BarHeight Property BatchMatch Method Applies To Geocoder Object Description This method matches all the addresses in a Table. see the Table Object page for more information. streetFields An object expression that evaluates to a MapObjects Strings object. If there is an additional field used for matching. such as ZIP or city name. outputTable A string expression that represents the name of the shapefile containing the results of the BatchMatch method action. addressField. addressTable An object expression that evaluates to a Table that contains addresses. 10:00 AM . Remarks The addressTable can be created either within MapObjects. ProgrammersReference. The addressField is the field that is parsed by the Standardizer object. paste the code into the Declarations section of a form that contains a CommonDialog named CommonDialog1. If an address is not matched (U in the ‘Status’ field). See Also Table Object. ‘If a field is not available.Standardizer Dim dcx As New MapObjects2. StreetTable Property.DataConnection ‘Set global variables with field names in the StreetTable ‘Modify if fields names in StreetTable are different. ‘Status’ and ‘Score’ are also added to the outputTable.e. 10:00 AM . MinimumMatchScore Property Example This example demonstrates how to use the BatchMatch method and set the BatchMatchVariableField property to match a file of addresses. The ‘Status’ Field shows the match status of the address. 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 ‘Score‘ Field stores the MatchScore of each address. whose ‘Shape’ field contains Point features. and a CommandButton named Command. a Map named Map1. Addresses with a MatchScore below the MinimumMatchScore are not matched. BatchMatchVariable Property.pmd 55 10/28/2004. Fields named ‘Side’. giving you information about the matching process. In a range of 0 to 100. plus any specified streetFields to the outputTable. Note that the name of the Table object’s Database property for the dBASE Driver DataSource is hard-coded in Command1_Click. A Geocoder used for batch matching must be valid. specify an empty Strings object or Nothing as the argument. These Point features represent the Location of each address which is matched. i. MapObjects adds all addressTable fields. It is either M (successfully matched) or U (not matched). set it with an empty string ProgrammersReference. MatchWhenAmbiguous Property. The BatchMatch method returns the number of addresses that have been matched. Press F5. MapObjects Programmer’s Reference 55 The results of the BatchMatch can be found in the outputTable. then click Addresses to specify the name of a dBASE file that contains a list of addresses. Option Explicit Dim geo As New MapObjects2. must be set up in a similar way as a Geocoder used with the LocateCandidate method. To try this example.Geocoder Dim stan As New MapObjects2. Try different values in the MinimumMatchScore and MatchWhenAmbiguous properties and see the different results. The outputTable is a shapefile. 100 signifies a highly confident or exact match. the ‘Score’ Field will be blank and the Value of the ‘Shape’ Field will be Nothing. Substitute appropriate values for all the data paths. You should ensure you have set an appropriate Data Source Name in using the ODBC utility in Windows Control Panel. If you do not want to add any streetFields. the dataConnection param- eter of the BatchMatch method determines where the outputTable will be located. FileName = “” . Len(ft) . 56 MapObjects Programmer’s Reference Private Const m_FromLeft = “L_f_add” Private Const m_FromRight = “R_f_add” Private Const m_ToLeft = “L_t_add” Private Const m_ToRight = “R_t_add” Private Const m_PreDir = “Prefix” Private Const m_PreType = “Pre_type” Private Const m_StreetName = “Name” Private Const m_StreetType = “Type” Private Const m_SufDir = “Suffix” Private Const m_LeftZone = “Zipl” Private Const m_RightZone = “ZipR” Private Sub Command1_Click() Dim AddressTable As New MapObjects2.Database = Left(fn.MapLayer Dim ft As String.dbf” .MatchWhenAmbiguous = True With CommonDialog1 .FileTitle fn = .Database = “CustomerDB” ‘name of ODBC DataSource AddressTable.FileName End With ‘This example uses an AddressTable from an ODBC DataSource.MinimumMatchScore = 70 geo. ODBC) You can access other data ‘sources to create a MapObjects2.CancelError = True On Error Resume Next .Len(ft) .dbf” . for details see ‘the online help.name = Left(ft. Len(fn) .Table object.Number = cdlCancel Then Unload Me End If ft = .Table Dim ml As New MapObjects2.pmd 56 10/28/2004. ‘If using an ODBC DataSource to create an AddressTable you ‘should ensure that you have an appropriate DataSourceName set ‘(see Windows Control Panel.DefaultExt = “*. AddressTable. 10:00 AM .Filter = “dBASE (*.ShowOpen If Err.dbf)|*.4) ‘ FileTitle without extension dcx. fn As String Dim count As Integer geo.1) ‘where to ProgrammersReference. SymbolType = moPointSymbol .Standardizer = stan ‘Change the paths below to ones appropriate for your data dc.IntersectionStandardizingRules = “C:\Program Files _ \ESRI\MapObjects2\GeoRules\us_intsc.GeoDataset = dcx. MapObjects Programmer’s Reference 57 ‘write outputTable If AddressTable.Connect Then geo.Layers.Layers(“results”).Color = moRed . _ “results”. i As Integer Dim name As String ‘Set up Standardizer ‘Change the paths below to ones appropriate for your data stan.FindGeoDataset(“results”) Map1.pmd 57 10/28/2004.Database = “C:\Program Files\ESRI\MapObjects2 _ \Samples\Data\Redlands” ProgrammersReference.Refresh End If Else MsgBox “Didn’t match addresses in dbf file” End If End Sub Private Sub Form_Load() Dim dc As New MapObjects2. Nothing) MsgBox “Successfully geocoded “ & count & “ addresses!” Debug.Add ml With Map1. “ADDRESS”.name <> “” And dcx.stn” stan.Print AddressTable.BatchMatch(AddressTable.count If count <> 0 Then Set ml.BatchMatchVariableField(“RightZone”) = “ZIPr” count = geo.Records.BatchMatchVariableField(“LeftZone”) = “ZIPl” geo. dcx.DataConnection Dim gd As Object Dim lyr As New MapLayer Dim f.Symbol .Style = moCircleMarker End With Map1. 10:00 AM .StandardizingRules = “C:\Program Files\ESRI\MapObjects2 _ \GeoRules\us_addr.stn” Set geo. MatchVariableIntersectionLink(“StreetType”.MatchVariableField(“ToLeft”) = m_ToLeft geo.MatchVariableIntersectionLink(“PreDir”.FindGeoDataset(“redlands”) lyr.MatchVariableIntersectionLink(“StreetName”.IntersectionMatchRules = “C:\Program Files\ESRI\MapObjects2 _ \GeoRules\us_intsc1.MatchVariableField(“PreDir”) = m_PreDir geo.Layers.mat” ‘ Link the Match Variables to fields in the StreetTable geo.GeoDataset = gd lyr.pmd 58 10/28/2004.MatchVariableField(“PreType”) = m_PreType geo._ mgLinkPrimary) = “StreetType1” geo. 10:00 AM .MatchVariableField(“StreetType”) = m_StreetType geo.Connected Then MsgBox “dc.MatchVariableField(“FromLeft”) = m_FromLeft geo.MatchVariableField(“SufDir”) = m_SufDir geo. _ mgLinkPrimary) = “StreetName1” geo. _ mgLinkPrimary) = “PreType1” geo.Color = moBlue Map1. _ mgLinkPrimary) = “LeftZone1” ProgrammersReference.MatchVariableField(“ToRight”) = m_ToRight geo.MatchVariableIntersectionLink(“LeftZone”.MatchRules = “C:\Program Files\ESRI\MapObjects2\ _ GeoRules\us_addr1.MatchVariableField(“RightZone”) = m_RightZone ‘ Link the intersection group 1 variables geo.connected error” End End If ‘Set up the StreetTable Set gd = dc.StreetTable = gd ‘Set up the match rules and variables ‘Change the paths below to ones appropriate for your data geo. _ mgLinkPrimary) = “SufDir1” geo.Symbol.Add lyr geo. 58 MapObjects Programmer’s Reference dc.MatchVariableField(“FromRight”) = m_FromRight geo.MatchVariableField(“StreetName”) = m_StreetName geo.MatchVariableIntersectionLink(“PreType”. _ mgLinkPrimary) = “PreDir1” geo.Connect If Not dc.MatchVariableField(“LeftZone”) = m_LeftZone geo.MatchVariableIntersectionLink(“SufDir”.mat” geo. ”.pmd 59 10/28/2004.” End If End If ‘Set search queries Dim queries As New MapObjects2.”. “”. _ mgLinkSecondary) = “StreetType2” geo. vbCritical End End If If Not geo. _ mgLinkSecondary) = “LeftZone2” geo.Strings queries.MatchVariableIntersectionLink(“LeftZone”.MatchVariableIntersectionLink(“SufDir”. MapObjects Programmer’s Reference 59 geo. _ mgIndexTypeNormal) Then MsgBox “Cannot build geocoding index. _ mgLinkSecondary) = “SufDir2” geo.SearchQueries = queries Command1.Add “SN? & ZN” queries.BuildIndices(True) Then MsgBox “Cannot build geocoding index. vbCritical End Else MsgBox “Indices are built. _ mgLinkSecondary) = “StreetName2” geo.MatchVariableIntersectionLink(“RightZone”. _ mgLinkSecondary) = “PreType2” geo.AddIndex(m_StreetName.Add “SN?” Set geo. _ mgIndexExists Then If Not geo.Caption = “Addresses” ProgrammersReference.AddIndex(m_LeftZone.MatchVariableIntersectionLink(“PreType”. _ mgLinkPrimary) = “RightZone1” ‘ Link up intersection group 2 variables geo. 10:00 AM .MatchVariableIntersectionLink(“StreetName”.MatchVariableIntersectionLink(“PreDir”.IndexStatus = MapObjects2. _ mgLinkSecondary) = “PreDir2” geo.”. m_RightZone. vbCritical End End If If Not geo. _ mgLinkSecondary) = “RightZone2” ‘Build indices if haven’t If Not geo.IndexStatusConstants.MatchVariableIntersectionLink(“StreetType”.MatchVariableIntersectionLink(“RightZone”. mgIndexTypeSoundex) Then MsgBox “Cannot build geocoding index. the BatchMatchVariableField property returns False. ProgrammersReference.pmd 60 10/28/2004. 60 MapObjects Programmer’s Reference End Sub BatchMatchVariableField Property Applies To Geocoder Object Description Returns or sets field names in addition to the addressField specified in the Geocoder object’s BatchMatch method.BatchMatchVariableField [ = fieldName] The BatchMatchVariableField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. If the Field specified in the addressField parameter is not valid. FieldValue Property Example See BatchMatch Method BeforeLayerDraw Event Applies To Map Object Description Occurs when a Map starts to draw a specified layer. StreetTable Property. Unlike the addressField. for example a separate Field in the addressTable such as ZIP or city name. if no additional Table Fields are required for the batch match. you do not need to set a BatchMatchVariableField. Syntax object. Remarks The addressField parameter of the BatchMatch method defines the Field that is parsed by a Standardizer object. This is an additional field used for matching. See Also BatchMatch Method. this field will not parsed with a Standardizer object. fieldName A string expression that specifies the name of the field in the address table for batch matching. If there is an additional Field which is required for matching. This property is optional. this Field needs to be specified in the object’s BatchMatchVariableField property. 10:00 AM . such as ZIP or city name. Y As Single) ProgrammersReference. Prior to drawing each layer on the Map.FullExtent. the code determines which of two layers to draw based on how close you’ve zoomed in to the map.Extent. Shift As Integer. AfterTrackingLayerDraw Event. Option Explicit Private Sub Command1_Click() Map1. To try this example.Visible = False End If End Sub Private Sub Map1_MouseDown(Button As Integer. See Also AfterLayerDraw Event. ByVal hDC As Stdole.Layers(1).FullExtent End Sub Private Sub Map1_BeforeLayerDraw(ByVal index As Integer. 10:00 AM . ByVal hDC _ As stdole.Visible = False Map1.OLE_HANDLE) The BeforeLayerDraw event syntax has these parts: Part Description object An object expression that evaluates to a Map. Remarks You can use the hDC to refer to the handle for an object’s device context.Layers(0).Visible = True Else Map1.Layers(0). and then press F5. X _ As Single.Width / 4 Then Map1. MapObjects Programmer’s Reference 61 Syntax Private Sub object_BeforeLayerDraw(ByVal index As Integer. This provides a value to pass to Windows API calls.OLE_HANDLE) ‘ greater detail in layers(1) If Map1.Extent = Map1.Visible = True Map1. hDC A handle provided by the Microsoft Windows operating environment to the device context of the Map. Click on the map to zoom in or press Command1 to zoom to the full extent of the map. one with greater detail than another.Width < Map1. index An integer that uniquely identifies a member of the Layers collection. 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. BeforeTrackingLayerDraw Event Example This example illustrates when the BeforeLayerDraw Event occurs.Layers(1).pmd 61 10/28/2004. 62 MapObjects Programmer’s Reference Dim rect As MapObjects2.5 Map1.AddItem “Solid Line” ProgrammersReference. AfterTrackingLayerDraw Event Example This example illustrates when the BeforeTrackingLayerDraw Event occurs. 10:00 AM .Extent rect. AfterLayerDraw Event.Point List1. The example traces the path of a GeoEvent initially added to the TrackingLayer at the center of the Map’s extent.OLE_HANDLE) The BeforeTrackingLayerDraw event syntax has these parts: Part Description object An object expression that evaluates to a Map.Caption = “Full Extent” End Sub BeforeTrackingLayerDraw Event Applies To Map Object Description Occurs when a Map starts to display the GeoEvent objects on its TrackingLayer. 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. Clicking on the Map designates a new location for the GeoEvent. hDC A handle provided by the Microsoft Windows operating environment to the device context of the Map. Click on the map to specify a new location.Rectangle Set rect = Map1. To try this example. Remarks You can use the hDC to refer to the handle for an object’s device context.pmd 62 10/28/2004.ScaleRectangle 0. Syntax Private Sub object_BeforeTrackingLayerDraw(ByVal hDC As Stdole. This provides a value to pass to Windows API calls. Change the symbol of the trail by selecting from the list.Extent = rect End Sub Private Sub Form_Load() Command1. See Also BeforeLayerDraw Event. The code in the BeforeTrackingLayerDraw event draws the trail. Option Explicit Dim ln As New MapObjects2.Line Private Sub Form_Load() Dim pt As MapObjects2. and then press F5. Symbol sym.ToMapPoint(X. Shift As Integer.ListIndex sym.Event(0) evpt.AddItem “Dash-Dot Line” List1. MapObjects Programmer’s Reference 63 List1.X evpt.Color = moBlue Map1.Extent.TrackingLayer.Add newpt ln.AddItem “Dashed Line” List1.Style = List1.pmd 63 10/28/2004.Center Map1.Y = .Add pts Map1. Y As Single) Dim evpt As New MapObjects2.Point Dim newpt As New MapObjects2. sym End If End Sub Private Sub Map1_MouseDown(Button As Integer.Parts.AddItem “Dash-Dot-Dot Line” List1.Y End With Dim pts As New MapObjects2.X.Points pts.AddEvent pt. 0 End Sub Private Sub Map1_BeforeTrackingLayerDraw(ByVal hDC As _ stdole. Y) With Map1.AddItem “Dotted Line” List1. ProgrammersReference.Y Map1. 10:00 AM . X _ As Single.SymbolType = moLineSymbol sym.ListIndex = 0 Set pt = Map1. newpt.Event(0).Add evpt pts.Point Set newpt = Map1.TrackingLayer.OLE_HANDLE) If Not ln Is Nothing Then Dim sym As New MapObjects2.Refresh True End Sub BorderStyle Property Applies To Map Object Description Returns or sets the border style for a Map.DrawShape ln.TrackingLayer.MoveTo newpt.TrackingLayer.X = . BorderStyle = 0 Command1.Caption = “No Border” End Sub Bottom Property Applies To Ellipse Object.BorderStyle = 1 Command1. Settings The BorderStyle property settings for a Map control are: Setting Description 0 None.pmd 64 10/28/2004. Option Explicit Private Sub Command1_Click() If Map1.Caption = “No Border” End If End Sub Private Sub Form_Load() Command1. as described in Set- tings. Rectangle Object Description Returns or sets the distance between the internal bottom edge of an object and the top edge of its container. To try this ex- ample.Caption = “Border” Else Map1. See Also Appearance Property. 1 (Default) Fixed Single. value A value or constant that determines the border style. Scrollbars Property Example This example uses the BorderStyle property to toggle the border of a Map. 64 MapObjects Programmer’s Reference Syntax object.BorderStyle = 1 Then Map1. BackColor Property. 10:00 AM .BorderStyle [= value] The BorderStyle property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. ProgrammersReference. 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. Rectangle Private mbTextAlreadyDisplayed As Boolean Private Sub Map1_AfterLayerDraw(ByVal index As Integer. Option Explicit Dim oRect As New MapObjects2.Point Dim oFont As New StdFont If Not mbTextAlreadyDisplayed Then oFont. oSymbol oTextsymbol. Press F5 and then click-drag a Rectangle after the MapLayers finish drawing.Bottom End With ‘draw the rectangle and the text oSymbol.TextSymbol Dim oPoint As New MapObjects2.OLE_HANDLE) Dim oSymbol As New MapObjects2.Height = oRect. 10:00 AM . Left Property Example This example uses the Bottom property to provide a coordinate point to use to position graphic text on a map. ByVal hDC As Stdole.pmd 65 10/28/2004.Height ‘text height in map units ProgrammersReference.Style = moTransparentFill Map1. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. See Also Top Property.x = oRect. ByVal _ canceled As Boolean.y = oRect.VerticalAlignment = moAlignBaseline End With ‘derive point location from the rectangle’s corner With oPoint .HorizontalAlignment = moAlignLeft . value A numeric expression specifying distance.Left . MapObjects Programmer’s Reference 65 Syntax object.DrawShape oRect.Bottom [= value] The Bottom property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.name = “Arial” With oTextsymbol Set .Font = oFont ‘ This assigns the Font object ‘set the alignment properties of the Textsymbol object . To try this example.Symbol Dim oTextsymbol As New MapObjects2. oPoint. The integer must be a number from 0 to one less than the value of the renderer’s BreakCount property. Shift As Integer.DrawText “MapObjects2”. value A numeric expression that evaluates to the upper bound of the category or class of data.Refresh End Sub Break Property Applies To ClassBreaksRenderer Object. x _ As Single. y As Single) Set oRect = Map1. a ListBox named List1. click the button to see the results. and a Map named Map1 that contains one MapLayer with polygon features.TrackRectangle mbTextAlreadyDisplayed = False Map1.pmd 66 10/28/2004. paste the code into the Declarations section of a form containing a CommonDialog control. 10:00 AM . oTextsymbol mbTextAlreadyDisplayed = True End If End Sub Private Sub Map1_MouseDown(Button As Integer. 66 MapObjects Programmer’s Reference Map1. (Data type is Double.Break( index) [= value] The Break property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. ZRenderer Object Description Returns or sets the upper bound of a category or class of data in a renderer object. To try this example.) See Also BreakCount Property 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. index An integer that specifies a category. Option Explicit Private Sub Command1_Click() ProgrammersReference. Syntax object. Only those break values that are within the data range are added to the renderer. a CommandButton named Command1. Press F5 and select the name of a numeric field appropriate to your data from the list. RampColors moYellow.ClassBreaksRenderer Dim oStats As New MapObjects2.Text).BreakCount .Records.pmd 67 10/28/2004.Field For Each oField In Map1. MapObjects Programmer’s Reference 67 Dim oClassRend As New MapObjects2.(oStats.Layers(0).Statistics Dim i As Integer Dim fBreakVal As Double ‘ Appropriate logical tests for the chosen maplayer should be ‘inserted below.StdDev Next .Fields List1.Records.Records. _ CalculateStatistics(List1.Layers(0).Text Set oStats = Map1.BreakCount + 1 .Records.Fields(List1.Renderer = oClassRend End With Map1.Break(. fBreakVal End If fBreakVal = fBreakVal + oStats.Type = _ moString Then With oClassRend . ‘ but only add those breaks that are within the range of values fBreakVal = oStats. If Not Map1.BreakCount = .Layers(0).name Next End Sub ProgrammersReference.Field = List1.Refresh Else MsgBox “Data type not suitable: “ & _ Map1.Type End If End Sub Private Sub Form_Load() Dim oField As MapObjects2.SymbolType = moFillSymbol .Max Then .Mean .StdDev * 3) For i = 0 To 6 If fBreakVal >= oStats.Min And fBreakVal <= oStats.Text) ‘ calculate breaks away from the mean in both directions.1) = fBreakVal Debug. 10:00 AM .AddItem oField.Layers(0).Layers(0). moBlue Set Map1.Print “Break Val = “.Fields(List1.Text). extent]) The Buffer method syntax has these parts: Part Description resultShape An object expression that evaluates to a shape object. 10:00 AM .Buffer (bufferDistance [.BreakCount [= value] The BreakCount property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list value An integer that species the number of breaks between categories or classes of data. 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. 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. ProgrammersReference. Will contain the resulting buffered shape. Syntax Set resultShape = object. Polygon Object. the shape’s Z values are used. For a ZRenderer object. 68 MapObjects Programmer’s Reference BreakCount Property Applies To ClassBreaksRenderer Object.) Remarks There is always one more category than the value of BreakCount. See Also Break Property Example See Break property Buffer Method Applies To Point Object. Points Collection. Rectangle Object. Line Object. (Data type is Integer. Syntax object.pmd 68 10/28/2004. pmd 69 10/28/2004. and choose an option. The user point and the new shape generated by the buffer operation are added to the tracking layer as GeoEvents. it will have a smaller radius).Buffer(Text1.AddEvent(pt. Remarks A negative buffer distance can be specified for Rectangle. 3) ProgrammersReference.TrackingLayer. rectangle. A buffer distance of zero on a Point. bufferDistance A numeric expression that represents the distance by which object should be buffered.TrackingLayer. If you set a buffer distance of zero on an Ellipse object. Points or Line objects. Also add a Textbox named Text1. Try changing the value in the textbox. or track a line. Polygon and Ellipse objects only. however a self-intersecting Line may be buffered.AddEvent(buffPt. This distance must be positive for Point. and 5 OptionButtons named Option1 to Option5. the resulting buffered shape will be inset from the input object (i. rectangles. polygons and ellipses. y As Single) ‘Point buffering If Option1. Option Explicit Private Sub Map1_MouseDown(Button As Integer. 0) Set buffPt = pt. Points object or Line object. ellipse or polygon. extent An object expression that evaluates to a Rectangle object. See Also Difference Method Example This example uses the Buffer method to allow the user to buffer points. and is used.Value Then Dim pt As New MapObjects2. y) Set eventPt = Map1. the resultShape will be a Polygon clone of that ellipse. paste the code into the Declara- tions section of a form containing a Map named Map1 that has at least one MapLayer. 10:00 AM .Text.ToMapPoint(x. MapObjects Programmer’s Reference 69 object An object expression that evaluates to an object in the Applies To list. Press F5. Buffering of a self-intersecting Polygon is not supported. Map1. In this case. Rectangle or Polygon object will not set the resultShape object. To try this example.GeoEvent Dim buffPt As New MapObjects2.e. lines. x _ As Single.Polygon Dim buffEventPt As New MapObjects2. This is the object which is to be buffered. then click on the map to create a point.FullExtent) Set buffEventPt = Map1. Points. This Rectangle should entirely contain the object’s extent.Point Dim eventPt As New MapObjects2. If a negative number is specified for a Point object.GeoEvent Set pt = Map1. then it is treated as a positive number of the same absolute value. Line. Shift As Integer. TrackingLayer.AddEvent(buffLine.GeoEvent Set poly = Map1.GeoEvent Set rect = Map1. 2) Set buffRect = rect.TrackPolygon Set eventPoly = Map1. 2) Set buffPoly = poly. 70 MapObjects Programmer’s Reference ‘Line buffering ElseIf Option2.TrackingLayer.Value Then Dim poly As New MapObjects2.Polygon Dim buffEventRect As New MapObjects2.AddEvent(rect. Map1.TrackRectangle ProgrammersReference.Polygon Dim buffEventPoly As New MapObjects2.TrackRectangle Set eventRect = Map1.GeoEvent Set line = Map1.Buffer(Text1.FullExtent) Set buffEventRect = Map1.Polygon Dim buffEventElli As New MapObjects2.TrackingLayer.TrackingLayer.TrackingLayer.TrackingLayer.Ellipse Dim eventElli As New MapObjects2.AddEvent(buffRect.Buffer(Text1. 3) ‘Ellipse buffering ElseIf Option5.GeoEvent Dim buffPoly As New MapObjects2.GeoEvent Set arect = Map1. Map1. 3) ‘Polygon buffering ElseIf Option4.Rectangle Dim elli As New MapObjects2.Buffer(Text1. Map1.Rectangle Dim eventRect As New MapObjects2.FullExtent) Set buffEventLine = Map1.AddEvent(poly. 10:00 AM .Text.Text.GeoEvent Dim buffRect As New MapObjects2.Polygon Dim eventPoly As New MapObjects2. 1) Set buffLine = line.AddEvent(buffPoly.pmd 70 10/28/2004.FullExtent) Set buffEventPoly = Map1.Value Then Dim arect As New MapObjects2.TrackLine Set eventLine = Map1.Text.line Dim eventLine As New MapObjects2. 3) ‘Rectangle buffering ElseIf Option3.GeoEvent Dim buffElli As New MapObjects2.Polygon Dim buffEventLine As New MapObjects2.AddEvent(line.Value Then Dim line As New MapObjects2.Value Then Dim rect As New MapObjects2.GeoEvent Dim buffLine As New MapObjects2. SymbolType = moFillSymbol .Color = moRed .Style = moTriangleMarker .Style = moGrayFill .Right = arect.TrackingLayer.AddEvent(buffElli.SymbolType = moPointSymbol . 3) End If End Sub Private Sub Form_Load() Option1.Symbol(1) .TrackingLayer.Symbol(0) .Left = arect. Map1.FullExtent) Set buffEventElli = Map1.OutlineColor = moRed End With With Map1.Bottom = arect.TrackingLayer.Color = moRed .SymbolCount = 4 With Map1. MapObjects Programmer’s Reference 71 elli.Text = “100” Map1.TrackingLayer.Color = moRed .Right Set eventElli = Map1.pmd 71 10/28/2004.Size = 3 End With With Map1.Caption = “Line” Option3.AddEvent(elli.SymbolType = moLineSymbol .TrackingLayer. 2) Set buffElli = elli.Caption = “Polygon” Option5.TrackingLayer.Caption = “Ellipse” Text1.Caption = “Point” Option2.Bottom elli.Color = moBlue .Symbol(3) .Size = 3 End With With Map1.Top = arect.OutlineColor = moBlue End With End Sub ProgrammersReference.Caption = “Rectangle” Option4. 10:00 AM .TrackingLayer.Top elli.Style = moGrayFill .Text.Buffer(Text1.Left elli.SymbolType = moFillSymbol .Symbol(2) . Syntax object. The two files are stored in the same folder as the GeoDataset. BuildIndex should not be used on a MapLayer based on ARC/INFO Coverages. 10:00 AM . or an index for a field of a PlaceNameTable of a PlaceLocator object. False The object’s index will not rebuild if it already exists. force) The BuildIndex method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. PlaceNameTable Property ProgrammersReference. When applied to a MapLayer object based on a shapefile. 72 MapObjects Programmer’s Reference BuildIndex Method Applies To MapLayer Object. Settings The settings for force are: Setting Description True The object’s index rebuilds regardless of its previous state.BuildIndex( [field]. it returns False. However. This parameter is only valid when object is a PlaceLocator. and the SearchByDistance method.sbn and . using the SearchShape method. PlaceLocator Object Description Builds a spatial index on a MapLayer object that is based on a Shapefile GeoDataset. force A boolean expression that determines whether MapObjects will build an index regardless of the previous state of the index. as described in Settings. The spatial index enhances performance when zooming. MapObjects does make use of spatial indices built in the original applications for these data sources. Note that building an index may take an appreciable amount of time. field A string expression that specifies the name of a field in a PlaceNameTable. Otherwise. panning. SDE layers. 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: . or CAD files.pmd 72 10/28/2004.sbx. See Also Indexed Property. Remarks The BuildIndex method returns True if the index built successfully. object An object expression that evaluates to an object in the Applies To list.Layers(0).pmd 73 10/28/2004.Caption = “Build Index” 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.BuildIndices ( force ) The BuildIndices Method syntax has these parts: Part Description variable A boolean expression that indicates whether the indices are built success- fully. Press F5. and a command button called Command1. and a Map named Map1 that has at least one MapLayer. then click the button.Layers(0).Layers(0). ProgrammersReference. paste the code into the Declarations section of a form containing a CommonDialog Control named Common1.Indexed Then If Map1. To try this example.Layers(0).name & “ has an existing index. Syntax Set variable = object.” End If End Sub Private Sub Form_Load() Command1. MapObjects Programmer’s Reference 73 Example This example uses the Indexed property and BuildIndex method to add an index to the first MapLayer in a map control. 10:00 AM .name Else MsgBox “No index Built” End If Else MsgBox “Layer “ & Map1.BuildIndex(False) Then MsgBox “Index Built for layer: “ & Map1. Option Explicit Private Sub Command1_Click() If Not Map1. ProgrammersReference. by using the AddIndex method. AddIndex Method Example See AddIndex method CalculateStatistics Method Applies To Recordset Object Description Creates a Statistics object whose statistical properties you can return. The BuildIndices method returns True if the index was built successfully. False The object’s indices will not rebuild if the index file already exists. or multiple indices. 10:00 AM . it returns False. Use the Geocoder object’s IndexStatus method to evaluate the status of the index. on match variables of the StreetTable of a Geocoder. An index file with a . Syntax Set variable = object. as described in Settings. 74 MapObjects Programmer’s Reference force A boolean expression that evaluates whether MapObjects will build the indices regardless of the previous state of the indices. Note that building the indices may take an appreciable amount of time. Field must contain numeric values.CalculateStatistics( fieldname) The CalculateStatistics method syntax has these parts: Part Description variable An object expression that evaluates to a Statistics object. object An object expression that evaluates to the name of an open Recordset. Settings The settings for force are: Setting Description True The object’s indices rebuild regardless of its previous state.gcd file extension will be created in the workspace of the StreetTable’s GeoDataset if the indices are built successfully. The indices must be specified before building. See Also IndexStatus Method. Otherwise. Remarks This method builds a geocoding index.pmd 74 10/28/2004. fieldname A string expression that evaluates to the name of the Field in the Recordset for which to calculate statistics. Caption = “Mean” Label1(3).Top = Label2(i . Load Label1(i) Load Label2(i) ‘ Set the location of the new option button. two Label control arrays named Label1() and Label2().Caption = “” For i = 1 To 4 ‘ Create four more instances of Label1 and Label2. Max. 10:00 AM . MapObjects Programmer’s Reference 75 Remarks The CalculateStatistics method calculates statistics for a Field whose records contain non- null numeric values only.1).Top = Label1(i .pmd 75 10/28/2004. StdDev. Label1(i).ListIndex)) Label2(0) = oStats.Mean Label2(3) = oStats.List(List1. To try this example.Min Label2(1) = oStats.Caption = “StdDev” Label1(4).StdDev ProgrammersReference.Statistics Set oStats = Map1. Press F5 and click the field name in the list to see the statistics for the field. and Sum properties to report statistics for a numeric field. and a Map named Map1 that contains one MapLayer that has at least one numeric field.Top + Label2(0).Max Label2(2) = oStats.Top + Label1(0).CalculateStatistics _ (List1. Option Explicit Private Sub Form_Load() Dim i As Integer Label1(0). The code in Form_Load will create additional instances.Caption = “Sum” End Sub Private Sub List1_Click() Dim oStats As MapObjects2.Visible = True Next i Label1(0).Caption = “Max” Label1(2).AutoSize = True Label2(0).Visible = True Label2(i).Layers(0).Height + 40 Label2(i). Mean. paste the code into the Declarations section of a form containing a List control named List1. To create the Label control arrays.1).Records. but you should align Label1(0) with Label2(0) vertically.Caption = “Min” Label1(1).Height + 40 Label1(i). See Also Statistics Object Example This example uses the Min. set the Index property of each Label control to 0.AutoSize = True Label2(0). AfterTrackingLayerDraw Event.Records. ByVal hDC As Stdole.pmd 76 10/28/2004. moCancelMap 1 (Default).Sum End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer. 10:00 AM . Only those features drawn before the user pressed the ESC key will be visible.Layers(0).Field For Each oField In Map1.CancelAction [= action] ProgrammersReference.AddItem oField. the application ignores the ESC key. See Also AfterLayerDraw Event.Value) > vbNull And VarType(oField.Fields ‘fields that only contain numeric values: If VarType(oField. ByVal _ canceled As Boolean.Name End If Next End Sub CancelAction Constants MapObjects defines the following constants for use with the Map object’s CancelAction property to control what action to take if the application receives an ESC keypress. Map Object 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.OLE_HANDLE) Dim oField As MapObjects2. moCancelLayer 2 Your application will stop drawing the layer it’s currently drawing and start to draw any remain- ing layers in the MapLayers collection. Your application will stop drawing all layers. Constant Value Description moCancelNone 0 None. No action occurs.Value) _ < moString Then List1. Syntax object. 76 MapObjects Programmer’s Reference Label2(4) = oStats. ListIndex End Sub Private Sub Command1_Click() Map1. as described in Settings.FullExtent End Sub Private Sub Form_Load() Combo1. and then press F5. Change the CancelAction setting in the ComboBox to see what effect a different CancelAction setting has.AddItem “None” Combo1. Zoom in?” _ .CancelAction = Combo1. While the map is drawing. vbYesNo) If response = vbYes Then Dim rect As New MapObjects2. 10:00 AM . See Also DrawingCancelled Event Example This example demonstrates the role of the value of the CancelAction property if the user presses ESC while the map is drawing. action A constant or value corresponding to the type of CancelAction you to take when the user presses the ESC key.AddItem “Layer” Combo1. a CommandButton named Command1 and a Map named Map1 that contains more than one MapLayer. To try this example. press the ESC key. Use Command1 to zoom to the full extent of the map.CancelAction = moCancelMap End Sub Private Sub Map1_DrawingCanceled() Dim response As Variant response = MsgBox(“The map is in an incomplete state.pmd 77 10/28/2004.Rectangle Set rect = Map1. Settings The settings for action are CancelActionConstants. MapObjects Programmer’s Reference 77 The CancelAction property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.ListIndex = 1 Map1.Extent ProgrammersReference. Option Explicit Private Sub Combo1_Click() Map1.AddItem “Map” Combo1. paste the code into the Declara- tions section of a form containing a ComboBox named Combo1.Extent = Map1. Edit Property. See Also Recordset Object. and then press F5. and Updatable Property Example This example uses the Edit method and the Updatable property in the context of a simple record editing application. Calling MoveNext before a call to Update has the same effect as calling CancelUpdate. Note that the example determines the number of records by iterating through the Recordset. The code also demonstrates how to use the CancelUpdate method to back out of making a change. Syntax object. a TextBox named Text1.Text = recset.pmd 78 10/28/2004. Enter the new value in the text box and press the Change button.Recordset Dim TotalRecs As Integer Private Sub Combo1_Click() Text1. Remarks The CancelUpdate method cancels any updates made after a call to Edit or AddNew but before a call to the Update method. Use the EditMode property to determine if there is a pending operation that can be canceled.List(Combo1. a ComboBox named Combo1. paste the code into the Declarations section of a form containing a CommandButton control named Command1. Choose a Field whose values you want to change.ScaleRectangle 0. 10:00 AM . the first time you change a record the code demonstrates the EditMode property.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.1 Map1. For the CommandButton. In addition. EditMode Property. 78 MapObjects Programmer’s Reference rect. You can iterate through the Recordset with the buttons named Next and Previous. To try this example. Dim editbufr As Variant Dim recset As MapObjects2. and a Map named Map1 that has a MapLayer.CancelUpdate The CancelUpdate method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object.Value ProgrammersReference.ListIndex)). set its Index property to 0 in the Control Properties dialog box to create a control array of one element.Fields(Combo1. vbYesNo + vbInformation.Value recnum = recnum .Edit .Enabled = True End If Map1.Update GetEditMode Else recset.1 Then Command1(0).Value recnum = recnum + 1 Command1(1).MovePrevious Text1.Refresh True End If Case 1 ‘Previous If recnum > 0 Then recset.1 Command1(0).Fields(Combo1.ListIndex)) Select Case Index Case 0 ‘Next If recnum < TotalRecs Then recset. MapObjects Programmer’s Reference 79 End Sub Private Sub Command1_Click(Index As Integer) Static recnum With recset.List(Combo1.Text resp$ = MsgBox(“Are you sure you want to change the value _ ?”.Enabled = False Else Command1(0).Enabled = False Else Command1(1).TrackingLayer.CancelUpdate Text1.Text = .Value = Text1. 10:00 AM .Enabled = True If recnum = 0 Then Command1(1).TrackingLayer.Enabled = True End If Map1. “MapObjects”) If resp$ = vbYes Then GetEditMode ‘demonstrates EditMode property recset.Text = editbufr ProgrammersReference.Enabled = True If recnum = TotalRecs .pmd 79 10/28/2004.Refresh True End If Case 2 ‘Change editbufr = .Value recset.MoveNext Text1.Text = . pmd 80 10/28/2004.Top = Command1(i .Caption = “Change” Set recset = Map1.Top + Command1(0).Records For Each f In recset. ‘ Set the location of the new option button.EditMode Case 0 Msg$ = “No editing operation is in progress. Button$.Layers(0).1).EOF TotalRecs = TotalRecs + 1 ProgrammersReference.ListIndex = 0 ‘count the number of records ctr = 0 Do While Not recset.Name Next f Combo1. Command1(i).Height + 40 Command1(i). “MapObjects” End If Demonstrated = Demonstrated + 1 End Sub Private Sub Form_Load() For i = 1 To 2 ‘ Create two more instances of Command1. 80 MapObjects Programmer’s Reference End If End Select End With End Sub Sub GetEditMode() Static Demonstrated As Integer If Demonstrated < 2 Then Select Case recset.” Button$ = vbInformation Case 1 Msg$ = “Edit in progress” Button$ = vbExclamation Case 2 Msg$ = “AddNew method has been invoked.Caption = “Next” Command1(1). 10:00 AM .AddItem f.Caption = “Previous” Command1(2).Visible = True Next i Command1(0).Fields Combo1.” Button$ = vbExclamation End Select MsgBox Msg$. pmd 81 10/28/2004.Updatable Then Command1(2).Candidate ( index) [= value] The Candidate property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. index A numeric expression that specifies the relative position of a member of the group of Candidate values associated with the Geocoder object. “|”: Score: The matching score in a range of 0 to 100.Value Command1(1). Street side: The side of a centerline in relation to the reference StreetTable where the address is successfully matched to. This ProgrammersReference. value A string expression that specifies the information in a candidate.Fields(Combo1. and blank if it doesn’t apply. Remarks The string returned from this property contains the following fields of information.FlashShape recset. The values are L (left).Value.OLE_HANDLE) Map1.ListIndex)).Fields(“Shape”). Syntax object.Enabled = False End If End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.MoveFirst Text1.Enabled = False If Not recset.List(Combo1. Each field is delimited by a vertical bar. 10:00 AM . 3 End Sub Candidate Property Applies To Geocoder Object Description Returns the information of a candidate address associated with the Geocoder object.MoveNext Loop recset. Index must be a number from 0 to a number that is one less than the value of the Geocoder object’s CandidateCount property. 100 indicates a highly confident or exact match and 0 means the candidate is not a match.Text = recset. MapObjects Programmer’s Reference 81 recset. R (right). Zip Code etc. two TextBoxes named Text1 and Text2.g. set it with an empty string Private Const m_FromLeft = “L_f_add” Private Const m_FromRight = “R_f_add” Private Const m_ToLeft = “L_t_add” Private Const m_ToRight = “R_t_add” Private Const m_PreDir = “Prefix” Private Const m_PreType = “Pre_type” Private Const m_StreetName = “Name” Private Const m_StreetType = “Type” Private Const m_SufDir = “Suffix” Private Const m_LeftZone = “Zipl” ProgrammersReference. 50.Geocoder Dim stan As New MapObjects2. the geocoded point may not be actually placed on the end point if the object’s SqueezeFactor property is set with a value other than 0. Then an address can be geocoded against a selected candidate using and LocateCandidate method.pmd 82 10/28/2004.0 represent the two end points of the arc.0 indicates that the geocoded point is on the mid-point of the arc. and two ListBoxes named List1 and List2. e.. Record number of the StreetTable: This number indicates the record number of the candi- date within the StreetTable. Although 0. the Street Name. paste the code into the Declarations section of a form that contains a Map named Map1. Candidate and CandidateCount properties. GenerateCandidates Property Example This example demonstrates how to review the candidates that a Geocoder finds using the GenerateCandidates method. Substitute appropriate values for the data paths and then press F5. To try this example. Option Explicit Dim geo As New MapObjects2. See Also CandidateCount Property. a CommandButton named Command1. By simple linear interpolation.0 and 100. MatchVariable fields: The values of the MatchVariable or IntersectionMatchVariable fields associated with the StreetTable. two Labels named Label1 and Label2.Standardizer ‘Set global variables with field names in the StreetTable ‘Modify if fields names in StreetTable are different ‘If a field is not available. 10:00 AM . Percentage along the line segment: This value indicates the location of the geocoded point (the candidate’s address location) along a line in terms of percentage. 82 MapObjects Programmer’s Reference information is only available if the address is geocoded against a StreetTable containing left/ right house numbers. Try different values in the SpellingSensitivity property and see the different number of candidates returned. b As Integer Dim s As New MapObjects2.Candidate(i). 10:00 AM . MapObjects Programmer’s Reference 83 Private Const m_RightZone = “ZipR” Private Sub Command1_Click() ‘Locate an address to its best candidate Dim foundLoc As MapObjects2. Multiple best candidates scored _ “ & Left(geo.StandardizeAddress(Text1.Text geoStatus = geo. but none of them _ have score equal or higher than the minimum match score” _ & geo.MinimumMatchScore End Select Label1.Strings ProgrammersReference.Candidate(0). 3) & “ are found.Canididate topic for description.Candidate(0). num = geo.” Case 2 msg = “Successful match.AddItem geo. i As Integer Dim msg As String If stan.GenerateCandidates Select Case geoStatus Case 0 msg = “No candidates re found.CandidateCount If num = 0 Then List1.1 List1.Text) Then stan. 3) & “ is found.AddressLocation Dim geoStatus.AddItem “< No candidates >” Else For i = 0 To num .” Case 3 msg = “One or more candidates are found. One best candidate scored “ _ & Left(geo. ‘ See the Geocoder.Caption = msg ‘show all the candidates in List1 and list the individual ‘item of the first candidate in List2 ‘each component in a candidate is delimited by an “|” symbol.FieldValue(“ZN”) = Text2. Geocoding fails” Case 1 msg = “Successful match. num. i Next i Dim cand As String Dim a.pmd 83 10/28/2004. b) End If ‘Locate to the best candidate If geo. “&”) = 0 Then For i = 0 To geo.1 s.Caption = “Here are the “ & num & “ candidates:” List2.AddItem “” s.IntersectionMatchVariableCount . Len(cand) . Text1. b .Add “Percent” If InStr(1.1 s. 3 End If End If End Sub Private Sub Form_Load() Dim dc As New MapObjects2.pmd 84 10/28/2004. 84 MapObjects Programmer’s Reference cand = geo.1) & vbTab & vbTab & _ Right(cand.Add “Record no” a = 1 For i = 0 To s.Text. i As Integer Dim name As String ProgrammersReference.Item(s.MatchVariable(i) Next i Else For i = 0 To 13 ‘geo.Add “Side” s.FlashShape foundLoc.LocateCandidate(0) Map1.DataConnection Dim gd As Object Dim lyr As New MapLayer Dim f.Add geo.count .Item(i) & vbTab & Mid(cand. 10:00 AM .MatchVariableCount .CandidateCount > 0 Then Set foundLoc = geo.a) a = b + 1 Next i List2. cand.location.Add geo.AddItem “Detail information of the first candidate:” List2.count .Add “Score” s.AddItem s.2 b = InStr(a.Candidate(0) Label2. “|”) List2.AddItem s.IntersectionMatchVariable(i) Next i End If s. a. MatchVariableField(“RightZone”) = m_RightZone ‘ Link the intersection group 1 variables ProgrammersReference.IntersectionMatchRules = “C:\Program Files\ESRI\ _ MapObjects2\GeoRules\us_intsc1.Database = “C:\Program Files\ESRI\ _ MapObjects2\Samples\Data\Redlands” dc.mat” geo.Add lyr geo. MapObjects Programmer’s Reference 85 ‘Set up Standardizer ‘Change the paths below to ones appropriate for your data stan.connected error” End End If ‘Set up the StreetTable Set gd = dc.FindGeoDataset(“Redlands”) Set lyr.MatchVariableField(“ToRight”) = m_ToRight geo.StreetTable = gd ‘Set up the match rules and variables ‘Change the paths below to ones appropriate for your data geo.Symbol.MatchVariableField(“FromLeft”) = m_FromLeft geo.GeoDataset = gd lyr.StandardizingRules = “C:\Program Files\ESRI\ _ MapObjects2\GeoRules\us_addr. 10:00 AM .Standardizer = stan ‘Change the paths below to ones appropriate for your data dc.Connect If Not dc.Color = moBlue Map1.MatchVariableField(“ToLeft”) = m_ToLeft geo.MatchVariableField(“FromRight”) = m_FromRight geo.pmd 85 10/28/2004.MatchVariableField(“StreetName”) = m_StreetName geo.MatchVariableField(“StreetType”) = m_StreetType geo.Layers.Connected Then MsgBox “dc.MatchVariableField(“PreDir”) = m_PreDir geo.MatchRules = “”C:\Program Files\ESRI\MapObjects2\ _ GeoRules\us_addr1.stn” geo.IntersectionStandardizingRules = “C:\Program Files\ESRI\ _ MapObjects2\GeoRules\us_intsc.MatchVariableField(“PreType”) = m_PreType geo.mat” ‘ Link the Match Variables to fields in the StreetTable geo.stn” stan.MatchVariableField(“LeftZone”) = m_LeftZone geo.MatchVariableField(“SufDir”) = m_SufDir geo. MatchVariableIntersectionLink(“LeftZone”. mgLinkPrimary) _ = “PreType1” geo.MatchVariableIntersectionLink(“StreetName”. 10:00 AM . _ mgIndexExists Then If Not geo. vbCritical End ProgrammersReference._ mgIndexTypeNormal) Then MsgBox “Cannot build geocoding index.IndexStatusConstants.”. mgLinkSecondary) _ = “StreetName2” geo.MatchVariableIntersectionLink(“PreType”.”.MatchVariableIntersectionLink(“PreDir”.MatchVariableIntersectionLink(“SufDir”. mgLinkPrimary) _ = “LeftZone1” geo. mgLinkPrimary) _ = “StreetName1” geo. mgLinkSecondary) _ = “SufDir2” geo.pmd 86 10/28/2004.MatchVariableIntersectionLink(“StreetType”.MatchVariableIntersectionLink(“LeftZone”. “”. mgLinkSecondary) _ = “RightZone2” ‘Build indices if haven’t If Not geo. mgLinkSecondary) _ = “PreDir2” geo. mgLinkPrimary) _ = “StreetType1” geo. mgIndexTypeSoundex) Then MsgBox “Cannot build geocoding index.MatchVariableIntersectionLink(“RightZone”.MatchVariableIntersectionLink(“RightZone”. mgLinkPrimary) _ = “PreDir1” geo.MatchVariableIntersectionLink(“SufDir”. mgLinkPrimary) _ = “RightZone1” ‘ Link up intersection group 2 variables geo. 86 MapObjects Programmer’s Reference geo. mgLinkSecondary) _ = “StreetType2” geo.AddIndex(m_StreetName.MatchVariableIntersectionLink(“StreetName”.BuildIndices(True) Then MsgBox “Cannot build geocoding index. vbCritical End End If If Not geo. mgLinkSecondary) _ = “PreType2” geo. mgLinkSecondary) _ = “LeftZone2” geo.”.AddIndex(m_LeftZone.MatchVariableIntersectionLink(“PreDir”. vbCritical End End If If Not geo.IndexStatus = MapObjects2. mgLinkPrimary) _ = “SufDir1” geo.MatchVariableIntersectionLink(“StreetType”.MatchVariableIntersectionLink(“PreType”. m_RightZone. Clear List2.Caption = “Locate Address” Text1.SearchQueries = queries geo. GenerateCandidates Method ProgrammersReference.pmd 87 10/28/2004.Add “SN? & ZN” queries.CandidateCount [= value] The CandidateCount property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Text = “92373” Label1.Clear End Sub CandidateCount Property Applies To Geocoder Object Description Returns the number of the candidate addresses found associated with the Geocoder object.Strings queries. value A variable declared to be of the integer data type that specifies the number of candidate addresses returned from the GenerateCandidates method.Text = “260 Cajon St” Text2. MapObjects Programmer’s Reference 87 Else MsgBox “Indices are built.” End If End If ‘Set search queries Dim queries As New MapObjects2. See Also Candidate Property.Caption = “” Label2. 10:00 AM .Caption = “” End Sub Private Sub Text1_Change() List1.SpellingSensitivity = 80 Command1.Add “SN?” Set geo. Syntax object. Press F5.Floor = Text2. 10:00 AM .Refresh End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ ProgrammersReference.Text changeDepth End Sub Private Sub changeDepth() Text3.5. and try changing the ceiling and floor properties of the rectangle by typing new values in the TextBoxes. To try this example.pmd 88 10/28/2004. and a CommandButton named Command. Also add three TextBoxes named Text1. If the depth of the rectangle is below 0. Option Explicit Dim rectSym As New MapObjects2.Ceiling = Text1.Ceiling [= value] The Ceiling property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. value A numeric expression specifying a height coordinate.Depth Map1. and then pressing the CommandButton. 88 MapObjects Programmer’s Reference Example See Candidate property Ceiling Property Applies To Rectangle Object Description Returns or sets the top height coordinate of a Rectangle object. the rectangle will draw in red. and return- ing the Depth property to check the dimensions of the rectangle.Rectangle Private Sub Command1_Click() drawRect. Syntax object.Text = drawRect. Depth Property Example This example illustrates setting of the Ceiling and Floor properties of a rectangle. paste the code into the Declarations section of a form containing a Map named Map1. Label2 and Label3. Text2 and Text3. and three corresponding Labels named Label1.Symbol Dim drawRect As New MapObjects2.Text drawRect. See Also Floor Property. Text = drawRect.3 .Depth > 0.Style = moGrayFill End With Label1.Left = 0.Size = 2 .Caption = “Set Dimensions” End Sub Center Property Applies To Ellipse Object.Depth Text3.3 .8 .Color = moBlue Else rectSym.Text = drawRect.Color = moRed End If Map1.Right = 0.Caption = “Depth” Text3.Caption = “Floor” Text2.Bottom = 0.pmd 89 10/28/2004.Floor = 0 .Text = drawRect.OLE_HANDLE) If drawRect.Outline = True .Caption = “Ceiling” Text1.5 Then rectSym. MapObjects Programmer’s Reference 89 Stdole.8 .Ceiling Label2. Rectangle Object ProgrammersReference. 10:00 AM . rectSym End Sub Private Sub Form_Load() With drawRect .Enabled = False Command1.Top = 0.Floor Label3.SymbolType = moFillSymbol .Ceiling = 1 End With With rectSym .DrawShape drawRect. 10:00 AM .FullExtent oRect. y The CenterAt method syntax has the following parts: ProgrammersReference.pmd 90 10/28/2004. 90 MapObjects Programmer’s Reference Description Returns the center point of an object as a Point object. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer.CenterAt x. Dismiss the Message Box and pan again.y End With End Sub CenterAt Method Applies To Map Object Description Moves the center of the Map to the specified location. Syntax object. y As Single) Map1.ScaleRectangle (0.x & “.Center MsgBox .Extent = oRect End Sub Private Sub Map1_MouseDown(Button As Integer. Press F5 and click-drag to pan the map.” & . object An object expression that evaluates to an object in the Applies To list. See Also Point Object Example This example uses the Center property to report the coordinates of the center of the map’s current extent. Syntax Set variable = object.Rectangle Set oRect = Map1. Shift As Integer.Extent.5) Map1. To try this example. x _ As Single. Option Explicit Private Sub Form_Load() Dim oRect As MapObjects2.Pan With Map1.Center The Center property syntax has these parts: Part Description variable A variable that has been declared as a Point object. CenterOnAscent [= boolean] The CenterOnAscent property syntax has these parts: ProgrammersReference. The display will refresh and display the position you clicked at the center of the Map. click the Map. x The horizontal coordinate to position at the center of the Map.Rectangle Set rect = Map1.Visible = True Map1.5 Map1.Y Map1.Extent rect.) y The vertical coordinate to position at the center of the Map.Extent = rect End Sub Private Sub Map1_MouseDown(Button As Integer.ToMapPoint(X. Syntax object. To try this example. Y As Single) Dim pt As New MapObjects2. (Data type is Double. Y) Map1. and then press F5. MapObjects Programmer’s Reference 91 Part Description object An object expression that evaluates to an object in the Applies To list.Visible = False Set pt = Map1. Offset Method Example This example uses the CenterAt method to pan the display to a specified location.ScaleRectangle 0.Point Map1.CenterAt pt. X _ As Single.X. 10:00 AM . Shift As Integer. paste the code into the Declarations section of a form that contains a Map named Map1 that contains at least one MapLayer.pmd 91 10/28/2004. (Data type is Double. pt.) See Also Pan Method. Option Explicit Private Sub Form_Load() Dim rect As MapObjects2.Refresh 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. boolean A boolean expression specifying whether to center the object by font Ascent or not as indicated in Settings. either centered by font Ascent or by the actual glyph bounds.pmd 92 10/28/2004. Settings The settings for boolean are: Setting Description True Centers TrueType symbols by font Ascent . False (Default) Centers TrueType symbols by actual glyph bounds.OLE_HANDLE) If Not pt Is Nothing Then Dim sym As New MapObjects2.Point Private Sub Check1_Click() Map1.Value = 0 End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.Symbol With sym .TrackingLayer. Toggle the CheckBox to see the effect of the property. Press F5.Style = moTrueTypeMarker .SymbolType = moPointSymbol If Check1. Option Explicit Dim pt As MapObjects2. 92 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list.Value = 0 Then ProgrammersReference. 10:00 AM . To try this example. then click the Map.Value = 1 Then . paste the code into the Declarations section of a form containing a CheckBox named Check1 and a Map named Map1. See Also Font Object.CenterOnAscent = True ElseIf Check1.Caption = “Center on Ascent” Check1.Refresh True End Sub Private Sub Form_Load() Check1. Point Object. TextSymbol Object Example This example uses the CenterOnAscent property to control how to align TrueType symbols. CharacterIndex = 45 .Font = “ESRI Transportation & Municipal” . y As Single) Set pt = Map1. Shift As Integer. MapObjects Programmer’s Reference 93 . the location of this Point will differ from the location of the Center of the Rectangle representing the Extent of the Polygon.Size = 36 . See Also Extent Property ProgrammersReference.Color = moBlue Map1. y) Map1.DrawShape pt.ToMapPoint(x. sym . sym End With End If End Sub Private Sub Map1_MouseDown(Button As Integer.TrackingLayer. Syntax Set variable = object.CharacterIndex = 46 .Style = moTrueTypeMarker . For an irregular polygon.Centroid The Centroid property syntax has these parts: Part Description variable A variable that has been declared as a Point. Remarks The centroid represents the geometric center of a Polygon.DrawShape pt.Color = moRed Map1. object An object expression that evaluates to an object in the Applies To list. x _ As Single.pmd 93 10/28/2004.Refresh True End Sub Centroid Property Applies To Polygon Object Description Returns the centroid of an object as a Point object.CenterOnAscent = False End If . 10:00 AM . x _ As Single.TrackingLayer.Size = 18 . paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. Shift As Integer. Syntax object.TrackingLayer. To try this example. the code increments the CharacterIndex value associated with the Symbol. Option Explicit Private Sub Form_Load() Dim fnt As New StdFont fnt. As you click on the Map. See Also Font Property Example This example uses the CharacterIndex property to change the Symbol associated with a GeoEvent on a TrackingLayer.pmd 94 10/28/2004. To return or set a Symbol object’s Font.Symbol(0) .SymbolCount = 1 With Map1. 94 MapObjects Programmer’s Reference Example See Area property CharacterIndex Property Applies To Symbol Object Description Returns or sets the character code in the Font associated with a Symbol object.Color = moBlack End With End Sub Private Sub Map1_MouseDown(Button As Integer. use the Font property. index A numeric expression that specifies the character code in the Symbol’s Font. y As Single) ProgrammersReference. the CharacterIndex property refers to the Wingdings character number.Style = moTrueTypeMarker . 10:00 AM . Press F5 and click the Map repeatedly to see the different symbols.Font = fnt . In this example.Name = “Wingdings” ‘TrueType font Map1.CharacterIndex [= index] The CharacterIndex property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. To normalize bar charts.ToMapPoint(x. set an indexed Field property and an indexed Color property.ChartRenderer See Also ClassBreaksRenderer Object.Symbol(0). To determine the dimensions of each bar chart. and for each attribute. here’s one way to create a ChartRenderer : Set Map1. A ChartRenderer is a creatable object in MapObjects. and MaxPieSize properties.TrackingLayer If .AddEvent pt.pmd 95 10/28/2004. LabelRenderer Object. MapObjects Programmer’s Reference 95 Static chridx With Map1. 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. use the BarHeight and BarWidth properties. 0 End With Map1. you can compare one feature to another by the relative size of each feature’s chart.Layers(0).Extent. In addition.TrackingLayer. A chart which contains data totaling zero will not be displayed.Renderer = New MapObjects2. EventRenderer Object. Use the ChartType property to set whether the chart is a pie chart or a bar chart. y) Map1. Use the ShowOutline property to control the appearance of the chart outlines. use the SizeField. MinPieSize.Point Set pt = Map1. In Visual Basic. ZRenderer Object.TrackingLayer.EventCount > 0 Then .Center Dim pt As MapObjects2.CharacterIndex = chridx chridx = chridx + 1 End Sub ChartRenderer Object The ChartRenderer Object’s 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. Set the number of fields represented in the chart with the FieldCount property. Properties BarHeight Field MinPieSize ShowOutline ProgrammersReference. DotDensityRenderer Object. To control the size of pie charts.RemoveEvent 0 End With If chridx = 0 Then chridx = 33 With Map1. use the NormalizationField property. ValueMapRenderer Object. 10:00 AM . 96 MapObjects Programmer’s Reference BarWidth FieldCount NormalizationField ChartType MaxPieSize NullValue 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. widths.Value = True Or Option2.Layers. Press F5.ChartRenderer Private Sub Form_Load() Dim recset As New MapObjects2.Renderer = cr Set recset = Map1.Caption = “Bar Chart” Set Map1.Item(“states”). select one or more field names. and a ListBox named List1. ctr As Integer If Option1.Name End If Next fld End Sub Private Sub Map1_BeforeLayerDraw(ByVal index As Integer.002 Case moPie ProgrammersReference. two OptionButton objects named Option1 and Option2. 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. 10:00 AM . Option Explicit Dim cr As New MapObjects2.Width * 0.Field Option1.AddItem fld.pmd 96 10/28/2004.Layers.Item(“states”).Type > 0 And fld.Height * 0.Records For Each fld In recset. Set the ListBox MultiSelect property to 2-Extended to allow for multiple selections and set the ListBox Sorted property to True.Caption = “Pie Chart” Option2.ChartType ‘heights. and sizes are ‘somewhat arbitrary Case moBar cr.Value = True Then Select Case cr.01 cr.Type < 8 Then List1.OLE_HANDLE) Dim i As Integer.BarHeight = Map1. To try this example.Recordset Dim fld As MapObjects2. and then choose a chart type.Fields If fld.BarWidth = Map1. ByVal hDC _ As Stdole. 10:00 AM .1) = QBColor(ctr + 1) End With End If Next i End If End If End Sub Private Sub Option1_Click() If Option1.Color(ctr .Pan End If End Sub ProgrammersReference.Refresh End If End Sub Private Sub Map1_MouseDown(Button As Integer.Selected(i) = True Then ctr = ctr + 1 With cr .FieldCount = ctr . Shift As Integer.Height * 0.Field(ctr . _ x As Single.ListCount .ListIndex > 0 Then For i = 0 To List1.Value = True Then cr.1) = List1.ChartType = moBar Map1. y As Single) If Button = 1 Then Map1.TrackRectangle Else Map1.005 cr.1 If List1.Value = True Then cr.pmd 97 10/28/2004. MapObjects Programmer’s Reference 97 cr.MinPieSize = Map1.Refresh End If End Sub Private Sub Option2_Click() If Option2.ChartType = moPie Map1.015 End Select If List1.List(i) .MaxPieSize = Map1.Extent = Map1.Height * 0. 10:00 AM . Syntax object. See Also ChartRenderer Object ChartType Property Applies To ChartRenderer Object Description Returns or sets which type of charts are drawn by the ChartRenderer object. Settings The settings for value are ChartTypeConstants. You can specify the ProgrammersReference. See Also ChartTypeConstants Example See ChartRenderer Object ClassBreaksRenderer Object A ClassBreaksRenderer is an object that represents a way of classifying features into categories or classes. moBar 1 The ChartRenderer represents data values for each feature as a bar chart. 98 MapObjects Programmer’s Reference ChartType Constants MapObjects defines the following ChartType constants to describe the type of chart in a ChartRenderer.ChartType [= value] The ChartType property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 98 10/28/2004. Constant Value Description moPie 0 The ChartRenderer represents data values for each feature as a pie chart. The Symbol used to render the feature depends upon the value contained in the specified Field. value A value or constant that determines the chart type as described in Settings. by drawing different symbols for features. by setting the SymbolType property. Strings Collection Description Removes all members of a collection. so if you set BreakCount to be 2.Renderer = New MapObjects2. In Visual Basic. Symbol Object Properties Break Field SymbolType BreakCount Symbol Tag Methods RampColors SizeSymbols Clear Method Applies To Layers Collection. In a similar fashion.ClassBreaksRenderer See Also Field Object. A ClassBreaksRenderer is a creatable object in MapObjects. MapObjects Programmer’s Reference 99 number of categories (number of different Symbols you wish to use) in the BreakCount property. A feature’s Field value determines the category it falls into. 10:00 AM . The ClassBreaksRenderer assigns a symbol to a feature using the indexed Symbol property. The ClassBreaksRenderer will interpolate colors for interven- ing classes. you can use the RampColors method to assign a start color to the first class and an end color to the last class.Clear The Clear method syntax has the following object qualifier and part: ProgrammersReference. You can assign a specific Symbol to each category. and use the Break property to specify the values in Field which determine which Symbol is used. Recordset Object. remember that there is always one more category than the number of breaks. The ClassBreaksRenderer will interpolate sizes for the intervening classes linearly. Syntax object. You can specify the type of Symbol to associate with the ClassBreaksRenderer. 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.Layers(0). here’s one way to create a ClassBreaksRenderer: Set Map1. If you want.pmd 99 10/28/2004. When setting the BreakCount property. there will be three categories. depending on what kinds of features are associated with the MapLayer. An object expression that evaluates to an object in the Applies To list. See Also DblClick Event. To try this example.pmd 100 10/28/2004. Remarks For more information about the Click event. MouseMove Event ClearConnectError Method Applies To DataConnection Object Description Clears any ConnectError value from the DataConnection object Syntax object. 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. Syntax Private Sub object_Click() The Click event syntax has one part: Part Description object An object expression that evaluates to a Map control. 100 MapObjects Programmer’s Reference Part Description object Required. see the Visual Basic online reference.Clear End Sub Click Event Applies To Map Object Description The Click event is a standard ActiveX control event. 10:00 AM . MouseUp Event.ClearConnectError ProgrammersReference. Option Explicit Private Sub Command1_Click() Map1. which occurs when the user presses and then releases a mouse button over the map.Layers. See Also Remove Method Example This example uses the Clear method to clear all layers from the map. MouseDown Event. If Connect returns False. MapObjects Programmer’s Reference 101 The ClearConnectError method syntax has these parts: Part Description object An object expression that evaluates to a DataConnection object. 10:00 AM . the code returns a message about the type of error.Database = “Midnight” If . vbInformation. Substitute appropriate values for the DataConnection object’s properties. paste the code into the Declarations section of a form containing a Map named Map1. Option Explicit Private Sub Form_Load() Dim dc As New MapObjects2.DataConnection Dim sMsg As String With dc . See Also GeoDataset Object Example This example uses the ConnectError property to return messages about problems encountered when connecting to an SDE database.Password = “revere” . “MapObjects” Else Select Case . Press F5.pmd 101 10/28/2004.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 ProgrammersReference. to ensure that the most recent error status is always reported.Server = “silver” .User = “paul” .Connect Then MsgBox “Connected successfully”. To try this example. Remarks You should use the ClearConnectError method after reporting the value of the ConnectError property. “MapObjects2”. 102 MapObjects Programmer’s Reference SDEErr = “File not found” Case 8 SDEErr = “Invalid directory” Case 9 SDEErr = “Host unknown” Case Else SDEErr = SDEErr(.pmd 102 10/28/2004. vbYesNo.ClearConnectError End If End If End With End Sub For details of the SDEErr Function. see the CommitTransaction example ClearEvents Method Applies To TrackingLayer Object Description Deletes all GeoEvent objects and their corresponding Symbols from the TrackingLayer.ConnectError) End Select Dim result As Integer Dim msg As String ‘Build message msg = “Connection Error: “ & sMsg & Chr(13) If Not dc. “Error: “ & .ExtendedErrorString End If msg = msg & Chr(13) & “Do you want to clear the last _ connect error?” ‘get user response result = MsgBox(msg.ConnectError _ . 10:00 AM .ClearEvents The ClearEvents method syntax has these parts: ProgrammersReference. 0) If result = 6 Then ‘yes dc.ExtendedError & “: “ & dc.ExtendedError = 0 Then msg = msg & dc. Syntax object. x _ As Single. vbYesNo) If Response = vbYes Then ‘ User chose Yes. Option Explicit Private Sub Map1_MouseDown(Button As Integer.EventCount > 5 Then Response = MsgBox(“There are now six GeoEvents on the _ TrackingLayer. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. Constant Value Description moDefaultCodePage 0 Determines the TableDesc object’s code page by reading the associated dBASE file header.TrackingLayer. and then press F5 and click the map to add GeoEvents. Symbol Object Example This example uses the ClearEvents method to remove all GeoEvents from the TrackingLayer at once.TrackingLayer.ClearEvents End If End If End Sub 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. y As Single) Dim pt As MapObjects2. OK to remove all?”. Remarks To remove individual events from the TrackingLayer. Shift As Integer.ToMapPoint(x.Point Dim Response As Variant Set pt = Map1.AddEvent pt. To clear all Symbol objects. 0 If Map1.pmd 103 10/28/2004. This code prompts the user when there are more than 5 GeoEvents to see if they want to clear all events. MapObjects Programmer’s Reference 103 Part Description object An object expression that evaluates to a TrackingLayer object. set SymbolCount to 0. ProgrammersReference. To try this example. use the RemoveEvent method. 10:00 AM . y) Map1. Map1.TrackingLayer. See Also GeoEvent Object Event. 104 MapObjects Programmer’s Reference moOEMCodePage 1 Forces the characters in the associated dBASE file to be treated as OEM characters.Layers(0).TableDesc. Syntax object. If the data is not correctly marked with a code page specifier.0 treats everything else as OEM.Records.pmd 104 10/28/2004. ProgrammersReference.CodePage [= value] The FieldCount property syntax has these parts: Part Description object An object expression that evaluates to a TableDesc. access the TableDesc from a Recordset: Map1. CodePage Property CodePage Property Applies To TableDesc Object Description Returns or sets the code page for a TableDesc object. To do this. this indicates that all of the characters are stored in the ANSI code page. 10:00 AM . See Also TableDesc Object. Settings The settings for value are CodePageConstants Remarks The dBASE V specification has a byte in its header for a locale id (the 29th byte). moAnsiCodePage 2 Forces the characters in the associated dBASE file to be treated as ANSI characters. you can override the behavior by setting the code page value to one of the CodePage constants.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. If the byte contains a value of 0x57. value An integer or constant that indicates the code page. as described in Settings. See Also Recordset Object Color Constants MapObjects defines the following color constants for use with Symbol objects. MapObjects version 2. MapObjects Programmer’s Reference 105 Constant Value Description moBlack 0x0 Black moRed 0xFF Red moGreen 0xFF00 Green moBlue 0xFF0000 Blue moMagenta 0xFF00FF Magenta moCyan 0xFFFF00 Cyan moWhite 0xFFFFFF White moLightGray 12632256 Light Gray moDarkGray 4210752 Dark Gray moGray 8421504 Gray moPaleYellow 13697023 Pale Yellow moLightYellow 8454143 Light Yellow moYellow 65535 Yellow moLimeGreen 12639424 Lime Green moTeal 8421440 Teal moDarkGreen 16384 Dark Green moMaroon 128 Maroon moPurple 8388736 Purple moOrange 33023 Orange moKhaki 7051175 Khaki moOlive 32896 Olive moBrown 4210816 Brown moNavy 8404992 Navy ProgrammersReference. 10:00 AM .pmd 105 10/28/2004. 10:00 AM . fBlue As Double Static lNumClicks As Long With Map1. The first time you click the button. TextSymbol Object. 106 MapObjects Programmer’s Reference See Also Symbol Object Color Property Applies To Symbol Object.Layers(0).Symbol Select Case lNumClicks Case 0 CommonDialog1. Map Object Syntax object.ShowColor . Option Explicit Private Sub Command1_Click() Dim fRed As Double. Settings The settings of the Color property are ColorConstants Example This example uses the Color property to control the color of the symbol used to render a MapLayer. a CommandButton named Command1 and a Map named Map1 that contains one MapLayer with polygon features. To try this example. fBlue) ‘random ProgrammersReference.Color = CommonDialog1. See Also Symbol Object.Color [= color] The Color property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Color = RGB(fRed. ChartRenderer Object Description Returns or sets the color of an object. fGreen As Double. paste the code into the Declarations section of a form contain- ing a CommonDialog control. Press F5 and click Command1. color A value or constant that determines the color of an object.pmd 106 10/28/2004. fGreen. TextSymbol Object. Subsequent clicks on the button illustrate different ways to set Color in code.Color Case 1 fRed = 255 * Rnd fGreen = 255 * Rnd fBlue = 255 * Rnd . you can make a selection from the Color dialog and click OK. i. Thanks anyway!”. A useful function is included to return a string based on the LastError of a DataConnection. and a ListBox named List1. one that has previously had the StartTransaction method called. 10:00 AM .Color = vbActiveTitleBar Case 4 . ProgrammersReference. Remarks The CommitTransaction method is used at the end of a single edit. MapObjects Programmer’s Reference 107 Case 2 . paste the code into the Declarations section of a new Form which has three CommandButtons named Command1.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. RollbackTransaction Method Example This example demonstrates how you might connect to and perform a transaction on a dataset stored in SDE. See Also GeoDataset Object. To try this example. and click “Connect”. Then press F5. When connected to SDE. Edit the properties of the DataConnection as appropriate for your SDE instance. vbInformation End Select lNumClicks = lNumClicks + 1 End With If lNumClicks < 6 Then Map1. on an open Recordset. Syntax object. a Map named Map1. 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. COmmand2 and Command3.pmd 107 10/28/2004. or series of edits. using the name of an SDE layer containing Line features in the FindGeoDataset method.Color = QBColor(10) ‘light green Case 3 .Color = moOrange Case Else MsgBox “No more examples.CommitTransaction The CommitTransaction method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object that has an open transaction.e. Press “End Transaction”. and then track a line on the Map.MapLayer Dim recs As New MapObjects2.Database = “esri_sde” If Not dc.SupportsTransactions Then recs. Screen.MousePointer = vbDefault End Sub Private Sub Command2_Click() ‘START TRANSACTION If recs.Connect Then End Set lyr. 10:00 AM .DataConnection Dim lyr As New MapObjects2.MousePointer = vbHourglass dc.Add lyr Set recs = lyr.use the ‘name of a dataset ‘ containing line features. ‘The FindGeoDataset method should also be editied .StartTransaction End If ReportOut End Sub Private Sub Command3_Click() ‘END TRANSACTION Dim Result As Integer ProgrammersReference. Option Explicit Dim dc As New MapObjects2.Recordset Dim reportCnt As Integer Dim sym As New MapObjects2.Records Screen. To see the results of the transaction.GeoDataset = dc. Password and Database strings ‘as appropriate ‘ for your own SDE instance.pmd 108 10/28/2004.Server = “drfinlay” dc. you can press the last CommandButton to remove and re-load the same MapLayer.Lines”) Map1.FindGeoDataset(“SDE_USER.SHAPE.User = “sde_user” dc.TIREE.Layers. 108 MapObjects Programmer’s Reference click “Start transaction”. User.Symbol Private Sub Command1_Click() ‘CONNECT TO SDE AND LOAD LAYER ‘You should edit the Server.Password = “sde_user” dc. 10:00 AM .Layers. “Commit Transaction”) If Result = vbYes Then recs.Remove (0) Map1.Refresh False ProgrammersReference.Refresh Command4. MapObjects Programmer’s Reference 109 Screen. Y As Single) ‘ADD FEATURES TO RECORDSET On Error GoTo SDEErrors Dim NewLine As MapObjects2.RollbackTransaction ReportOut ElseIf Result = vbCancel Then ReportOut Exit Sub End If Map1.MousePointer = vbHourglass Dim geo As MapObjects2.TrackLine Screen.MousePointer = vbHourglass Command1_Click Command4.TrackingLayer.MousePointer = vbHourglass Result = MsgBox(“Do you want to Commit this Transaction?” _ .Enabled = True Screen.CommitTransaction ReportOut ElseIf Result = vbNo Then recs. X _ As Single.MousePointer = vbDefault End Sub Private Sub Map1_MouseDown(Button As Integer.Enabled = False Screen.GeoEvent Set geo = Map1.TrackingLayer.TrackingLayer. 0) Map1.AddEvent(NewLine.ClearEvents MsgBox “MapLayer removed”. Shift As Integer. vbYesNoCancel. vbInformation Screen.Line Set NewLine = Map1.MousePointer = vbDefault End Sub Private Sub Command4_Click() ‘REMOVE AND RE_LOAD LAYER Map1.pmd 109 10/28/2004. 10:00 AM .ExtendedError & vbNewLine & dc.Symbol(0) .AddNew recs.Update ReportOut Map1.pmd 110 10/28/2004.Caption = “Connect” Command2.Caption = “Start Transaction” Command3.Color = moYellow .ConnectError & vbNewLine & “ExtendedError _ : “ & dc.Name & “] “ & _ EditModeStr(recs.Refresh Screen.EditMode) Else EditModeString = “No Edit Records set” End If ProgrammersReference.MousePointer = vbDefault End Sub Private Sub Form_Load() Command1.SymbolType = moLineSymbol .Enabled = False With Map1.ExtendedErrorString ReportOut Screen.Caption = “End Transaction” Command4.TrackingLayer. 110 MapObjects Programmer’s Reference ReportOut recs.Size = 3 End With End Sub Private Sub ReportOut() ‘REPORT ON ERRORS/SDE STATUS Dim EditModeString As String Dim ConnStr As String reportCnt = reportCnt + 1 If Not recs Is Nothing Then EditModeString = “[“ & lyr.Caption = “Remove and Re-Add Layer to Map” Command4.Fields(“Shape”).Value = NewLine ReportOut recs.MousePointer = vbDefault Exit Sub SDEErrors: MsgBox “Error in Carrying out Editing on SDE:” & vbNewLine _ & “Connect Error: “ & dc. ConnectError) dc. object An object expression that evaluates to a DataConnection object. 10:00 AM . The Connect method returns a Boolean value indicating whether or not MapObjects was able to create the connection. see the online help End Function Connect Method Applies To DataConnection Object Description Makes a connection to the Database specified in a DataConnection object. Remarks To successfully connect to a DataConnection object.ListIndex = List1.1 End Sub Public Function EditModeStr(EditModeEnum As Integer) As String ‘SELECT STRING FOR ON CURRENT EDIT MODE Select Case EditModeEnum Case moEditNone: EditModeStr = EditModeEnum & “: No Editing” Case moEditInProgress: EditModeStr = EditModeEnum & _ “: Edit in progress” Case moEditAdd: EditModeStr = EditModeEnum & _ “: Adding in progress” End Select End Function Public Function ConnectErrorMsg(errNum As Integer) As String ‘SELECT STRING FOR CURRENT SDE ERROR For Details of this function. you should ensure that the DataConnection’s Database property specifies a source of a supported vector data.AddItem reportCnt & “) EditMode: “ & EditModeString & _ “ | “ & “DC Error: “ & ConnStr List1.ListCount .Connect The Connect method syntax has these parts: Part Description variable A boolean expression that indicates whether a connection was made. ProgrammersReference.pmd 111 10/28/2004. Syntax Set variable = object.ClearConnectError List1. MapObjects Programmer’s Reference 111 ConnStr = ConnectErrorMsg(dc. If your application is attempting to connect to SDE. Option Explicit Private Sub Form_Load() Dim lyr As New MapLayer Dim dc As New MapObjects2. the code adds a MapLayer based on a GeoDataset to the collection of MapLayers. A useful function is provided in the Connection property example code. Connected Property Example This example uses the Connect method to establish a connection to a folder containing GeoDatasets. 112 MapObjects Programmer’s Reference You can also check the status of the DataConnection using the Connected property.Layers. Substitute an appropriate pathname for the DataConnection object’s Database property and specify the name of a valid GeoDataset as an argument to FindGeoDataset. See Also ConnectError Property.Database = “C:\Program Files\ESRI\MapObjects2\ _ Samples\Data\Redlands” If dc. paste the code into the Declarations section of a form containing a Map named Map1. To try this example. after the Connect method has been attempted. 10:00 AM .pmd 112 10/28/2004. Press F5. the ExtendedError and ExtendedErrorString properties will return any error messages from the database. In order to establish a successful connection with an SDE database. Database is a path name to a directory. or to check the current status of a previously used DataConnection object.Connect Then Set lyr.GeoDataset = dc.FindGeoDataset(“Redlands”) Map1. the Server. In this case. providing error string reporting for each of the SDE error’s supported by MapObjects as ConnectionErrorConstants.DataConnection dc. If Connect returns True.Add lyr Else MsgBox “Connection failed” End If End Sub Connected Property Applies To DataConnection Object ProgrammersReference. 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. Syntax object. sTitle Else MsgBox “Disconnected”. Press F5 and navigate through the file system.Enabled = False End Sub Private Sub Command2_Click() Dim sTitle As String If dc. False A connection to a DataConnection has not been made. a DirListBox control named Dir1. vbExclamation. Return Values The returned values for the Connected property are: Setting Description True A connection to a DataConnection has been made.Connected Then sTitle = “DataConnection Status” MsgBox “Connected”. MapObjects Programmer’s Reference 113 Description Returns a value indicating whether the DataConnection object has a current valid connection.Connected The Connected property syntax has these parts: Part Description object An object expression that evaluates to a DataConnection object. a DriveList control named Drive1. paste the code into the Declarations section of a form containing a Map control. sTitle End If End Sub ProgrammersReference.Disconnect Command1. Check the status by clicking Command2.DataConnection Private Sub Command1_Click() dc. Disconnect from the Database by clicking Command1. 10:00 AM . Option Explicit Dim dc As New MapObjects2.pmd 113 10/28/2004. vbInformation. See Also ConnectError Property Example This example demonstrates the use of the Connected Property and the Disconnect method. and two CommandButton controls named Command1 and Command2. To try this example. A useful function is provided in the Connection property example code. you should then call the ClearConnectError method.Connect Then Command1.path = Drive1. Connected Property. 114 MapObjects Programmer’s Reference Private Sub dir1_Change() dc.Caption = “Status” End Sub ConnectError Property Applies To DataConnection Object Description Returns a value that specifies the type of error that caused an unsuccessful DataConnection connection.Enabled = True End If End Sub Private Sub Drive1_Change() Dir1.Drive ‘ Set directory path. 10:00 AM . Syntax value = object. End Sub Private Sub Form_Load() Command1.pmd 114 10/28/2004.ConnectError The ConnectError property syntax has these parts: Part Description object An object expression that evaluates to a DataConnection object. Connect Method ProgrammersReference. Remarks If you have used the ConnectError property to report on the last DataConnection error. providing error string reporting for each of the SDE error’s supported by MapObjects as ConnectionErrorConstants.path If dc.Database = Dir1.Enabled = False Command1. Return Values Return values from the ConnectError property are ConnectionErrorConstants.Caption = “Disconnect” Command2. See Also Connection Property. the database connection will be freed. All operations performed using this connection are executed as the user named in the User property. Connect Method Example See the online help for example code ProgrammersReference. the Connection property will be zero. by repeating the Connect process on a new DataConnection object. the Disconnect method should always be used to disconnect from an SDE server before the application ends.Connection The Connection property syntax has these parts: Part Description variable A variable that has been declared to be a long data type object An object expression that evaluates to a DataConnection object. Return Values If the object is a connection to a non-SDE data source. the Connection property will return a handle to the database connec- tion. Syntax variable = object. Remarks For an SDE database. The connection will be valid as long as the DataConnection exists. or there is no connection to the SDE server made. when the DataConnection object goes out of scope. Connected Property. 10:00 AM . For more information on SDE handles and the SDE API. MapObjects Programmer’s Reference 115 Example See ClearConnectError method Connection Property Applies To DataConnection Object Description Returns the handle to a successful SDE Connection. If your application makes use of the database Connection. see your SDE documentation. See Also Connection Property. If appropriate. it is important that it does not try to free the connection itself.pmd 115 10/28/2004. 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. You can create multiple SDE connections. 10:00 AM . Constant Value Description moNoError 0 No Error moUnknownError 1 Unknown Error moAccessDenied 2 Access Denied moInvalidUser 3 Invalid User moNetworkTimeout 4 Network Timeout moInvalidDatabase 5 Invalid Database moTasksExceeded 6 Tasks Exceeded moFileNotFound 7 File Not Found moInvalidDirectory 8 Invalid Directory moHostUnknown 9 Host Unknown moSE_FAILURE -1 Failed to connect to SDE moSE_INVALID_LAYERINFO_OBJECT -2 LAYERINFO pointer not initialized moSE_NO_ANNOTATION -3 The given shape has no annotation moSE_FINISHED -4 Stream loading of shapes has finished moSE_SDE_NOT_STARTED -5 SDE is not started. 116 MapObjects Programmer’s Reference ConnectionError Constants MapObjects defines the following Error code constants for DataConnection connections.pmd 116 10/28/2004. cannot perform function moSE_UNCHANGED -6 Specified shape was left unchanged moSE_CONNECTIONS_EXCEEDED -7 Number of tasks on the server is at a maximum ProgrammersReference. defs moSE_NO_LAYER_SPECIFIED -17 Layer specification missing moSE_LAYER_LOCKED -18 Specified layer is locked moSE_LAYER_EXISTS -19 Specified layer already exists moSE_LAYER_NOEXIST -20 Specified layer does not exist moSE_LAYER_INUSE -21 Specifies layer is in use moSE_FID_NOEXIST -22 Specified shape (LAYER:FID) does not exist moSE_FID_EXISTS -23 Specified shape (LAYER:FID) exists moSE_LAYER_MISMATCH -24 Both layers must be the same moSE_NO_PERMISSIONS -25 No permission to perform the operation moSE_INVALID_NOT_NULL -26 Column has a ‘Not Null’ constraint ProgrammersReference.pmd 117 10/28/2004. MapObjects Programmer’s Reference 117 moSE_LOGIN_NOT_ALLOWED -8 Number of connections to the server is at a maximum moSE_INVALID_USER -9 Specified user and password cannot be validated moSE_NET_FAILURE -10 Network I/O operation failed moSE_NET_TIMEOUT -11 Network I/O timeout moSE_OUT_OF_SVMEM -12 Server task cannot allocate the memory it requires moSE_OUT_OF_CLMEM -13 Client task cannot allocate the memory it requires moSE_OUT_OF_CONTEXT -14 The function call is out of context moSE_NO_ACCESS -15 No access to object moSE_TOO_MANY_LAYERS -16 Exceeded max_layers in giomgr. 10:00 AM . moSE_TABLE_NOEXIST -37 The DMBS table does not exist moSE_ATTR_NOEXIST -38 Specified attribute column does not exist moSE_LICENSE_FAILURE -39 Underlying license manager problem. moSE_INVALID_COLUMN_VALUE -41 Value exceeds valid range moSE_INVALID_WHERE -42 User-specified ‘where’ clause is invalid moSE_INVALID_SQL -42 User-specified SQL clause is invalid moSE_LOG_NOEXIST -43 Specified log file does not existT ProgrammersReference. cannot be verified moSE_INVALID_LAYER_NUMBER -28 MapLayer number is out of range moSE_INVALID_ENTITY_TYPE -29 Invalid entity type moSE_INVALID_SEARCH_METHOD -30 Invalid search method moSE_INVALID_ETYPE_MASK -31 Invalid entity type mask moSE_BIND_CONFLICT -32 Bind/set/get/ mismatch moSE_INVALID_GRIDSIZE -33 Invalid grid size moSE_INVALID_LOCK_MODE -34 Invalid lock mode moSE_ETYPE_NOT_ALLOWED -35 Enityt type of shape is not allowed in the layer moSE_TOO_MANY_POINTS -36 Exceeded the ‘max points’ specified. 10:00 AM . moSE_OUT_OF_LICENSES -40 No more SDE licenses available.pmd 118 10/28/2004. 118 MapObjects Programmer’s Reference moSE_INVALID_SHAPE -27 Invalid shape. can’t open temp file. 10:00 AM . MapObjects Programmer’s Reference 119 moSE_LOG_NOACCESS -44 Unable to access the specified logfile moSE_LOG_NOTOPEN -45 Specified logfile is unavailable for I/O moSE_LOG_IO_ERROR -46 I/O error using the logfile moSE_NO_SHAPES -47 No shapes selected or used in the operation moSE_NO_LOCKS -48 No locks defined moSE_LOCK_CONFLICT -49 Lock request conflicts with another lock request moSE_OUT_OF_LOCKS -50 Maximum number of locks allowed by the system are in use moSE_DB_IO_ERROR -51 Database-level I/O error occurred moSE_STREAM_IN_PROGRESS -52 Shape/FID stream not finished moSE_INVALID_COLUMN_TYPE -53 Invalid column data type moSE_TOPO_ERROR -54 Topological integrity error moSE_ATTR_CONV_ERROR -55 Attribute conversion error moSE_INVALID_COLUMN_DEF -56 Invalid column definition moSE_INVALID_SHAPE_BUF_SIZE -57 Invalid shape array buffer size moSE_INVALID_ENVELOPE -58 Envelope is Null. or Min > Max moSE_TEMP_IO_ERROR -59 Temp file I/O error. has negative values. cannot login ProgrammersReference. or ran out of disk space moSE_GSIZE_TOO_SMALL -60 Spatial index grid size is too small moSE_LICENSE_EXPIRED -61 SDE run-time license has expired.pmd 119 10/28/2004. pmd 120 10/28/2004. 10:00 AM . 120 MapObjects Programmer’s Reference moSE_TABLE_EXISTS -62 DBMS table exists moSE_INDEX_EXISTS -63 Index with the specified name already exists moSE_INDEX_NOEXIST -64 Index with the specified name does not exist moSE_INVALID_POINTER -65 Specified pointer value is null or invalid moSE_INVALID_PARAM_VALUE -66 Specified parameter value is invlaid moSE_ALL_SLIVERS -67 Sliver factor caused alll results to be slivers moSE_TRANS_IN_PROGRESS -68 User-specifie transaction is in progress moSE_IOMGR_NO_DBMS_CONNECT -69 I/O manager has lost it’s connection to the underlying DBMS moSE_DUPLICATE_ARC -70 ARC (startpt.endpt) already exists moSE_INVALID_ANNO_OBJECT -71 SE_ANNO pointer not initialized. moSE_PT_NO_EXIST -72 Specified point does not exist in the feature moSE_PTS_NOT_ADJACENT -73 Specified points must be adjacent moSE_INVALID_MID_PT -74 Specified midpoint is invalid moSE_INVALID_END_PT -75 Specified endpoint is invalid moSE_INVALID_RADIUS -76 Specified radius is invalid moSE_LOAD_ONLY_LAYER -77 MapLayer has LoadOnly mode.midpt. operation is not allowed moSE_LAYERS_NOT_FOUND -78 Layer table does not exist ProgrammersReference. connection is closed. or the wrong object has been used moSE_INVALID_DBA_PASSWORD -93 The DBA password is incorrect moSE_PATH_NOT_FOUND -94 Coord path not found the shape edit operation moSE_SDEHOME_NOT_SET -95 No $SDEHOME variable has been set moSE_NOT_TABLE_OWNER -96 User must be the table owner ProgrammersReference.pmd 121 10/28/2004. 10:00 AM . MapObjects Programmer’s Reference 121 moSE_FILE_IO_ERROR -79 Error writing or creating an output text file moSE_BLOB_SIZE_TOO_LARGE -80 Maximum blob size exceeded moSE_CORRIDOR_OUT_OF_BOUNDS -81 Resulting corridor exceeds the valid coordinate range moSE_SHAPE_INTEGRITY_ERROR -82 Model integrity error moSE_NOT_IMPLEMENTED_YET -83 Function or option is not yet implememted moSE_CAD_EXISTS -84 This shape has a CAD moSE_INVALID_TRANSID -85 Invalid internal SDE transac- tion ID moSE_INVALID_LAYER_NAME -86 MapLayer name must not be empty moSE_INVALID_LAYER_KEYWORD -87 Invalid Layer configuration keyword used moSE_INVALID_RELEASE -88 Invalid release/version of SDE server moSE_VERSION_TBL_EXISTS -89 Version table exists moSE_COLUMN_NOT_BOUND -90 Column has not been bound moSE_INVALID_INDICATOR_VALUE -91 Indicator variable contains an invalid value moSE_INVALID_CONNECTION -92 The connection handle is NULL. 122 MapObjects Programmer’s Reference moSE_PROCESS_NOT_FOUND -97 The process ID specified does not correspond on an SDE server moSE_INVALID_DBMS_LOGIN -98 DBMS did not accept user/ password moSE_PASSWORD_TIMEOUT -99 Password received was sent more than MAXTIMEDIFF second before moSE_INVALID_SERVER -100 Server machine was not found moSE_IOMGR_NOT_AVAILABLE -101 IO Manager task not started on server moSE_SERVICE_NOT_FOUND -102 No SDE entry in /etc/services file moSE_INVALID_STATS_TYPE -103 Tried statistics on a non- numeric value moSE_INVALID_DISTINCT_TYPE -104 Distinct stats on invalid type moSE_INVALID_GRANT_REVOKE -105 Invalid use of grant/revoke function moSE_INVALID_SDEHOME -106 The supplied SDEHOME path is invalid or NULL moSE_INVALID_STREAM -107 Stream does not exist moSE_TOO_MANY_STREAMS -108 Max number of streams exceeded moSE_OUT_OF_MUTEXES -109 Exceeded system’s maximum number of mutexs moSE_CONNECTION_LOCKED -110 This connection is locked to a different thread moSE_CONNECTION_IN_USE -111 This connection is being used at the moment by a different thread moSE_NOT_A_SELECT_STATEMENT -112 The SQL statement was not a select ProgrammersReference.pmd 122 10/28/2004. 10:00 AM . meters. 10:00 AM .0 moSE_INVALID_SYSTEM_UNITS -123 System units smaller than 1 or greater than 21474836467 moSE_INVALID_UNITS -124 Feet. MapObjects Programmer’s Reference 123 moSE_FUNCTION_SEQUENCE_ERROR -113 Function called out of se- quence moSE_WRONG_COLUMN_TYPE -114 Get request on wrong column type moSE_PTABLE_LOCKED -115 This pTable is locked to a different thread moSE_PTABLE_IN_USE -116 This pTable is being used at the moment by a different thread moSE_STABLE_LOCKED -117 This sTable is locked to a different thread moSE_STABLE_IN_USE -118 This sTable is being used at the moment by a different thread moSE_INVALID_FILTER_TYPE -119 Unrecognized spatial filter type moSE_NO_CAD -120 The given shape has no CAD moSE_INSTANCE_NOT_AVAILABLE -121 No instance running on server moSE_INSTANCE_TOO_EARLY -122 Instance is a version previous to 2.pmd 123 10/28/2004. decimal degrees or other moSE_INVALID_CAD_OBJECT -125 SE_CAD pointer not initialized moSE_INVALID_NUM_OF_PTS -126 No longer issued moSE_INVALID_SPATIAL_CONSTRAINT -127 Spatial filters invalid for search moSE_INVALID_STREAM_TYPE -128 Invalid operation for the given stream moSE_INVALID_SPATIAL_COLUMN -129 Column contains NOT NULL values during SE_Layer_create() ProgrammersReference. pmd 124 10/28/2004. 10:00 AM .table does not match the layer moSE_PROJECTION_ERROR -145 Error projecting shape points moSE_ARRAY_BYTES_EXCEEDED -146 Max array bytes exceeded moSE_POLY_SHELLS_OVERLAP -147 2 donuts or 2 outer shells overlap ProgrammersReference. server required moSE_MULTIPLE_SPATIAL_COLS -133 Only one spatial column allowed moSE_INVALID_SHAPE_OBJECT -134 The given shape object handle is invalid moSE_INVALID_PARTNUM -135 Specified shape part number does not exist moSE_INCOMPATIBLE_SHAPES -136 Given shapes are of incompat- ible types moSE_INVALID_PART_OFFSET -137 Specifies part offset is invalid moSE_INCOMPATIBLE_COORDREFS -138 Given coordinate references are incompatible moSE_COORD_OUT_OF_BOUNDS -139 Specified coordinate exceeds the valid coordinate range moSE_LAYER_CACHE_FULL -140 Max layers exceeded in cache moSE_INVALID_COORDREF_OBJECT -141 Given coordinate reference object handle is invalid moSE_INVALID_COORDSYS_ID -142 Coordinate system identifier is invalid moSE_INVALID_COORDSYS_DESC -143 Coordinate system description is invalid moSE_INVALID_ROW_ID_LAYER -144 SE_ROW_ID owner. 124 MapObjects Programmer’s Reference moSE_NO_SPATIAL_MASKS -130 No spatial masks available moSE_IOMGR_NOT_FOUND -131 IO manager program not found moSE_SYSTEM_IS_CLIENT_ONLY -132 Operation cannot run on this system. 10:00 AM . MapObjects Programmer’s Reference 125 moSE_TOO_FEW_POINTS -148 Number of points is less than required for feature moSE_INVALID_PART_SEPARATOR -149 Part seperator in the wrong position moSE_INVALID_POLYGON_CLOSURE -150 Polygon does not close correctly moSE_INVALID_OUTER_SHELL -151 A polygon outer shell does not completely enclose all donuts for the part moSE_ZERO_AREA_POLYGON -152 Polygon shell has no area moSE_POLYGON_HAS_VERTICAL_LINE -153 Polygon shell contains a vertical line moSE_OUTER_SHELLS_OVERLAP -154 Multipart area has overlapping parts moSE_SELF_INTERSECTING -155 Linestring or polygon bound- ary is self-intersecting moSE_INVALID_EXPORT_FILE -156 Export file is invalid moSE_READ_ONLY_SHAPE -157 Attempted to modify or free a read-only shape from an sTable moSE_INVALID_DATA_SOURCE -158 Invalid data source moSE_INVALID_STREAM_SPEC -159 Stream spec parameter exceeds giomgr default moSE_INVALID_ALTER_OPERATION -160 Tried to remove cad or anno moSE_INVALID_SPATIAL_COL_NAME -161 Spatial column same as table name moSE_INVALID_DATABASE -162 Invalid database name moSE_SPATIAL_SQL_NOT_INSTALLED -163 Spatial SQL extension not present in underlying DBMS moSE_NORM_DIM_INFO_NOT_FOUND -164 Dimension parameters for SDO DIM table is not found in the dbTune file ProgrammersReference.pmd 125 10/28/2004. 126 MapObjects Programmer’s Reference moSE_NORM_DIM_TAB_VALUE_NOT_FOUND-165 Dimension parameters in the SDO DIM table is corrupted or missing moSE_UNSUPPORTED_NORMALIZED_OPERATION -166 Current operation is not supported for Normalized layers moSE_INVALID_REGISTERED_LAYER_OPTION -167 Invalid operation: Registered layers do not allow this opera- tion moSE_READ_ONLY -168 User has read only access to SE_ROW_ID moSE_SDE_WARNING -1000 Base number for warning codes moSE_ETYPE_CHANGED -1001 Function changed entity type of feature moSE_AUTOCOMMITTED -1002 This store/replace triggered an autocommit moSE_TOO_MANY_DISTINCTS -1003 Too many distinct values in stats moSE_NULL_VALUE -1004 Request column value is NULL moSE_NO_ROWS_UPDATED -1005 No rows were updated moSE_NO_CPGCVT -1006 No codepage conversion moSE_NO_CPGHOME -1007 Cannot find codepage directory moSE_DBMS_DOES_NOT_SUPPORT -1008 DBMS does not support this function moSE_NO_TRIGGERS_CREATED -1009 DBMS does not support multiple triggers. 10:00 AM . Do not create over existing business table trigger See Also DataConnection Object ProgrammersReference.pmd 126 10/28/2004. Visible = False End If Next curLayer ‘Now set the map’s coordinate system to be the same as that ‘of the first layer in the map control’s layer collection ProgrammersReference.prj files). Map Object Description Returns or sets the coordinate system for a Map or a MapLayer object. and a ListBox called List1.name). the coordsys may be declared as a variant data type.AddItem curLayer. Option Explicit Private Sub Form_Load() Dim curLayer As MapObjects2.Layers If Not curLayer. Syntax object. To try this example.Visible = True Else List1. See Also GeoCoordSys Object.AddItem curLayer. If the type is previously unknown. 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 . 10:00 AM .CoordinateSystem Is Nothing Then List1.MapLayer For Each curLayer In Map1.name).pmd 127 10/28/2004. and the IsProjected property can then be checked. Press F5 to run the example.CoordinateSystem.CoordinateSystem [= coordSys ] The CoordinateSystem property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Layers(curLayer. Remarks The coordinate system referenced by coordsys may be of type GeoCoordSys or ProjCoordSys. ProjCoordSys Object Example This example uses the CoordinateSystem property to hide each MapLayer which does not have a coordinate system set. coordSys A coordinate system object (either a GeoCoordSys or a ProjCoordSys).name & “: Coordinate System not set” Map1. MapObjects Programmer’s Reference 127 CoordinateSystem Property Applies To MapLayer Object.name Map1.Layers(curLayer.name & “: “ & _ curLayer. An output resolution of 1 represents the same number of pixels in the bitmap image of the Map as on the screen.CoordinateSystem.ProjCoordSys mapPCS. Syntax object.CoordinateSystem = mapPCS ElseIf Not Map1.AddItem “Map Control: “ & Map1. paste the code into the Declara- tions section of a form that contains a CommandButton named Command1 and a Map named ProgrammersReference.CoordinateSystem.CoordinateSystem.CoordinateSystem. 10:00 AM .pmd 128 10/28/2004. ExportMap Method.GeoCoordSys mapGCS. If any ImageLayers in the Map control’s Layers collection have their Transparent property set to True.CoordinateSystem. To try this example.Type = Map1.Layers(0). any ImageLayers in the Map control’s Layers collection will not be visible.name End Sub CopyMap Method Applies To Map Object Description Copies the visible extent of the Map to the Clipboard in enhanced and standard metafile format.Type Map1. See Also OutputMap Method. both in the horizontal and the vertical direction.IsProjected Then Dim mapPCS As New MapObjects2.Layers(0).CoordinateSystem Is Nothing Then If Map1.Layers(0).Type Map1.Type = Map1. scaleFactor A value that determines the output resolution.CopyMap scaleFactor The CopyMap method syntax has the following parts: Part Description object An object expression that evaluates to an object in the Applies To list.IsProjected Then Dim mapGCS As New MapObjects2. 128 MapObjects Programmer’s Reference If Map1. PrintMap Method Example This example uses the CopyMap method to copy the visible extent of a Map to the Clipboard in enhanced and standard metafile format. If RotationAngle is not zero.CoordinateSystem = mapGCS End If End If List1. an output resolution of 10 is ten times the original number of pixels in the image. then these too will not be visible.Layers(0). Remarks CopyMap does not support VisibleRegion or Transparent properties. Count [= total] The Count method syntax has the following parts: Part Description object Required. 10:00 AM . Remarks You can use this property with a For. if the number of records is unknown. MapObjects Programmer’s Reference 129 Map1 that contains at least one MapLayer.. click Command1 and then paste the contents of the Clipboard into another application. Layers Collection. and then press F5. GroupRenderer Object. Statistics Object Description Returns the number of objects in a collection.1 List1. Parts Collection.. Strings Object.Layers.Map1.Additem Form1. indicating the number of objects in a collec- tion.Count . For Recordset objects. Syntax object. the following code adds the names of all layers in a map to a list: For I = 0 To Form1.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 ProgrammersReference.Layers(I). Recordset Object.CopyMap 1 End Sub Count Property Applies To Fields Collection. For example.pmd 129 10/28/2004. Option Explicit Private Sub Command1_Click() Map1. An object expression that evaluates to an object in the Applies To list. the property returns -1.Map1.Next statement to carry out an operation on the mem- bers of a collection. GeoDatasets Collection. Points Object. total An integer data type variable. and some GeoEvents. Remarks The Custom property is used to set a reference to a user-defined custom Symbol or Projec- tion object.Symbol. You can also create a custom renderer object. to obtain the correct Count of the Recordset. allowing the developer to render a MapLayer to exact specifications. for example: Dim myMarker as New MySymbols. Syntax object. 10:00 AM . and the number of records taken from the Count property of this Statistics object. Add Method Example This example uses the Count property to report on how many layers constitute the Map. See Also Item Property.Custom [= customObj ] The Custom property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 130 MapObjects Programmer’s Reference In these cases. and _ “ & Map1.Count & “ layers in the map.Caption = Map1. See Also IsCustom Property ProgrammersReference. and the number of events in the tracking layer. Projection Object Description Returns or sets a reference to a custom Symbol or customized Projection object. a Statistics object should be created from the Recordset. Press F5 Private Sub Form_Load() Label1.MarkerSymbol myLayer. For example. customObj An object declared as a user -defined Symbol or Projection.tlb Type Library.pmd 130 10/28/2004.EventCount & “ events in the tracking layer” End Sub Custom Property Applies To Symbol Object.Custom = myMarker Custom Symbols and Projections are created by using the ICustom Interface. 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.TrackingLayer. in Visual Basic you can create your own DLL using the ICustom interface by adding a reference to the AFCust2.Layers. To try this example.0. MapObjects Programmer’s Reference 131 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. Syntax object.Database [=dbName] The Database property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. dbName A string expression that evaluates to an SDE or an ODBC Database name, Microsoft Jet database engine database, an installable ISAM database, an INFO database, an ARC/INFO or PC ARC/INFO workspace, or a pathname to a directory containing ESRI shapefiles (SHP files). 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. See Also User Property Example See Connect method 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 ProgrammersReference.pmd 131 10/28/2004, 10:00 AM 132 MapObjects Programmer’s Reference GeoDatasets by using the methods FindArcInfoCoordinateSystem and FindCoordinateSystem. 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 connection’s 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. See Also GeoDataset Object, TableDesc Object, MapLayer Object Properties Connected Database GeoDatasets User ConnectError ExtendedError Passwords Connection ExtendedErrorString Server Methods AddGeoDataset DeleteGeoDataset FindCoordinateSystem ClearConnectError Disconnect FindGeoDataset 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. The default Datum is moDatum_AuthalicSphere, value 6035. See Also Datum Object, Type Property ProgrammersReference.pmd 132 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 133 Datum Object The Datum object is used to define the datum upon which a geographical coordinate system is based. A Datum object’s 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 Name Spheroid Type Datum Property Applies To GeoCoordSys Object Description Sets or returns a value that identifies the datum upon which a GeoCoordSys object is based. Syntax object. Datum [= datum ] The GeoCoordSys property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. datum An object expression that evaluates to a Datum object See Also Datum Object 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 ProgrammersReference.pmd 133 10/28/2004, 10:00 AM 134 MapObjects Programmer’s Reference Private Sub Combo1_Click() Dim datype As Integer datype = stripProjection(Combo1.List(Combo1.ListIndex)) Dim curLayer As MapObjects2.MapLayer For Each curLayer In Map1.Layers If Not curLayer.CoordinateSystem.IsProjected Then If curLayer.CoordinateSystem.Datum.Type = datype Then curLayer.Visible = True Else curLayer.Visible = False End If End If Next curLayer Map1.Refresh End Sub Private Function stripProjection(theProjection As String) As Integer ‘Strip the projection object type number from the selected string Dim openB As Integer openB = InStr(theProjection, “[“) stripProjection = Int(Left(Right(theProjection, Len(theProjection) _ - openB), Len(theProjection) - openB - 1)) End Function Private Sub Form_Load() Dim datums As New MapObjects2.Strings Dim theDat As Variant datums.PopulateWithDatums For Each theDat In datums Combo1.AddItem theDat Next theDat ‘ 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. ‘ ‘ Dim gcs1 As New MapObjects2.GeoCoordSys ‘ Dim gcs2 As New MapObjects2.GeoCoordSys ‘ Dim dat1 As New MapObjects2.Datum ‘ Dim dat2 As New MapObjects2.Datum ProgrammersReference.pmd 134 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 135 ‘ 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. Syntax Private Sub object_DblClick() The DblClick event syntax has one part: Part Description object An object expression that evaluates to a Map control. Remarks For more information about the DblClick event, see the Visual Basic online. See Also Map events 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 The Database property syntax has these parts: Part Description object An object expression that evaluates to a Symbol object. See Also Symbol Object, UseDefault Property ProgrammersReference.pmd 135 10/28/2004, 10:00 AM 136 MapObjects Programmer’s Reference 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 Private Sub Form_Load() Dim oField As MapObjects2.Field Set moRecset = Map1.Layers(0).Records For Each oField In moRecset.Fields If VarType(oField.Value) > vbNull And VarType(oField.Value) _ <= moString Then List1.AddItem oField.name End If Next Check1.Caption = “Use Default Value” End Sub Private Sub List1_DblClick() Dim strs As New MapObjects2.Strings Dim sFldname As String Dim oRenderer As New MapObjects2.ValueMapRenderer Dim oSym As New MapObjects2.Symbol Dim i As Integer Set moRecset = Map1.Layers(0).Records sFldname = List1.List(List1.ListIndex) ‘iterate through the records and accumulate values Do While Not moRecset.EOF strs.Add moRecset(sFldname).ValueAsString moRecset.MoveNext Loop ‘ set up a ValueMap renderer Set Map1.Layers(0).Renderer = oRenderer oRenderer.Field = sFldname oRenderer.UseDefault = Check1.Value ‘ toggle ProgrammersReference.pmd 136 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 137 ‘ set the number of values for which to render a unique symbol ‘ simulates values that might be considered in an “other” ‘ category If oRenderer.UseDefault Then If strs.Count > 1 Then ‘ arbitrarily specify that only half the values will get _ ‘ a unique symbol oRenderer.ValueCount = strs.Count / 2 Else oRenderer.ValueCount = 1 End If Else ‘ one symbol for each unique value oRenderer.ValueCount = strs.Count End If ‘ this is the symbol to use if UseDefault is True Set oSym = oRenderer.DefaultSymbol oSym.Color = moPaleYellow ‘ set the values for the renderer For i = 0 To oRenderer.ValueCount - 1 oRenderer.Value(i) = strs(i) Next i Map1.Refresh Set oRenderer = Nothing Set strs = Nothing Set moRecset = Nothing End Sub Private Sub Check1_Click() If List1.ListIndex <> -1 Then List1_DblClick End Sub Delete Method Applies To Recordset Object Description Deletes the current record in an open Recordset object. Syntax object.Delete The Delete method syntax has these parts: ProgrammersReference.pmd 137 10/28/2004, 10:00 AM 138 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to a Recordset object. 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 Private Sub Command1_Click() Dim recset As MapObjects2.Recordset Dim ans As Variant Set recset = Map1.Layers(0).Records recset.MoveFirst Map1.FlashShape recset.Fields(“shape”).Value, 4 ans = MsgBox(“Are you sure you want to delete this record?”, _ vbYesNo, “MapObjects”) If ans = vbYes Then recset.Edit recset.Delete recset.StopEditing Map1.Refresh End If End Sub Private Sub Form_Load() Command1.Caption = “Delete” End Sub DeleteGeoDataset Method Applies To DataConnection Object Description Deletes a GeoDataset object from a DataConnection (shapefiles only). ProgrammersReference.pmd 138 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 139 Syntax object.DeleteGeoDataset name [=return] The DeleteGeoDataset method syntax has these parts: Part Description object An object expression that evaluates to a DataConnection object. name A string expression that evaluates to the name of the GeoDataset object to delete. return A boolean expression that indicates the status of the DeleteGeoDataset method call. Return Values The DeleteGeoDataset method return values are: 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. true The specified shapefile was removed. See Also GeoDataset Object, TableDesc Object 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 folder’s 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 Private Sub Command1_Click() With dc ProgrammersReference.pmd 139 10/28/2004, 10:00 AM 140 MapObjects Programmer’s Reference .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 Private Sub dir1_Change() Dim oDataset As MapObjects2.GeoDataset 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 Private Sub Form_Load() Command1.Caption = “&Delete GeoDataset” 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 MapLayer’s GeographicTransformation property for on-the-fly projection of the MapLayer. ProgrammersReference.pmd 140 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 141 Syntax object.DensificationTolerance [=tolerance]. The DensificationTolerance property syntax has these parts: Part Description object An object expression that evaluates to a MapLayer. tolerance A numeric expression, which sets the frequency at which points are inserted into the MapLayer’s 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. MapLayers that do not have a CoordinateSystem set will be displayed unprojected. See Also Rectangle Object, Extent Property Example This example sets the DensificationTolerance property of a MapLayer relative to it’s 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 Private Sub Form_Load() Dim PCS As New MapObjects2.ProjCoordSys PCS.Type = 32630 Map1.Layers(0).CoordinateSystem = PCS If Map1.Layers(0).CoordinateSystem.Type > 0 Then Label1.Caption = “Map Layer Units: “ & _ Map1.Layers(0).CoordinateSystem.Unit.Name Map1.Layers(0).DensificationTolerance = 0.5 Label2.Caption = “Deinsification Tolerance: “ & _ Map1.Layers(0).DensificationTolerance End If End Sub Depth Property Applies To Rectangle Object ProgrammersReference.pmd 141 10/28/2004, 10:00 AM Syntax Set variable = object. Polygon Object. extent An object expression that evaluates to a Rectangle object. See Also Ceiling Property.Difference (subtractShape [. ProgrammersReference. By default. Points Collection.(See Remarks). Floor Property Example See Ceiling property Difference Method Applies To Point Object. Rectangle Object. object An object expression that evaluates to an object in the Applies To list. 142 MapObjects Programmer’s Reference Description Returns the difference between the Ceiling and Floor coordinates of a Rectangle object. subtractShape An object expression that evaluates to an object in the Applies To list. a Rectangle object will have a Depth of zero.extent]) The Difference method syntax has these parts: Part Description resultShape An object expression that evaluates to a shape object. This Rectangle should entirely contain the object’s extent. and is used internally. (See Remarks). 10:00 AM . Syntax Set resultShape = object. This is the shape whose dimensions will be reduced by subtractShape. This is the shape that represents the amount by which object will be reduced.pmd 142 10/28/2004. Will contain the resulting shape after the difference operation. Ellipse Object Description Returns a shape that represents the geometric Difference of two shape objects of the same dimension. Remarks The Depth property to represents the dimension of the rectangle along the Z-axis.Depth The Depth property syntax has these parts: Part Description variable A numeric expression that contains the depth of the Rectangle object An object expression that evaluates to an object in the Applies To list. Line Object. i. the resultShape will be nil. ProgrammersReference. Point Points Object Points Object Line Line Line Rectangle Rectangle Rectangle Polygon Polygon Ellipse Polygon Rectangle Rectangle Polygon Polygon Ellipse Ellipse Rectangle Rectangle Polygon Polygon Ellipse An exception will be raised if an incompatible shape type is passed as an argument for subtractShape. 10:00 AM .Difference(shapeB) could be different to shapeB. Type of object subtractShapes Possible resultShapes Point Point. Where the resultShape could be more than one object type (e.e. 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.g. Point Points Object Points Object Points Object Point. shapeA. Rectangle or Polygon). The Difference method is not commutative. Only certain combinations of shape are valid. therefore the order of object and subtractShape arguments is significant to the result. MapObjects Programmer’s Reference 143 Remarks If the two Shapes do not have a valid Difference. then use an interim Object and then test the result using its ShapeType property to see what type of object it is.pmd 143 10/28/2004.Difference(shapeA). GeoEvent Set shape2 = shape Set diffShape = shape1. Union Method.pmd 144 10/28/2004. To try this example. 144 MapObjects Programmer’s Reference You cannot use the Difference method with a self-intersecting Polygon.AddEvent(diffShape. an excep- tion is raised in Visual Basic.TrackRectangle Map1. 1) Set shape1 = Nothing diff = False End If End Sub Private Sub Map1_MouseDown(Button As Integer.FullExtent) Set diffEvent = Map1.Difference(shape2. Map1. Intersect Method. See Also Buffer Method. Option Explicit Dim shape1 As Object Dim shape2 As Object Dim diff As Boolean Private Sub doDifference(shape As Object) If Not diff Then Set shape1 = shape diff = True ElseIf diff Then Dim diffShape As Object Dim diffEvent As New MapObjects2. Valid Object expected as argument. and then click on the map to track two polygons. The polygons and the new shape generated by the Difference operation are added to the tracking layer as GeoEvents.Polygon Dim eventLine As New MapObjects2. GetCrossings Method. press F5. If you do. y As Single) If Button = 2 Then Dim r As New MapObjects2.Extent = r Exit Sub End If ‘Line difference Dim poly As New MapObjects2.GeoEvent ProgrammersReference. You can however use a self-intersecting Line. x _ As Single. 10:00 AM .TrackingLayer.Rectangle Set r = Map1. paste the code into the Declara- tions section of a form containing a Map named Map1 that has at least one MapLayer. XOr Method Example This example uses the Difference method to allow the user to perform Difference operations on polygons. specifying Error 5000. Shift As Integer. SymbolType = moFillSymbol .TrackingLayer. the transformation will occur in the direction implied by the Name of the GeoTransformationConstants. opposite to what the SecondName states.pmd 145 10/28/2004.AddEvent(poly.TrackingLayer. ProgrammersReference. Constant Value Description moDirection_Forward 1 When using a pre-defined transformation.OutlineColor = moGreen End With With Map1.SymbolCount = 2 With Map1.Symbol(1) . When using a user-defined transformation.Style = moGrayFill .Symbol(0) .Color = moGreen . MapObjects Programmer’s Reference 145 Set poly = Map1. the transformation will go from the GeoCoordSys defined by the FromGeoCoordSys property to that defined in the ToGeoCoordSys property.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.TrackingLayer. If a SecondType is used then by default the direction of the second stage transformation will be reverse. that is.TrackingLayer.SymbolType = moFillSymbol .TrackPolygon Set eventLine = Map1.Style = moGrayFill . 10:00 AM .Color = moBlue . 0) Call doDifference(poly) End Sub Private Sub Form_Load() diff = False Map1. 146 MapObjects Programmer’s Reference moDirection_Reverse 0 When using a pre-defined transformation. Syntax object. See Also GeoTransformation Object Direction Property Applies To GeoTransformation Object Description Sets or returns a value that identifies the Direction of the GeoTransformation. (i. as described in Settings Settings The settings for dirConstant are DirectionConstants. paste the code into the Declarations section of a new Form which has two Map controls named Map1 and Map2. the transformation will occur in the opposite direction to that implied by the Name or SecondName of the GeoTransformationConstants.Direction [= dirConstant ] The Direction property syntax has these parts: Part Description object An object expression that evaluates to a GeoTransformation object. To try this example.pmd 146 10/28/2004. you should set the Direction property to the appropriate direction for the transformation you require. Each Map should contain a MapLayer with geographical locations in common. If you are using two different Type’s on the GeoTransformation. Remarks If you are using only one GeoTransformation Type. the Direction property is forward and the SecondDirection is reverse. By default. Ensure the coordinate systems of each MapLayer are set appropriately. See Also GeoCoordSys Object Example This example demonstrates the Direction property of the GeoTransformation object.e. but it is possible to do so. dirConstant A numeric expression that specifies the Direction of the GeoTransformation. 10:00 AM . It should not be necessary to specify a direction of Reverse when using a user-defined transforma- tion. you have set both Type and SecondType) you should set both the Direction and SecondDirection properties appro- priately. ProgrammersReference. 10:00 AM . and click on either Map. The point will be transformed to the other maps coordinate system.Type = moGeoTransformation_OSGB1936_To_WGS1984_1 ‘Set the appropriate direction.CoordinateSystem.direction = direction ‘A CoordinateSystem may be either ProjCoordSys or GeoCoordSys.Point Dim curMap As Integer Dim sym As New MapObjects2.Point) As Point ‘Here. ‘We need to check if the type before assigning the FromGeoCoordSys ‘and ToGeoCoordSys Dim map1Projected As Boolean Dim map2Projected As Boolean If Map1.CoordinateSystem.IsProjected Then map2Projected = True Else map2Projected = False End If ‘If changing from WGS1984 to other datum If direction = moDirection_Forward Then If map1Projected Then myGT. Option Explicit Dim fromPt As New MapObjects2.GeoTransformation myGT. _ DirectionConstants.IsProjected Then map1Projected = True Else map1Projected = False End If If Map2. an appropriate GeoTransformation is created for transforming ‘the selected Point.FromGeoCoordSys = Map1. FromGeoCoordSys and ToGeoCoordSys myGT.FromGeoCoordSys = Map1. This should be changed appropriately for the ‘CoordinateSystem of your Map2 MapLayer.pmd 147 10/28/2004.GeoCoordSys Else myGT.CoordinateSystem End If If map2Projected Then ProgrammersReference. and displayed on both maps.Symbol Private Function transformPoint(direction As MapObjects2.Point Dim toPt As New MapObjects2. ptIn As MapObjects2. Dim myGT As New MapObjects2.CoordinateSystem. MapObjects Programmer’s Reference 147 Then press F5. ToMapPoint(X.FromGeoCoordSys = Map2.CoordinateSystem End If Set transformPoint = Map1.ToGeoCoordSys = Map2. sym End If End Sub Private Sub Map1_MouseDown(Button As Integer.Transform( _ Map2.OLE_HANDLE) If (Not fromPt Is Nothing) And curMap = 1 Then sym. Y) Set toPt = transformPoint(moDirection_Forward.Refresh (True) End Sub ProgrammersReference.GeoCoordSys Else myGT.DrawShape fromPt.GeoCoordSys Else myGT.Color = moBlue Map1.CoordinateSystem. 148 MapObjects Programmer’s Reference myGT. X _ As Single.ToGeoCoordSys = Map2.CoordinateSystem.CoordinateSystem.TrackingLayer. sym End If If (Not toPt Is Nothing) And curMap = 2 Then sym. Y As Single) Set fromPt = Map1.Transform _ (Map1.Refresh (True) Map2.ToGeoCoordSys = Map1.ToGeoCoordSys = Map1. fromPt.FromGeoCoordSys = Map2.CoordinateSystem.CoordinateSystem. myGT) End If End Function Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ stdole. Shift As Integer. 10:00 AM .CoordinateSystem End If If map2Projected Then myGT.TrackingLayer.CoordinateSystem.CoordinateSystem End If Set transformPoint = Map2. fromPt.GeoCoordSys Else myGT. . fromPt) curMap = 1 Map1. .Color = moRed Map1.pmd 148 10/28/2004.DrawShape toPt.CoordinateSystem. myGT) ElseIf direction = moDirection_Reverse Then If map1Projected Then myGT. TrackingLayer. X _ As Single. Shift As Integer.Type = moProjCS_BritishNationalGrid Map2. Y As Single) Set fromPt = Map2.Refresh (True) End Sub Private Sub Form_Load() ‘Map1 should contain a MapLayer based on the WGS1984 Datum. MapObjects Programmer’s Reference 149 Private Sub Map2_AfterTrackingLayerDraw(ByVal hDC As _ stdole. ‘for example the World Countries sample dataset.Layers(0).DrawShape toPt. Y) Set toPt = transformPoint(moDirection_Reverse.Color = moRed Map2.CoordinateSystem = gcs ‘Here the CoordinateSystem of each map is set to the ‘CoordinateSystem of its MapLayer Map1.Style = moTriangleMarker End With ProgrammersReference. 10:00 AM .Layers(0). ‘Map2 should contain a MapLayer based on a different Datum ‘You should ensure the CoordinateSystem of both layers is set ‘correctly. fromPt) curMap = 2 Map1.TrackingLayer.CoordinateSystem = pcs Dim gcs As New MapObjects2. sym End If End Sub Private Sub Map2_MouseDown(Button As Integer.CoordinateSystem Map2. Dim pcs As New MapObjects2.pmd 149 10/28/2004.CoordinateSystem With sym .Refresh (True) Map2.Layers(0).ProjCoordSys pcs.Layers(0).GeoCoordSys gcs.Color = moBlue Map2.DrawShape fromPt. sym End If If (Not toPt Is Nothing) And curMap = 1 Then sym.ToMapPoint(X.Outline = False .Size = 4 .OLE_HANDLE) If (Not fromPt Is Nothing) And curMap = 2 Then sym.SymbolType = moPointSymbol .Type = moGeoCS_WGS1984 Map1.CoordinateSystem = Map1.CoordinateSystem = Map2. Map1.Disconnect The Disconnect method syntax has these parts: Part Description object An object expression that evaluates to a DataConnection object.DistanceTo( shape) The DistanceTo method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Top + Map2. Points Collection. Polygon Object. Line Object. 5000. See Also Connect Method. ProgrammersReference. Rectangle Object Description Returns the distance in map units between two objects.Width = Map2. Connected Property Example See Connected property DistanceTo Method Applies To Point Object. Syntax object. Syntax object.Left + Map1.Move 60.Height + 60 End Sub Disconnect Method Applies To DataConnection Object Description Terminates a connection to a DataConnection. Remarks The Disconnect method should always be used to Disconnect from an SDE server before the application ends.Top. 5000 Map2. 150 MapObjects Programmer’s Reference ‘Arrange controls Map1.Width + 100.pmd 150 10/28/2004.Left + Map2.Height Form1.Move Map1. 60. 10:00 AM . Map1. _ Map1.Width + 60 Form1.Width.Height = Map2. or Rectangle object.Center. Option Explicit Private Sub Command1_Click() Dim lDist As Long Dim oMypt As Point If Map1.Y lDist = Map1. MapObjects Programmer’s Reference 151 shape An object expression that evaluates to a Point.X = .DistanceTo(oMypt) MsgBox “It’s “ & Str(lDist) & “units from the center of the _ map to the first GeoEvent. 0 ElseIf Button = 2 Then ProgrammersReference. See Also DistanceToSegment Method Example This example uses the DistanceTo method to measure the distance between the center of the Map and the first GeoEvent on the Map object’s TrackingLayer. To determine the distance.Y = .AddEvent oPoint.Point oMypt. and then press F5 and click the Map to add a GeoEvent. 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.” _ & Chr(13) & “Please click on the map to add a geoevent. Polygon.pmd 151 10/28/2004.TrackingLayer.Point Set oPoint = Map1. except for Polygon objects. click Command1.TrackingLayer. Y As Single) If Button = 1 Then Dim oPoint As MapObjects2. Remarks The DistanceTo method will return true 3D distances between shapes that support Z values. Shift As Integer.Event(0) Dim oMypt As New MapObjects2.TrackingLayer.EventCount > 0 Then With Map1. 10:00 AM .” End With Else MsgBox “There are curently no events in your tracking layer.ToMapPoint(X.Extent. To try this example. and a right-click will allow the user to track a polygon. Line. for which the shortest distance from the other shape to the nearest edge of the Polygon is returned instead.X oMypt. A left-click will add a point event. X _ As Single. and add this polygon as an event.” End If End Sub Private Sub Map1_MouseDown(Button As Integer. Points. Y) Map1. Size = 8 End With With Map1.TrackingLayer.SymbolCount = 2 With Map1. Point2 An object expression that evaluates to a Point object. Points Property Example This example uses the DistanceToSegment method to return the distance from a Point to two points that constitute a line segment. 152 MapObjects Programmer’s Reference Dim poly As New MapObjects2.SymbolType = moPointSymbol . Point1 An object expression that evaluates to a Point object. 10:00 AM .Polygon Set poly = Map1.Color = moRed . Point2) The DistanceToSegment method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. paste the code into the Declarations ProgrammersReference. 1 End If End Sub Private Sub Form_Load() Map1.DistanceToSegment( Point1.TrackingLayer.SymbolType = moFillSymbol .Color = moRed .Symbol(1) . Syntax object.AddEvent poly.TrackingLayer.TrackingLayer. To try this example.pmd 152 10/28/2004.Style = moGrayFill End With 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.Symbol(0) .TrackPolygon Map1. See Also Line Object. X = oRect.Symbol If Not moLine Is Nothing Then oLnSym. oLnSym End If If Not moPoint Is Nothing Then oPtSym.line Dim moPoints As New MapObjects2.Right oPoint2.Top = 100 Map1.Style = moCircleMarker Map1. Option Explicit Dim moLine As New MapObjects2.Y = oRect. then press F5 and click the Map to position a point.DrawShape moPoint.Y = oRect.Symbol Dim oPtSym As New MapObjects2.SymbolType = moPointSymbol oPtSym.Left oPoint1.Color = moBlue oPtSym. The code reports the distance to the line segment. oPtSym End If End Sub ProgrammersReference.Parts.Top moPoints.Bottom = 0: oRect.Point Private Sub Form_Load() Dim oRect As New Rectangle Dim oPoint1 As New MapObjects2.Point oRect.Left = 0: oRect.SymbolType = moLineSymbol oLnSym.OLE_HANDLE) Dim oLnSym As New MapObjects2.Bottom oPoint2.Points Dim moPoint As MapObjects2.Color = moRed Map1.Add oPoint2 moLine.Extent = oRect oPoint1.Add moPoints End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.X = oRect. 10:00 AM . MapObjects Programmer’s Reference 153 section of a form containing a Map named Map1.DrawShape moLine.Add oPoint1 moPoints.pmd 153 10/28/2004.Point Dim oPoint2 As New MapObjects2.Right = 100: oRect. Refresh True MsgBox Format(fDist. “fixed”) & “ units to the segment” End Sub DotColor Property Applies To DotDensityRenderer Object Description Returns or sets the color of each of dot of a DotDensityRenderer object. 10:00 AM .DotDensityRenderer Dim oStats As MapObjects2. X As _ Single. 154 MapObjects Programmer’s Reference Private Sub Map1_MouseDown(Button As Integer. Option Explicit Private Sub Command1_Click() Dim oDotRend As New MapObjects2. a TextBox named Text1. Syntax object. To try this example.TrackingLayer. moPoints(1)) Map1. Settings For more information on color settings. paste the code into the Declarations section of a form containing a CommonDialog control. and a Map named Map1 that contains one MapLayer with polygon features. Shift As Integer.ToMapPoint(X. see ColorConstants.pmd 154 10/28/2004.Statistics With Map1.Layers(0) Set . DotValue Property Example This example uses the DotColor property to control the color of the dots in a Dot Density map. Y As Single) Dim fDist As Double Set moPoint = Map1. Y) fDist = moPoint. a ListBox named List1. Press F5 and click the button. See Also DotSize Property.DistanceToSegment(moPoints(0).DotColor [= color] The DotColor property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. a Label named Label1.Renderer = oDotRend ProgrammersReference. color A value or constant that determines the color of the dots used by the renderer. a CommandButton named Command1. Left .Text .Field = List1.ListIndex) .Max .Field Set oRecset = Map1.DotColor = CommonDialog1.Label1.Height * 1.Top + Text1.ListIndex)) Text1.pmd 155 10/28/2004.Height End With With Command1 .DotValue = Text1.Caption = “1 dot equals this many units:” .oStats.Fields If oField.DotSize = 4 .Records For Each oField In oRecset.AutoSize = True .ShowColor ‘get the DotColor from the Color dialog With oDotRend .Left = Text1.AddItem oField.Text = (oStats.Min + (oStats.CalculateStatistics _ (List1. 10:00 AM .Layers(0).Top .List(List1.Top = Text1.Left = Text1.Color .Records.Min) / 2) / 20 End With CommonDialog1.Type < moDate Then ‘numeric fields List1.DrawBackground = True End With Map1.Caption = “Draw Dots” .Name End If Next With Text1 .List(List1.Top = Text1.Left . MapObjects Programmer’s Reference 155 Set oStats = .Text = “” .Refresh Set oDotRend = Nothing ‘disassociate object End Sub Private Sub Form_Load() Dim oRecset As MapObjects2.Locked = True End With With Label1 .5 ProgrammersReference.Recordset Dim oField As MapObjects2. 156 MapObjects Programmer’s Reference . See Also DotColor Property.pmd 156 10/28/2004. here’s one way to create a DotDensityRenderer: Set Map1. specified value in the Field property of the DotDensityRenderer as specified in its DotValue property. value A numeric expression that specifies the size in points to draw the dots. 10:00 AM . ValueMapRenderer Object Properties DotColor DotValue Field DotSize DrawBackground Tag DotSize Property Applies To DotDensityRenderer Object Description Returns or sets the size of each dot of a DotDensityRenderer object.DotSize [= value] The DotSize property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. DotValue Property ProgrammersReference.Renderer = New MapObjects2. Each dot represents a uniform. A DotDensityRenderer is a creatable object in MapObjects.Enabled = True End Sub DotDensityRenderer Object A DotDensityRenderer is an object that represents a way of symbolizing features by drawing dots on a feature.DotDensityRenderer See Also ChartRenderer Object.Layers(0). ClassBreaksRenderer Object. In Visual Basic. Syntax object.Enabled = False End With End Sub Private Sub List1_Click() Command1. You can set the color of the dots with DotColor and the size of the dots in points with DotSize. Color = moPaleYellow With Map1.Layers(0). Press F5. ProgrammersReference.SetFocus . 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.Renderer.Text .Layers(0). To try this example.Layers(0). and click the button.Show ‘ must do this in order to use SetFocus in Load With Text1 .SelLength = 1 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.pmd 157 10/28/2004.Renderer = New MapObjects2.Refresh End With End Sub Private Sub Form_Load() Set Map1.Symbol. Option Explicit Private Sub Command1_Click() With Map1 . enter a new value for the DotSize. 10:00 AM .DotValue = 100000 .DotSize = Text1.DotDensityRenderer Map1.Field = “Pop1990” .Layers(0).DotSize = 4 .DotColor = moRed .Renderer . paste the code into the Declarations section of a form containing a TextBox control named Text1.Text = “4” . a CommandButton named Command1 and a Map named Map1 that contains one MapLayer with polygon features.DrawBackground = True End With Me. MapObjects Programmer’s Reference 157 Example This example uses the DotSize property to control the size of the dots in a Dot Density map. Layers(0). DotSize Property Example This example uses the DotValue property to control the value one dot represents in a Dot Density map. Press F5.Text = “100000” With Map1 Set . paste the code into the Declarations section of a form containing a TextBox control named Text1. 158 MapObjects Programmer’s Reference Syntax object.Renderer.Renderer = New MapObjects2. enter a new value for the DotValue. and click the button.DrawBackground = True End With End With Me. a CommandButton named Command1 and a Map named Map1 that contains one MapLayer with polygon features.DotDensityRenderer .pmd 158 10/28/2004.DotColor = moRed . To try this example.DotValue = Text1.Layers(0). Option Explicit Private Sub Command1_Click() With Map1 .Layers(0).Field = “Pop1990” .Text . value A numeric expression that specifies the value in the DotDensityRenderer object’s Field property that one dot represents.Layers(0).Show ‘ must do this in order to use SetFocus in Load With Text1 ProgrammersReference.Renderer .DotSize = 4 .Refresh End With End Sub Private Sub Form_Load() Text1. 10:00 AM .Symbol.Color = moPaleYellow With .DotValue [= value] The DotValue property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.DotValue = Text1. See Also DotColor Property.Text . You may want to change the Field property from “Pop1990” to the name of a numeric field appropriate to your data. MapObjects Programmer’s Reference 159 . Syntax Private Sub object_DragDrop(source As Control. source The object being dragged. X A value of Single data type. specifying the Y coordinate of the mouse click. 10:00 AM . Remarks For more information about the DragDrop event. in control units. See Also DragFiles 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. in control units. ToMapPoint Method DragFiles Event Applies To Map Object Description Occurs when a drag-and-drop operation of filenames is in progress. Y A value of Single data type.pmd 159 10/28/2004.SelLength = Len(Text1. leaves.Text) End With End Sub DragDrop Event Applies To Map Object Description The DragDrop event is a standard ActiveX control event. y As Single) The DragDrop event syntax has these parts: Part Description object An object expression that evaluates to a Map control. You can use this event to monitor the mouse pointer as it enters. which occurs when an object is dragged over a Map control and the mouse button is released.SetFocus . The mouse pointer position determines the target object that receives this event. specifying the X coordinate of the mouse click. or rests directly over a valid target. ProgrammersReference. x As Single. which may then be added programmatically to the Layers collection. the code adds the shapefiles as MapLayer objects. Note that the DragFiles event is not supported for Map controls with a WindowMode of Windowless Opaque or Windowless Transparent. sorted by ShapeType. ByVal y As Single. Settings The settings for state are DragStateConstants. paste the code into the Declarations section of a form containing a Map named Map1. 10:00 AM .Count > 0 Then dropValid = True End If ProgrammersReference. 160 MapObjects Programmer’s Reference See Also DragDrop Event.pmd 160 10/28/2004. ByVal state As Integer. Press F5 and then click-drag one or more shapefiles from Windows Explorer onto the Map. 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. dropValid A boolean expression that indicates whether the target is valid. fileNames An object expression that evaluates to a Strings collection whose members represent the names of the files that are being dragged. DropFiles Event. ByVal X _ As Single. ByVal x As Single. ByVal Y As Single. x. dropValid must be set to True when appropriate. dropValid _ As Boolean) If fileNames. Option Explicit Private Sub Map1_DragFiles(ByVal fileNames As Object. To try this example. Strings Collection Syntax Private Sub object_DragFiles(ByVal fileNames As Object. y A number that specifies the current horizontal (x) and vertical (y) position of the mouse pointer within the target object. dropValid As Boolean) The DragFiles event syntax has these parts: Part Description object An object expression that evaluates to a Map. After you release the mouse. 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. ByVal state As Integer. The DragFiles event should be used for dragging the names of valid GeoDatasets onto the Map control. ByVal X _ As Single.Connect Then For i = 0 To fileNames. Len(shpfile) .4)) ml.Count .Layers(i).Add Map1.MapLayer Dim l As MapObjects2.Add Map1.Layers(i) End If Next i Map1.Item(0). MapObjects Programmer’s Reference 161 End Sub Private Sub Map1_DropFiles(ByVal fileNames As Object.Count .Layers.MapLayer Dim p As MapObjects2. Len(fileNames.Add ml Next i ‘prepare collections to sort layers Dim ptcoll As New Collection Dim linecoll As New Collection Dim polycoll As New Collection Dim imgcoll As New Collection For i = 0 To Map1.DataConnection Dim shpfile As Variant Dim i As Integer Dim ml As MapObjects2.shapeType Case 21 ‘point features ptcoll.LayerType = moMapLayer Then Select Case Map1.Len(shpfile) . vbDirectory)) shpfile = CStr(Left(shpfile.Database = Left(fileNames.Layers(i). vbDirectory) shpfile = CStr(Left(shpfile.Layers.Layers(i) Case 23 ‘polygon features polycoll.GeoDataset = dcx.4)) dcx.MapLayer shpfile = Dir(fileNames.Clear ProgrammersReference. ByVal Y As Single) Dim dcx As New MapObjects2.MapLayer shpfile = (Dir(fileNames.Add Map1.Layers(i) End Select Else imgcoll.Item(0).Layers(i) Case 22 ‘line features linecoll.FindGeoDataset(shpfile) Map1. Len(shpfile) .Item(0)) _ .5) If dcx.Layers. 10:00 AM .Add Map1.1 Set ml = New MapObjects2.Item(i).pmd 161 10/28/2004.1 ‘Check if its a MapLayer or Imagelayer If Map1. pol. ln. which occurs when an object is dragged over a Map control. in control units. pt As Object For Each il In imgcoll Map1.Extent = Map1. in control units. specifying the X coordinate of the mouse click.Add pt Next pt End If Map1. 10:00 AM .Layers. Syntax Private Sub object_DragOver(source As Control.Add ln Next ln For Each pt In ptcoll Map1. specifying the Y coordinate of the mouse click. Y A value of Single data type. ProgrammersReference.Layers.Add il Next il For Each pol In polycoll Map1.FullExtent Map1.pmd 162 10/28/2004.Add pol Next pol For Each ln In linecoll Map1. x As Single. y As Single. state As Integer) The DragOver event syntax has these parts: Part Description object An object expression that evaluates to a Map control.Refresh End Sub DragOver Event Applies To Map Object Description The DragOver event is a standard ActiveX control event.Layers. source The control being dragged. 162 MapObjects Programmer’s Reference ‘add all the layers back in sorted by type Dim il.Layers. X A value of Single data type. See Also DragFiles Event. See Also DragFiles Event. Constant Value Description moDragEnter 0 Enter (fileNames are being dragged within the range of the Map). MapObjects Programmer’s Reference 163 state A value that corresponds to the transition state of the control being dragged in relation to a target form or control. GroupRenderer Object. Map Object DrawBackground Property Applies To DotDensityRenderer Object. DropFiles Event. moDragLeave 1 Leave (fileNames are being dragged out of the range of the Map). LabelRenderer Object ProgrammersReference. Note that the DragOver event is not supported for Map controls with a WindowMode of Windowless Opaque or Windowless Transparent. EventRenderer Object. LabelPlacer Object. 10:00 AM . ToMapPoint Method DragState Constants MapObjects defines the following constants for use with the Map object’s DragFiles event. see Values below. see the Visual Basic online reference. moDragOver 2 Over (fileNames have moved from one position in the Map to another).pmd 163 10/28/2004. Values The state parameter may have the following values: Value Action Description 0 Enter source control is being dragged within the range of a target 1 Leave source control is being dragged out of the range of a target 2 Over source control has moved from one position in the target to another Remarks For more information about the DragOver event. 164 MapObjects Programmer’s Reference Description Returns or sets a value indicating whether a renderer displays a map’s background fill and polygon outline.Layers(0). See Also Symbol Object Example This example uses the DrawBackground property to control the background of a Dot Density map.Symbol.CalculateStatistics _ (List1. Syntax object.Statistics Dim oRenderer As New MapObjects2.Color = moPaleYellow Set oStats = Map1.Renderer = oRenderer Map1. 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. paste the code into the Declarations section of a form containing a Label named Label1. a CheckBox named Check1. a ListBox named List1.pmd 164 10/28/2004. To try this example. Option Explicit Private Sub List1_Click() Dim oStats As MapObjects2. a TextBox named Text1.List(List1.DotDensityRenderer Set Map1. Press F5 and click the name of a field.Layers(0).DrawBackground [= value] The DrawBackground property syntax has these parts: Part Description object An object expression that evaluates to a renderer object.ListIndex)) ProgrammersReference. value A boolean expression that determines whether the back color and polygon outline display.Records. You may wish to make use of this property when using a custom renderer. and a Map named Map1 that contains one MapLayer with polygon features that have statistical data associated with them. as when the DrawBackground property is True. You can toggle the DrawBackground property with the CheckBox. the Map will take care of drawing features. Remarks The DrawBackground method is implemented by all renderers. as described in Settings. 10:00 AM . Settings The settings for value are: Setting Description True The renderer object’s back color and polygon outline display.Layers(0). False The renderer object’s back color and polygon outline do not display. pmd 165 10/28/2004.Left .Left = Text1.AutoSize = True .Fields If oField.ListIndex <> -1 Then ‘set a field first List1_Click End If End Sub Private Sub Form_Load() Dim oRecset As MapObjects2.DotSize = 4 .Locked = True .Type < moDate Then ‘numeric fields List1.DotColor = moRed .Label1.oStats.DotValue = Text1.Layers(0).Caption = “Draw background” .Refresh End Sub Private Sub Check1_Click() If List1.Value = 1 ‘initialize DrawBackground to True ProgrammersReference.ListIndex) .DrawBackground = Check1.Text = “” End With With Label1 .Top = Text1.Text . 10:00 AM .AddItem oField.Text = (oStats.Field Set oRecset = Map1.Value End With Map1.Top = Text1.Height .Top + Text1.Left = Text1.Min) / 2) / 20 With oRenderer .Left .Min + (oStats.Max .List(List1.Records For Each oField In oRecset.Top .Recordset Dim oField As MapObjects2.Height End With With Check1 .Caption = “1 dot equals this many units:” .Field = List1.name End If Next oField With Text1 . MapObjects Programmer’s Reference 165 Text1. Extent.Font = fnt Map1. BeforeTrackingLayerDraw Event Example This example demonstrates one way to use the DrawError event if the application can’t draw the specified MapLayer because another application has opened the associated Recordset for writing. Create an executable that edits the same GeoDataset as the one associated with the MapLayer. paste the code into the Declarations section of a form containing a Map named Map1 that contains a MapLayer.Name = “Times” fnt. BeforeLayerDraw Event.Name _ & “‘“. Option Explicit Private Sub Map1_DrawError(ByVal index As Integer) Dim fnt As New StdFont fnt. To try this example. 166 MapObjects Programmer’s Reference End With End Sub DrawError Event Applies To Map Object Description Occurs when a Map cannot draw the specified MapLayer. Syntax Private Sub object_DrawError(ByVal index As Integer) The DrawError event syntax has these parts: Part Description object An object expression that evaluates to a Map. See Also AfterLayerDraw Event. s End Sub ProgrammersReference.Size = 14 Dim s As New TextSymbol Set s.pmd 166 10/28/2004.Layers(index). Run the editing application and then run this example.DrawText “Data Unavailable for ‘“ & Map1. Map1. index An integer that uniquely identifies the member of the MapLayers collection that can not be drawn. AfterTrackingLayerDraw Event. 10:00 AM . AfterTrackingLayerDraw Event. MapObjects Programmer’s Reference 167 DrawingCanceled Event Applies To Map Object Description Occurs after you perform a CancelAction on a Map or a MapLayer.pmd 167 10/28/2004.Extent rect. 10:00 AM . See Also AfterLayerDraw Event. You can use Command1 to zoom to the full extent of the map.Extent = Map1.Rectangle Set rect = Map1. 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.FullExtent End Sub DrawShape Method Applies To Map Object Description Draws a shape on a Map. Option Explicit Private Sub Map1_DrawingCanceled() Dim response As Variant response = MsgBox(“The map is in an incomplete state. To try this example. press the ESC key.Extent = rect End If End Sub Private Sub Command1_Click() Map1.1 Map1. and then press F5. Syntax object. While the map is drawing. vbYesNo) If response = vbYes Then Dim rect As New MapObjects2.DrawShape shape.ScaleRectangle 0. BeforeLayerDraw Event. BeforeTrackingLayerDraw Event Example This example demonstrates the role of the DrawingCanceled event if the user presses ESC while the map is drawing. Syntax Private Sub object_DrawingCanceled() The object placeholder represents an object expression that evaluates to a Map. symbol ProgrammersReference. _ Zoom in?”. See Also Point Object. Option Explicit Dim rect As MapObjects2. An object expression that evaluates to an object in the Applies To list. Rectangle Object. Polygon or Ellipse) or a Recordset object. the method positions the Recordset at the first record and then draws each feature stored in the Shape field. 10:00 AM . Points Object.Refresh True End Sub ProgrammersReference. Polygon Object Example This example uses the DrawShape method to draw a shape on the Map. DrawShape positions the Recordset at the first record again. sym End If End Sub Private Sub Map1_MouseDown(Button As Integer.pmd 168 10/28/2004. not from a Table object. Line.Symbol If Not rect Is Nothing Then sym. At the end of the call.TrackingLayer.Color = moBlue Map1. 168 MapObjects Programmer’s Reference The DrawShape syntax has the following object qualifier and arguments: Part Description object Required.DrawShape rect. Shift As Integer. Points. Ellipse Object. To try this example. Remarks Invoke the DrawShape method in a Layer or TrackingLayer drawing event. paste the code into the Declarations section of a form containing a Map named Map1. If you specify a Recordset as the shape argument for DrawShape. The Recordset must be derived from a GeoDataset.Rectangle Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ stdole. Rectangle. Line Object.SymbolType = moFillSymbol sym.Style = moDiagonalCrossFill sym. symbol An object expression that evaluates to a Symbol object.TrackRectangle Map1. Y As Single) Set rect = Map1.OLE_HANDLE) Dim sym As New MapObjects2. X _ As Single. Press F5 and then click-drag a rectangle on the map. shape An object expression that evaluates to a geometric shape (Point. otherwise MapObjects returns an error. Note that the height parameter for DrawText is set to 0. If shape is a Rectangle object. then the text will be positioned at the center of the extent of all points in the collection. a Line object. MapObjects ignores the VerticalAlignment property and aligns the text horizontally with the center point of the Rectangle. text A string expression specifying the text to draw.pmd 169 10/28/2004. symbol An object expression that evaluates to a TextSymbol object. symbol The DrawText syntax has the following object qualifier and arguments: Part Description object Required. Syntax object.DrawText text. a Rectangle object or a Points object. MapObjects Programmer’s Reference 169 DrawText Method Applies To Map Object Description Draws text on a Map. DrawText splines the text. Invoke the DrawText method in a Layer or TrackingLayer drawing event. MapObjects centers the text on the point. and then press F5. otherwise MapObjects returns an error. using the coordinates of the Line as a guide. 10:00 AM .Name = “Arial” ProgrammersReference. An object expression that evaluates to an object in the Applies To list. Option Explicit Dim textsym As New MapObjects2. If shape is a Points object. shape An object expression that evaluates to a Point object. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. If shape is a Point object. See Also TextSymbol Object Example This example uses the DrawText method to draw some text on the Map. To try this example.TextSymbol Private Sub Form_Load() Dim fnt As New StdFont fnt. Remarks If shape is a Line object. therefore the code will draw the text using the Size property of the TextSymbol object’s Font. shape. Font = fnt With textsym .Extent. Strings Collection ProgrammersReference. See Also AfterLayerDraw Event.pmd 170 10/28/2004. Map1. 170 MapObjects Programmer’s Reference fnt. x. BeforeTrackingLayerDraw Event. Syntax Private Sub object_DropFiles(ByVal fileNames As Object. ByVal x As Single. AfterTrackingLayerDraw Event. BeforeLayerDraw Event. ByVal _ canceled As Boolean.Height = 0 ‘use font size (36 points in this case) .DrawText “MapObjects”. ByVal y As Single) The DropFiles event syntax has these parts: Part Description object An object expression that evaluates to a Map. textsym 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. dropValid must be set to True in the DragFiles event when appropriate. Remarks In order for the DropFiles event to occur.VerticalAlignment = moAlignBaseline End With End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer.Center. Note that the DropFiles event is not supported for Map controls with a WindowMode of Windowless Opaque or Windowless Transparent.OLE_HANDLE) Map1.Size = 36 Set textsym.Color = moLightGray . fileNames An object expression that evaluates to a Strings collection whose members represent the names of the files that are being dragged. y A number that specifies the current horizontal (x) and vertical (y) position of the mouse pointer within the target object. 10:00 AM . ByVal hDC As stdole. The following Visual Basic example shows how this can be done for a given MapLayer. When you call the Edit method.Update Else MsgBox “Edit failed.pmd 171 10/28/2004. the EditMode property changes to moEditInProgress.Updatable Then recs. MapObjects Programmer’s Reference 171 Example See DragFiles Event Edit Method Applies To Recordset Object Description Allows edits for the current record. 10:00 AM . The safest approach is to create a local Recordset object. Remarks Your application should check the Updatable property before calling Edit to determine whether changes can be made to the 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. called new_layer: Dim recs As MapObjects2.EditMode = moEditInProgress Then ‘ Edit feature and attributes recs. Delete Method.Edit The Edit method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object.” End If End If Example See CancelUpdate Method ProgrammersReference. This can be used by your application to determine whether changes are being made to a Recordset. See Also Update Method. EditMode Property Syntax object.Edit If recs.Records If recs. on which all the editing operations are carried out.Recordset Set recs = new_layer. Constant Value Description moEditNone 0 No editing operation is in progress. 10:00 AM .pmd 172 10/28/2004. 172 MapObjects Programmer’s Reference EditMode Constants MapObjects defines the following constants for use with the Recordset object’s EditMode property. EditMode Property Example See CancelUpdate Method ProgrammersReference. moEditAdd 2 AddNew method has been invoked.EditMode The EditMode property syntax has these parts: Part Description object An object expression that evaluates to a Recordset object. Delete Method. and the current record is in the copy buffer. Recordset Object Example See CancelUpdate Method EditMode Property Applies To Recordset Object Description Returns a value that indicates the state of editing for the current record Syntax object. and the current record in the copy buffer is a new record that has not been saved in the database. Return Values The EditMode property returns EditModeConstants See Also Edit Method. See Also Field Object. Update Method. moEditInProgress 1 Edit method has been invoked. pmd 173 10/28/2004. The MapLayer object’s TrackCircle method returns an Ellipse.Ellipse Properties Bottom Height Right Top Center Left ShapeType Width Extent Methods Buffer Inset IsPointIn Union Difference Intersect Offset XOr See Also TrackCircle Method Enabled Property Applies To Map Object Description Returns or sets a value that determines whether an object can respond to user-generated events. The Center of an Ellipse object is a Point that is the center of the bounding Rectangle that defines its Extent. You can create an Ellipse object in Visual Basic with code like this: Set el = New MapObjects2. Syntax object. ProgrammersReference. as described in Settings. boolean A boolean expression specifying whether object can respond to user- generated events. 10:00 AM . MapObjects Programmer’s Reference 173 Ellipse Object An Ellipse object represents an elliptical geometric shape.Enabled [= boolean] The Enabled property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. EnableGIF (licenseCode) The EnableGIF method syntax has the following parts: Part Description object An object expression that evaluates to an object in the Applies To list. you can disable a Map that does not apply to the current state of the application.EnableGIF “ABC1234567” ‘invalid code .for illustration only End Sub See Also ImageLayer Object ProgrammersReference. licenseCode A string expression evaluating to the license code for GIF reading Remarks In order to use a GIF image as an ImageLayer. Remarks The Enabled property allows a Map to be enabled or disabled at run time. such as in the Initialize or Load event of a form (Form_Initialize or Form_Load in Visual Basic).pmd 174 10/28/2004. Follow the procedures included with your product packaging for obtaining a valid license code. you must invoke the EnableGIF method at the start of your application code. False Prevents object from responding to events. 174 MapObjects Programmer’s Reference Settings The settings for boolean are: Setting Description True (Default) Allows object to respond to events. Here is how you would invoke EnableGIF: Private Sub Form_Load() Map1. Syntax object. 10:00 AM . See Also Visible Property EnableGIF Method Applies To Map Object Description Enables use of GIF reading when supplied with a valid license code. For example. EnableTIFFLZW (licenseCode) The EnableTIFFLZW method syntax has the following parts: Part Description object An object expression that evaluates to an object in the Applies To list. MapObjects Programmer’s Reference 175 EnableTIFFLZW Method Applies To Map Object Description Enables use of TIFF LZW compression for image layers when supplied with a valid license code. 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.EnableTIFFLZW “ABC1234567” ‘invalid code-for illustration only End Sub See Also ImageLayer Object EndMeasureField Property Applies To EventRenderer Object Description Returns or sets the field which specifies at which Measure value. you must invoke the EnableTIFFLZW method at the start of your application code. 10:00 AM . Here is how you would invoke EnableTIFFLZW: Private Sub Form_Load() Map1. Syntax object. such as in the Initialize or Load event of a form (Form_Initialize or Form_Load in Visual Basic). an event ends.EndMeasureField [= fieldname] The EndMeasureField property syntax has these parts: ProgrammersReference. Syntax object. Follow the procedures included with your product packaging for obtaining a valid license code. along a Line feature.pmd 175 10/28/2004. value A string expression evaluating to the Field property of the EventTable of an EventRenderer which defines the measure at which an event ends. See Also StartMeasureField Property. FeatureRouteIDField Property Example See EventRenderer Object EnhancedGeocodingError Constants MapObjects defines the following constants for use with the Geocoder and Standardizer object’s LastError property. Remarks The EndMeasureField property is only used for rendering Line events. the EndMeasureField is ignored. 10:00 AM . 176 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to a EventRenderer.pmd 176 10/28/2004. EventRouteIDField Property. If you have specified SymbolType to be moPointSymbol. Constant Value Description mgErrorNone 0 No error mgErrorUnknown 1 Unknown error mgErrorInternal 2 Internal error mgErrorMatchRulesUnspecified 3 Match rules unspecified mgErrorIntersectionMatchRulesUnspecified 4 Intersection match rules unspecified mgErrorStandardizerUnspecified 5 Standardizer unspecified mgErrorStreetTableUnspecified 6 Street table unspecified mgErrorStandardizationRulesUnspecified 7 Standardization rules unspecified mgErrorStandardizerInvalid 8 Specified Standardizer is invalid mgErrorCannotOpenMatchRules 9 Cannot open match rules ProgrammersReference. pmd 177 10/28/2004. MapObjects Programmer’s Reference 177 mgErrorNoMatchVariables 10 Cannot find match variables mgErrorOutOfMemory 11 Out of memory mgErrorMatchRulesSyntax 12 Error in match rules syntax mgErrorMatchRulesWarningsTriggered 13 Match rules warnings triggered mgErrorNoCandidates 14 No candidates mgErrorTooManyHandlesAllocated 15 Too many handles allocated mgErrorNoAddressStandardized 16 No address standardized mgErrorCannotAccessDatabase 17 Cannot access database mgErrorCannotOpenStandardizationRules 18 Cannot open standardiza- tion rules mgErrorStandardizationRulesProcessing 19 Error processing standard- ization rules mgErrorCannotReadStandardizationRules 20 Cannot read standardiza- tion rules mgErrorCannotAccessAddressFile 21 Cannot access address file mgErrorCannotWriteOutputDatabase 22 Cannot write to output database mgErrorMatchVariableKeyFieldUnspecified 23 Match variable key field are unspecified mgErrorStreetTableIndexMissing 24 Street table is missing a geocoding index mgErrorRecordCountMismatch 25 Record count mismatch in building the indices mgErrorNoIndicesSpecified 26 No indices were specified to build mgErrorTooManyIndicesSpecified 27 Too many indices speci- fied (the maximum is 10) ProgrammersReference. 10:00 AM . use less keys (or Soundex searches) mgErrorNoQueries 32 No search queries given mgErrorOutOfDiskSpace 33 Out of disk space See Also Geocoder Object. isEnd A boolean expression indicating the status of the current record.pmd 178 10/28/2004.EOF [=isEnd] The EOF property syntax has these parts: Part Description object An object expression that evaluates to a Recordset object. Return Values The EOF return values are: Value Description True The current record position is after the last record. ProgrammersReference. key information is too complex mgErrorKeyFieldNotFoundInDatabase 30 Could not find specified key field in database mgErrorQueryTooComplex 31 The query is too complex. See Also MoveFirst Method. LastError Property 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. Standardizer Object. see Return Values. 178 MapObjects Programmer’s Reference mgErrorCorruptMetadataInformation 28 Corrupt metadata informa- tion mgErrorMetadataTooLong 29 Metadata string is too long. MoveLast Method. MovePrevious Method Syntax object. 10:00 AM . Use the LastError property to check the type of error. IndexStatus Method Syntax object.pmd 179 10/28/2004. Remarks The MoveNext method should not be called when the EOF property is True. Example See AddIndex Method Event Property Applies To TrackingLayer Object Description Returns a reference to a GeoEvent object on the TrackingLayer.EraseIndices = [erased] The EraseIndices method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Remarks You can use the Geocoder object’s IndexStatus method to check if a valid geocoding file exists before you attempt to remove it. MapObjects Programmer’s Reference 179 False The current record position is on or before the last record. ProgrammersReference. False The index file cannot be removed due to an error. erased A variable declared to be of the boolean data type. 10:00 AM . Example See CancelUpdate Method EraseIndices Method Applies To Geocoder Object Description Removes the geocoding index file associated with a Geocoder object if the file is not read- only. See Also BuildIndices Method. Return Values The EraseIndices method return values are: Part Description True The index file is removed successfully. CharacterIndex = 108 End With With Map1.TrackingLayer.Color = moRed . Option Explicit Private Sub Form_Load() Dim fnt As New StdFont fnt. 10:00 AM .Font = fnt .Bold = False Map1. i As Long If Shift = 0 Then ProgrammersReference.Style = moTrueTypeMarker . See Also GeoEvent Object Example This example uses the Event property to iterate throughout the GeoEvents of a Map’s TrackingLayer in order to determine whether a GeoEvent falls within a selection rectangle.Symbol(1) .CharacterIndex = 108 End With End Sub Private Sub Map1_MouseDown(Button As Integer.Size = 16 . 180 MapObjects Programmer’s Reference Syntax object. and then press F5 and click the map to add GeoEvents.Font = fnt . Then hold down Shift and select some of the GeoEvents. index An Integer data type index that indicates which GeoEvent to reference.Event( index) The Event method syntax has these parts: Part Description object An object expression that evaluates to a TrackingLayer object. Shift As Integer.TrackingLayer. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. To try this example.pmd 180 10/28/2004.Size = 16 . x _ As Single.Style = moTrueTypeMarker .Symbol(0) .SymbolCount = 2 With Map1.Rectangle Dim nEventCount As Long. y As Single) Dim r As MapObjects2.TrackingLayer.Color = moGreen .Name = “Wingdings” fnt. TrackingLayer. See Also GeoEvent Object Example This example uses the EventCount property to keep a running count of the number of GeoEvents on the TrackingLayer of a Map.EventCount Dim testPt As New MapObjects2.x = evt.Point Set pt = Map1.1 Set evt = Map1. count An Integer data type variable that represents the number of GeoEvents on the TrackingLayer. As you add GeoEvents to the TrackingLayer by clicking on the Map.x testPt.pmd 181 10/28/2004.y = evt.TrackingLayer. Syntax object. To try this example.Point Dim evt As MapObjects2.IsPointIn(testPt) Then evt.TrackingLayer. 10:00 AM .AddEvent pt. a Label displays the current count. 0 Else Set r = Map1.ToMapPoint(x.y If r. paste the code ProgrammersReference. y) Map1.GeoEvent For i = 0 To nEventCount .TrackRectangle nEventCount = Map1.EventCount [= count] The EventCount property syntax has these parts: Part Description object An object expression that evaluates to a TrackingLayer object.SymbolIndex = 0 End If Next i Map1.Refresh End If End Sub EventCount Property Applies To TrackingLayer Object Description Returns the number of GeoEvent objects currently on the TrackingLayer. MapObjects Programmer’s Reference 181 Dim pt As MapObjects2.SymbolIndex = 1 Else evt.Event(i) testPt. TrackingLayer. For point events this should be set to the moPointSymbol constant and for linear events.ToMapPoint(x. The type of event to be rendered will depend on the information contained in the EventTable. moLineSymbol. the event is rendered at that measure. When rendering point events.AddEvent pt. y As Single) Dim pt As MapObjects2. only values contained in the StartMeasureField are used. x _ As Single. By setting its ValueCount property you can determine how many values of its SymbolField property the EventRenderer will provide a symbol for. The renderer displays the events in the EventTable by matching the route Id value of each event against the features in the MapLayer. 0 Label1. When rendering line events. 10:00 AM . and then press F5 and click the map. The measure values for an event determine where it will be displayed on the matching feature in the MapLayer. The SymbolField property specifies the field that contains a numeric value to match against the renderer’s symbol array. The FeatureRouteIDField property specifies the field in the MapLayer’s Recordset that contains route ID values and the EventRouteIDField property specifies the field containing route ID values in the EventTable’s Recordset. y) Map1. therefore an EventRenderer can only be applied to a MapLayer consisting of shapes with the Line ShapeType. Shift As Integer. You can specify the type of event that the EventRenderer will symbolize by setting the SymbolType property. 182 MapObjects Programmer’s Reference into the Declarations section of a form containing a Label named Label1 and a Map named Map1 that contains at least one MapLayer.EventCount End Sub Private Sub Form_Load() Label1. Events are only gener- ated on Line objects.Caption = “0” End Sub EventRenderer Object An EventRenderer is an object that represents a way of symbolizing events that occur on features of a MapLayer. The symbols used to display events can be based on values held in the EventTable. the event begins at the measure value in StartMeasureField and continues until the measure value in EndMeasureField.pmd 182 10/28/2004.TrackingLayer.Point Set pt = Map1. Option Explicit Private Sub Map1_MouseDown(Button As Integer. An event in an EventTable is specified by values in the StartMeasureField and EndMeasureField properties.Caption = Map1. ProgrammersReference. by drawing a Symbol for each event found. Layers(0).pmd 183 10/28/2004. if you wish to render events with a value of 75 in the SymbolField with the first Symbol in the symbol array (Symbol(0)). Symbol Object. you can use the IndexEvents and IndexExtent properties. here’s one way to create an EventRenderer: Set Map1. To try this example. For events in the EventTable which do not have a value in the SymbolField. ProgrammersReference. In order to manage the rendering of large numbers of events more efficiently.EventRenderer Properties DefaultSymbol EventTable StartMeasureField UseDefault DrawBackground FeatureRouteIDField Symbol Value EndMeasureField IndexEvents SymbolField ValueCount EventRouteIDField IndexExtent Tag Methods InvalidateIndex See Also MapLayer Object. 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. “EVENT2” and “SYMBOL”. Press F5 and click Com- mand1. You can control the way in which the EventRenderer accesses the Event information. In addition. An EventRenderer is a creatable object in MapObjects. you should set the first value in the Value array to equal 75 (Value(0) = 75). or the field cannot be found. decreasing the time your MapLayer takes to draw. 10:00 AM . Line Object Example This example demonstrates the use of the EventRenderer and its properties. If the SymbolField property is not set. you should specify which value in the SymbolField corresponds to which Symbol in the symbol array by setting the value array. fName and Database as appropriate for your EventTable. “EVENT1”. Values. This example uses an EventTable from Excel 97 with Fields called “ROUTE”. You should change the Fields. MapObjects Programmer’s Reference 183 You should then set the properties of each Symbol in the symbol array. and the InvalidateIndex method. When using large datasets with large numbers of events.Renderer = New MapObjects2. and a Com- mand Button named Command1. displaying the MapLayer with an EventRenderer may become a time consuming operation. In Visual Basic. For example. the DefaultSymbol will be used if the UseDefault property is True. then all symbols will be rendered with the DefaultSymbol. Color = moBlue End With ‘ Change this value as appropriate .Renderer = evRend ‘ The fName and database strings should be changed as appropriate ‘ for your data fName = “rt_zmEventTable.MousePointer = moHourglass Dim evRend As New MapObjects2.Size = 2 ProgrammersReference.xls” database = “C:\Program Files\ESRI\MapObjects2\Samples\Data” ‘ This example uses an Excel spreadsheet for it’s EventTable ‘ See the Accessing Data pages in the online help .Value(0) = 0 With .Symbol(1) . DATABASE=” & database & “ & fName evTab.DefaultSymbol.DefaultSymbol. 10:00 AM .DefaultSymbol.Size = 1 ‘ Change this value as appropriate .Name = “points$” With evRend .Color = moRed .Layers(0).pmd 184 10/28/2004.Style = moSolidLine .DefaultSymbol. evTab.database = “EXCEL 8.Value(1) = 1 With . 184 MapObjects Programmer’s Reference Option Explicit Private Sub Command1_Click() Screen.you should ‘ have a reference to the appropriate type library in your project.DrawBackground = True .EventRenderer Dim evTab As New MapObjects2.Style = moSolidLine .Table Dim fName As String Dim database As String Set Map1.Style = moDashLine .Symbol(0) .ValueCount = 3 .SymbolType = moLineSymbol .SymbolType = moLineSymbol .0.Size = 2 . EventTable = evTab ‘ Fields should be changed as appropriate for your event table . ProgrammersReference.pmd 185 10/28/2004.Size = 2 .Color = moGreen End With .FeatureRouteIDField = “ROUTE” . 10:00 AM .Refresh Screen.MousePointer = moDefault End Sub Private Sub Form_Load() Command1.Symbol(2) .Style = moSolidLine .SymbolField = “SYMBOL” End With Map1. EventRouteIDField [= fieldname] The EventRouteIDField property syntax has these parts: Part Description object An object expression that evaluates to a EventRenderer.Value(2) = 2 With .Caption = “Render Events” End Sub EventRouteIDField Property Applies To EventRenderer Object Description Returns or sets the EventRouteIDField property of the EventRenderer object.Color = moCyan End With ‘ Change this value as appropriate . value A string expression evaluating to the Field property of the EventTable of an EventRenderer which defines the route ID field. MapObjects Programmer’s Reference 185 .EventRouteIDField = “ROUTE” .EndMeasureField = “EVENT2” . Syntax object.StartMeasureField = “EVENT1” . See Also StartMeasureField Property. The EventTable property references a MapObjects2 Table object. See Also Symbol Object. ProjCoordSys Object ProgrammersReference. FeatureRouteIDField Property Example See EventRenderer Object 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. GeoCoordSys Object. The EventRouteIDField and FeatureRouteIDField should contain similar values. an EventRouteIDField containing route ID’s. 10:00 AM . and a StartMeasureField containing measure values on the route. EndMeasureField Property.pmd 186 10/28/2004. A SymbolField can also be used to specify the Symbol which should be used to render each event. If the EventRouteIDField property contains a value which does not match with any value in the FeatureRouteIDField. StartMeasureField Property. table A Table object containing event information. If rendering line events. Syntax object. as described in Remarks. 186 MapObjects Programmer’s Reference Remarks The EventRouteIDField property is used to specify which Field in the EventTable contains route ID information. the EventTable should also contain an EndMeasureField.EventTable [= table] The EventTable property syntax has these parts: Part Description object An object expression that evaluates to a EventRenderer. FeatureRouteIDField Property. EventRouteIDField Property Example See EventRenderer Object Export Method Applies To Recordset Object. no event will be rendered. Remarks The EventTable of an EventRenderer should contain at least two fields. EndMeasureField Property. [outCoordSys] ) The Export method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Recordset Objects When exporting a Recordset. and the . MapObjects Programmer’s Reference 187 Description For Recordset objects. If this parameter is used. For GeoCoordSys or ProjCoordSys objects. outName A string expression that evaluates to the full path and file name on disk for the exported file. this information can be stored separately in a Projection file (. When MapObjects reads a GeoDataset based on a shapefile with a prj file present.Export ( outName. For SDE layers. not using the MapObjects Export method. the projection information is stored in the layer’s definition table. creating a Shapefile. the Export method writes a . Syntax For a GeoCoordSys or ProjCoordSys object.prj file that describes the coordinate system itself.Export ( outName ) Syntax For a Recordset object. Projection files used with coverages must be generated using ARC/INFO. 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. Used with Recordset objects only. the GeoDataset will be held transformed into that coordinate system. Shapefiles with support for Z and Measure values are only fully supported as of ProgrammersReference.prj extension. Remarks ProjCoordSys and GeoCoordSys Objects When used with ProjCoordSys or GeoCoordSys objects. the Export method writes the Recordset to a GeoDataset.pmd 187 10/28/2004. For shapefiles. The prj file should have the same filename as the shapefile.prj) alongside the GeoDataset on disk. 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. May be of type GeoCoordSys or ProjCoordSys. Your program can check this using the HasZ and HasMeasure properties of the GeoDataset object. outCoordSys Optional. 10:00 AM . The projection files used with shapefiles and SDE layers are the only form of projection metadata which can be written by MapObjects. the Recordset is exported into the coordinate system defined. FullExtent Else MsgBox “New maplayer is not valid”.ShowSave name = Combo1.Type = stripProj(name) newLayer.Color = moYellow End With If newLayer. paste the code into the Declarations section of a form containing a CommandButton named Command1.Symbol .0.Layers.Layers(0).Records. Transform Method Example This example uses the Export method of the Recordset object to export a MapLayer to a shapefile. See Also GeoDataset Object.FileName.Add newLayer Map1.MapLayer Dim coordSys As New MapObjects2.pmd 188 10/28/2004. AddGeoDataset Method. older applications may not be able to read such Shapefiles. If you intend to use geographic data transformed in MapObjects with older applications. To try this example.Caption = “Export” ProgrammersReference.Valid Then Map1.1 and MapObjects 2.Extent = Map1. coordSys) With newLayer. containing one MapLayer which has a coordinate system set. _ “Invalid MapLayer” End If End Sub Private Sub Form_Load() Command1.ProjCoordSys Private Sub Command1_Click() Dim name As String CommonDialog1. 188 MapObjects Programmer’s Reference ArcView 3. a CommonDialog control named CommonDialog1.ListIndex) coordSys. transformed to a different coordinate system. ReturnDescription Method. a Combo Box named Combo1 and a Map named Map1. Option Explicit Dim newLayer As New MapObjects2.GeoDataset = Map1. and then click Command1. 10:00 AM . The exported MapLayer is added to the Map for comparison with the untransformed MapLayer. vbExclamation. In some cases.List(Combo1. Press F5.Style = moLightGrayFill .Export _ (CommonDialog1. transforming them if required. 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. “[“) stripProj = Left(Right(theProjection. 10:00 AM .Color = moDarkGreen End With End Sub Function stripProj(theProjection As String) As Variant ‘Get position of open bracket Dim openB As Integer openB = InStr(theProjection.Path CommonDialog1.openB .Symbol . moExportClipboardEMF 2 ExportMap places a metafile (CF_ENHMETAFILE) on the clipboard. See Also Map Object.pmd 189 10/28/2004.Strings projCoord. Len(theProjection) .AddItem “ProjCoordSys: “ & i Next i Combo1. Constant Value Description moExportEMF 0 ExportMap creates a Windows Enhanced Metafile (EMF) file.Filter = “Shapefiles (. moExportClipboardBMP 3 ExportMap places a bitmap (CF_DIB) on the clipboard.openB).DialogTitle = “Export Projected Shapefile” CommonDialog1. moExportBMP 1 ExportMap creates a Windows Bitmap (BMP) file.Style = moSolidFill .Layers(0).InitDir = App.PopulateWithProjectedCoordSys Dim i As Variant For Each i In projCoord Combo1.1) End Function ExportMap Constants MapObjects defines the following constants for use with the Map object’s ExportMap method to specify what type of file to export. ExportMap Method ProgrammersReference.ListIndex = 0 With Map1.shp)|*. _ Len(theProjection) .shp” Dim projCoord As New MapObjects2. MapObjects Programmer’s Reference 189 CommonDialog1. as described in Settings. paste the code into the Declarations section of a form that contains a CommonDialog control named CommonDialog1. 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 ProgrammersReference. See Also CopyMap Method. To try this example. Syntax object. Remarks ExportMap does not support VisibleRegion or Transparent properties. a CommandButton named Command1. then these too will not be visible. An output resolution of 1 represents the same number of pixels in the bitmap image of the Map as on the screen.pmd 190 10/28/2004. any ImageLayers in the Map control’s Layers collection will not be visible. and then press F5. If any ImageLayers in the Map control’s Layers collection have their Transparent property set to True. True clears the Clipboard. For Clipboard formats. 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. 10:00 AM . format A value or constant that determines the format of the exported file. indicates whether or not to clear the Clipboard. scaleFactor A value that determines the output resolution. an output resolution of 10 is ten times the original number of pixels in the image. OutputMap2 Method. Settings The settings for format are ExportMapConstants. both in the horizontal and the vertical direction. OutputMap Method. formatData A string expression that evaluates to the full path and file name on disk for export files. 190 MapObjects Programmer’s Reference 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. ExportMap2 Method.ExportMap format. scaleFactor The ExportMap method syntax has the following parts: Part Description object An object expression that evaluates to an object in the Applies To list. formatData. and a Map named Map1 that contains at least one MapLayer. False prevents the clear. If RotationAngle is not zero. click Command1. and allows an output source depth to be specified.CancelError = True On Error Resume Next CommonDialog1. 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.FileName.Number = cdlCancel Then ‘Cancel button pressed Err.ShowSave If Err.DefaultExt = “*.pmd 191 10/28/2004.emf” CommonDialog1. formatData.emf)|*. use ExportMap2 and set its useSourceDepth parameter to True.emf” CommonDialog1. and you want to honor its palette. Option Explicit Private Sub Command1_Click() CommonDialog1. useSourceDepth The ExportMap2 method syntax has the following parts: Part Description object An object expression that evaluates to an object in the Applies To list.ExportMap moExportEMF.ExportMap2 format. Syntax object. scaleFactor.Filter = “Enhanced Metafile (*. CommonDialog1. True clears the Clipboard. False prevents the clear. MapObjects Programmer’s Reference 191 that has an image depth greater than 8 bits per pixel. An output resolution of 1 represents the same number of pixels in the bitmap image of the Map as ProgrammersReference. formatData A string expression that evaluates to either: Exporting to a file: the full path and file name on disk for export files.Clear Exit Sub End If Map1. format A value or constant that determines the format of the exported file.emf” CommonDialog1. scaleFactor A value that determines the output resolution. 10:00 AM . Exporting to Clipboard: indicates whether or not to clear the Clipboard. as described in Settings.FileName = “map1. Default value is False. 192 MapObjects Programmer’s Reference on the screen. If any ImageLayers in the Map control’s Layers collection have their Transparent property set to True. Return Values The value that is returned for this property is that raised by the Relational Database Manage- ment System underlying your SDE instance. ConnectError Property. Settings The settings for format are ExportMapConstants. Connected Property. ExportMap2 will honor the source palette. useSourceDepth Optional. You should check your RDBMS manuals for more information about the exact cause and meaning of the returned value. ExtendedErrorString Property ProgrammersReference.ExtendedError The ExtendedError property syntax has these parts: Part Description variable A variable that has been declared to be a long data type object An object expression that evaluates to a DataConnection object.pmd 192 10/28/2004. Remarks ExportMap2 gives you the ability to export 16 and 24-bit truecolor bitmaps. OutputMap Method. A boolean expression that indicates whether to search through the ImageLayers of the Map to determine whether the palette of any of the source images is greater than 8 bits per pixel. See Also CopyMap Method. an output resolution of 10 is ten times the original number of pixels in the image. ExportMap2 Method. 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. If so. Syntax variable = object. then these too will not be visible. Disconnect Method. See Also Connect Method. both in the horizontal and the vertical direction. If RotationAngle is not zero. OutputMap2 Method. any ImageLayers in the Map control’s Layers collection will not be visible. ExportMap Method. 10:00 AM . 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. ExportMap2 does not support VisibleRegion or Transparent properties. Points Object. ConnectError Property. The property is read-only for all objects to which it applies. ProgrammersReference. Connected Property. ExtendedError Property Example See ClearConnectError Property Extent Property Applies To Ellipse Object. 10:00 AM . Disconnect Method.pmd 193 10/28/2004. ImageLayer Object. Syntax variable = object. 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. Syntax object. Map Object. Line Object. MapObjects Programmer’s Reference 193 Example See ClearConnectError Property ExtendedErrorString Property Applies To DataConnection Object Description Returns a value that represents any ExtendedErrorString returned from an RDBMS while accessing SDE layers.ExtendedErrorString The ExtendedErrorString property syntax has these parts: Part Description variable A variable that has been declared to be a String data type object An object expression that evaluates to a DataConnection object. with the exception of the Map object and MapLayers derived from SDE. MapLayer Object. See Also Connect Method. You should check your RDBMS manuals for more information about the exact cause and meaning of the returned description. Polygon Object Description Returns or sets the spatial extent of an object.Extent [= rectangle] The Extent property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. the ScaleRectangle method scales the Rectangle that defines the Extent of the Map and the code resets the Extent accordingly. 10:00 AM . Below.Extent oRect.Left. then the Map.g. If at least one of the properties lies outside of the FullExtent.Extent. If you are setting the Map. 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.Extent = Rectangle) you should be sure that the Left.Top.TrackRectangle Set Map1.ScaleRectangle (0. or Map. Remarks In Visual Basic you may wish to use the Extent property to zoom in on a map.Bottom will change. Map.pmd 194 10/28/2004.3048. a code fragment shows you how you might do this in the Map’s MouseDown event: Dim r as New MapObjects2.25) Map1.Extent = r You should bear in mind that you cannot set a Map’s Extent to be outside it’s FullExtent. Syntax object.Extent. See Also Rectangle Object Example The following example uses the Extent property to set what portion of the Map is visible.Factor [= value ] ProgrammersReference. . To try this example.Rectangle Set r = Map1.Extent. When you run the code.Right.Extent. For example. and none of the Map. Set Map.Extent change will not be successful. Press F5 and then click Command1.Extent properties e. Option Explicit Private Sub Command1_Click() Dim oRect As MapObjects2. 194 MapObjects Programmer’s Reference rectangle An ActiveX Automation object of type Rectangle that MapObjects exposes. Top and Bottom properties of your Rectangle are within the Map’s FullExtent.Rectangle Set oRect = Map1. the Foot Unit has a factor of 0. Map. Right.Extent = oRect 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. Press F5 to see a bar-chart displaying the different Factors of the pre-defined Unit objects.Strings Dim aUnit As Variant Dim i As Integer Dim arrChart(1 To 30.PopulateWithUnits For i = 0 To unitObjs. See Also Spheroid Object Example This example uses the factor property of different unit objects to build a chart. which contains an MS Chart control.Maximum = Text1.Text MSChart1. 1 To 2) As String ‘Build a collection of Unit names and factors unitObjs.Refresh End Sub Private Sub Form_Load() Dim unitObjs As New MapObjects2.Axis(VtChAxisIdY. 10:00 AM .1 Dim theUnit As New MapObjects2.factor Next i ‘Put data into chart Dim j As Integer With MSChart1 .RowCount = 1 . Try changing the Maximum Y Axis value of the Chart to see more detail. Option Explicit Private Sub Command1_Click() MSChart1. value A numeric expression that specifies the conversion Factor.RowLabel = “Units” .Name arrChart(i + 1. 0).Plot.Repaint = True . 2) = theUnit.Unit theUnit. MapObjects Programmer’s Reference 195 The Factor property syntax has these parts: Part Description object An object expression that evaluates to a Unit object.Count ProgrammersReference.ValueScale.pmd 195 10/28/2004.ColumnCount = unitObjs. paste the following code into the Decalrations section of a new project. To try this example.Type = stripProj(unitObjs(i)) arrChart(i + 1. 1) = theUnit.Count . Column = j + 1 .Data = arrChart(j + 1. ProgrammersReference.Count . “[“) stripProj = Left(Right(theProjection.ShowLegend = False . Len(theProjection) . _ Len(theProjection) . Syntax object.ShowLegend = True End With End Sub Function stripProj(theProjection As String) As Variant ‘Get position of open bracket Dim openB As Integer openB = InStr(theProjection. FeatureRouteIDField [= fieldname] The FeatureRouteIDField property syntax has these parts: Part Description object An object expression that evaluates to a EventRenderer. 2) .AxisScale.Type = VtChScaleTypeLinear For j = 0 To unitObjs.openB).openB . 10:00 AM .1 . value A string object evaluating to the Field property of the EventTable of an EventRenderer which defines the route ID field. The EventRouteIDField and FeatureRouteIDField should contain similar values.ColumnLabel = arrChart(j + 1. If the FeatureRouteIDField property contains a value which does not match with any value in the EventRouteIDField.Count .Axis(VtChAxisIdY).pmd 196 10/28/2004. Remarks The FeatureRouteIDField property is used to specify which Field in the MapLayer’s GeoDataset contains route ID information. 196 MapObjects Programmer’s Reference .1) End Function FeatureRouteIDField Property Applies To EventRenderer Object Description Returns or sets the FeatureRouteIDField property of the EventRenderer object.ColumnLabelCount = unitObjs. 1) Next j . the event will be rendered with the DefaultSymbol if the UseDefault property is True.Plot. LabelPlacer Object. 10:00 AM . regardless of its type.Field [= value] The Field property syntax has these parts: ProgrammersReference. Each Field has a Name. for example: Dim fld as MapObjects2. as a String with ValueAsString property. which is the default property for a Field object. Recordset Object Field Property Applies To ChartRenderer Object. Boolean. Example See EventRenderer Object Field Object A Field object represents a column of data within a Recordset with a common data type and a common set of properties. point. Syntax For a ClassBreaksRenderer. 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. DotDensityRenderer Object. empty. EventRouteIDField Property. LabelPlacer. LabelRenderer Object. FieldType Constants. ValueMapRenderer Object Description Returns or sets a field which is used by a MapLayer’s Renderer. date.Field Properties Name Value ValueAsString Type See Also Fields Collection. fully qualify the class name in declarations. DotDensityRenderer. Remarks To distinguish a MapObjects Field from a Visual Basic Field. double. and polygon. MapObjects Programmer’s Reference 197 See Also StartMeasureField Property. LabelRenderer or ValueMapRenderer Object object. long. ClassBreaksRenderer Object. The Type property returns a value representing what type of data the field contains: string. EndMeasureField Property.pmd 197 10/28/2004. line. index An integer that specifies the position of a member of a group of Values. Index must be a number from 0 to a number that is one less than the ValueCount property of the EventRenderer. or one slice in a pie chart. Syntax For a ChartRenderer Object object. Remarks The Field property sets the Fields of the MapLayer’s Recordset which are used by the renderer to determine how each feature in the MapLayer is displayed. 198 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list. value A string expression that specifies a name of a field in the Recordset of the MapLayer on which the renderer is set. See Also FieldType Property Example This example demonstrates the use of the Field property in association with a ClassBreaksRenderer object to create a graduated symbol map. Each renderer in the Applies To list makes use of the value of the specified field. 10:00 AM .Statistics Dim oRenderer As New MapObjects2. value A string expression that evaluates to the required value for the renderer. the Field property contains an array of Fields. If object is a ClassBreaksRenderer object. To try this example. Press F5 and then select a numeric field. Option Explicit Private Sub Combo1_Click() Dim i As Integer Dim oStats As MapObjects2.Field (index) [= value] The Field property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. LabelPlacer or ValueMapRenderer object. 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.pmd 198 10/28/2004. Each string must represent a field name that contains continuous numeric data.ClassBreaksRenderer Dim sFieldName As String ProgrammersReference. each of which represents on bar in a bar chart. Layers(0).Field = sFieldName .SymbolType = moPointSymbol .oStats.Symbol(i).5 .Recordset Dim oField As MapObjects2.Records.Text = “” End Sub FieldCount Property Applies To ChartRenderer Object.List(Combo1.BreakCount = 2 For i = 0 To oRenderer.Refresh End If End Sub Private Sub Form_Load() Dim oRecset As MapObjects2.name End If Next Combo1.Renderer = oRenderer Map1.Fields If oField.Type < moString Then Combo1.Symbol(i).BreakCount .CalculateStatistics(sFieldName) With oRenderer .Records For Each oField In oRecset.Color = moRed Next i .ListIndex = -1 Combo1.Layers(0). 10:00 AM .pmd 199 10/28/2004. TableDesc Object.AddItem oField.Field Set oRecset = Map1.ListIndex) Set oStats = Map1.Style = moCircleMarker .Mean * 0.SizeSymbols 4. 18 End With Map1.ListIndex <> -1 Then sFieldName = Combo1.Max . MapObjects Programmer’s Reference 199 If Combo1.Mean .Break(1) = oStats. Standardizer Object ProgrammersReference.Break(0) = oStats.Layers(0). 200 MapObjects Programmer’s Reference Description Returns or sets the number of Field objects described in a TableDesc object. Index must be a number from 0 to a number that is one less than the value of the TableDesc object’s FieldCount property. the IntersectionStandardizingRules will then be used.pmd 200 10/28/2004. When a regular address is standardized using the StandardizeAddress method. value A numeric expression that specifies the number of fields. FieldName Property. 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. Syntax object. When a street intersection address is standardized. 10:00 AM . Field Object.FieldLength( index) [= value] The FieldLength property syntax has these parts: Part Description object An object expression that evaluates to a TableDesc. the StandardizingRules will be used. The FieldCount value changes at run time depending on what addresses are assigned to the StandardizeAddress method. Syntax object.FieldCount [= value] The FieldCount property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. ProgrammersReference. FieldValue Property Example See AddGeoDataset Method or StandardizeAddress Method 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. or returns the number of FieldNames found in the standardization rule file associated with the StandardizingRules or IntersectionStandardizingRules properties of the Standardizer object. index A numeric expression that specifies the relative position of a member of the group of FieldLength values associated with the TableDesc object. See Also Recordset Object. dct file. See Also Recordset Object. Note that the length of a column may be different than the number of bytes required to store the data on the data source. value A string expression that specifies the name of the Field in a Recordset.dbf) limit field names to 10 characters. Field Object Example See AddGeoDataset Method FieldName Property Applies To TableDesc Object. See Also Recordset Object. 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. the FieldLength does not include the null termination byte. By convention. Syntax object. Fields with longer names will be truncated. Index must be a number from 0 to a number that is one less than the value of the TableDesc or Standardizer object’s FieldCount property. HN stands for house number and SN for street name. Remarks For Standardizer objects. MapObjects Programmer’s Reference 201 value A numeric expression that specifies the length of a string or character Field in a Recordset. FieldCount Property.FieldName( index) [= value] The FieldName property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. the field names are associated with the standardization rule files. 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. Standardizer Object Description Returns or sets a user-defined name for a Field described by a TableDesc object associated with a Recordset. Field Object. They were defined in the standardization rule . Note also that dBASE files (. Remarks For character data.pmd 201 10/28/2004. StandardizeAddress Method ProgrammersReference. Each name is a unique two letter word such as HN. 10:00 AM . FieldValue Property Example See AddGeoDataset Method. value A numeric expression that specifies the numeric precision of a Field in a Recordset. Remarks The precision of a numeric Field refers to the maximum number of digits used by its data type. Field Object. See Also Recordset Object.pmd 202 10/28/2004. use the default property. index A numeric expression that specifies the relative position of a member of the group of FieldPrecision values associated with the TableDesc object.FieldPrecision( index) [= value] The FieldPrecision property syntax has these parts: Part Description object An object expression that evaluates to a TableDesc.Fields. Index must be a number from 0 to a number that is one less than the value of the TableDesc object’s FieldCount property. To access a particular Field in the collection.Fields(“Name”). for example: Dim flds as MapObjects2. for example: aString = Records. FieldType Constants Example See AddGeoDataset Method Fields Collection A Fields object contains a collection of each Field object in a Recordset object. The maximum FieldPrecision allowable is 19. Item. fully qualify the class name. 10:00 AM .ValueAsString Remarks To distinguish a MapObjects Fields collection from a Visual Basic Fields collection.ValueAsString or. Syntax object. The precision of a nonnumeric field generally refers to either the maximum length or the defined length of the field. aString = Records.Fields ProgrammersReference. 202 MapObjects Programmer’s Reference 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.Item(“Name”). MapObjects Programmer’s Reference 203 See Also FieldType Constants.Layers(0). paste the code into the Declarations section of a form containing a CommandButton named Command1. Syntax object.Fields The Fields property syntax has these parts: Part Description object An object expression that evaluates to a Recordset object.FieldScale( index) [= value] ProgrammersReference.pmd 203 10/28/2004. See Also Field Object Example This example uses the Fields Property to list the names of the fields associated with a MapLayer’s Recordset.AddItem f. Press F5 and then click Command1 to see the list of field names.Recordset Dim f As MapObjects2. To try this example. a ListBox named List1. Recordset Object Fields Property Applies To Recordset Object Description Returns all stored Field objects of the Fields collection of a Recordset.Fields List1. 10:00 AM .Name Next f End Sub 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. Option Explicit Private Sub Command1_Click() Dim recset As MapObjects2.Field Set recset = Map1. Syntax object. and a Map named Map1 that has at least one MapLayer.Records For Each f In recset. some data sources impose a separate limit on the maximum scale. See Also Recordset Object. However. Remarks For approximate floating point number fields. For the SQL_DECIMAL and SQL_NUMERIC data types. since the number of digits to the right of the decimal point is not fixed. the FieldScale is undefined.pmd 204 10/28/2004. 204 MapObjects Programmer’s Reference The FieldScale property syntax has these parts: Part Description object An object expression that evaluates to a TableDesc. 10:00 AM . index A numeric expression that specifies the relative position of a member of the group of FieldScale values associated with the TableDesc object. Field Object Example See AddGeoDataset Method FieldType Constants MapObjects defines the following type constants for use with the Field object’s Type property and the TableDesc object’s FieldType property Constant Value Description moNone 0 None moLong 3 Long moDouble 5 Double moDate 7 Date moString 8 String moBoolean 11 Boolean moPoint 21 Point moLine 22 Line ProgrammersReference. the maximum scale is generally the same as the maximum precision. 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. Index must be a number from 0 to a number that is one less than the value of the TableDesc object’s FieldCount property. as de- scribed in Settings. and change the path of the database. Option Explicit Private Sub Form_Load() Dim dc As New MapObjects2. and creates a list of details from a MapLayer’s Recordset. MapObjects Programmer’s Reference 205 moPolygon 23 Polygon moPoints 24 Points collection See Also Field Object FieldType Property Applies To TableDesc Object Description Returns or sets the type of Field described by a TableDesc object associated with a Recordset.Database = App.DataConnection ‘Change the line below to point to a folder containing shapefiles dc. See Also Recordset Object. paste the code into the Declarations section of a form that contains a ListBox named List1. and the FindGeoDataset method. index A numeric expression that specifies the relative position of a member of the group of FieldType values associated with the TableDesc object. value An integer or constant that indicates an operational or data type. To try this example.FieldType( index) [= value] The FieldType property syntax has these parts: Part Description object An object expression that evaluates to a TableDesc. 10:00 AM .. Field Object Example This example uses the MapObjects FieldTypeConstants. Index must be a number from 0 to a number that is one less than the value of the TableDesc object’s FieldCount property..pmd 205 10/28/2004. Then press F5. Syntax object. Settings The settings for value are FieldTypeConstants.Path & “.Files” ProgrammersReference. AddItem “Field Name” & Chr(9) & “Field Type” & Chr(9) & _ “Constant” ‘ For Each field In layer.1 fldString = tblDesc. 10:00 AM .Records. “Connect Error” Else Dim layer As New MapObjects2.FieldType(i) Case moBoolean fldString = fldString & Chr(9) & Chr(9) & “Boolean” Case moDate fldString = fldString & Chr(9) & Chr(9) & “Date” Case moDouble fldString = fldString & Chr(9) & Chr(9) & “Double” Case moLine fldString = fldString & Chr(9) & Chr(9) & “Line” Case moLong fldString = fldString & Chr(9) & Chr(9) & “Long” Case moNone fldString = fldString & Chr(9) & Chr(9) & “None” Case moPoint fldString = fldString & Chr(9) & Chr(9) & “Point” ProgrammersReference.MapLayer ‘Change the line below to a name of a shapefile layer.Fields Dim tblDesc As MapObjects2.FieldCount .TableDesc For i = 0 To tblDesc.FindGeoDataset(“states”) List1.Connect If Not dc.Connected Then MsgBox “Could not connect to database”.pmd 206 10/28/2004. vbOKOnly.field Dim fldString As String List1.Clear Dim i As Integer Dim field As MapObjects2. 206 MapObjects Programmer’s Reference dc.FieldType(i) Select Case tblDesc.GeoDataset = dc.Records.FieldName(i) If Len(fldString) < 7 Then fldString = fldString & Chr(9) End If fldString = fldString & Chr(9) & tblDesc.TableDesc Set tblDesc = layer. after an address is standardized. as defined in the . the StandardizeAddress method of the Standardizer object will only parse an address “270 North Main Avenue” into the HN.FieldValue (FieldName) [ = value] The FieldValue property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. You can override the values returned by the Standardizer by setting new values to the match key fields if you wish to. PD. MapObjects Programmer’s Reference 207 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. and SD. ST.dct file. Remarks The Standardizer object’s FieldName property returns the names of the match key fields. the FieldName is used as a search key. or found in the appropriate . For example.pmd 207 10/28/2004. PT.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. Syntax object. value A string expression that specifies the value in the field name. 10:00 AM . SN.dct standardization file. as no zip code is ProgrammersReference. FieldName A string expression that specifies the Standardizer’s FieldName. When searching a Geocoder object’s StreetTable. FieldName values can be read at run time from a valid Standardizer. the FieldValue returns a standardized values of an address for each FieldName. For example.FieldValue(“ZN”) = “53702” Similarly.File [= pathname] The File property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 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. See Also Valid Property Example This example uses the File Property to specify the file associated with an ImageLayer. you would manually specify the value for a field named ZN using the object’s FieldValue property. for example.bmp|TIFF _ ProgrammersReference. the Standardizer may return “Ave” for the street type (ST) field. If you wish the address to contain a zone. You can change it to “Av” if you prefer by setting the new value to the FieldValue (“ST”) property. To try this example.pmd 208 10/28/2004.bmp)|*. Option Explicit Private Sub Form_Load() Dim iLayer As New ImageLayer CommonDialog1. 208 MapObjects Programmer’s Reference present in the address. FieldName Property Example See StandardizeAddress Method File Property Applies To ImageLayer Object Description Returns or sets the path and filename of an image file displayed by an ImageLayer. pathname A string expression that specifies the path and filename associated with an ImageLayer. you can override the FieldValue of existing FieldName’s which are the result of standardization by setting a new value to the field. the code displays the Common FileDialog to set the File associated with the image to add.Filter = “Windows Bitmap (*. Syntax object. then specify the image to add. In this case. stan. 10:00 AM . See Also FieldCount Property. Make sure that the image has an associated world file. FilterIndex = 1 CommonDialog1.FileName <> “” Then iLayer.Layers.FileName ‘ move the existing layer to the top If Map1.ShowOpen If CommonDialog1.pmd 209 10/28/2004.File = CommonDialog1. Constant Value Description moSolidFill 0 Solid moTransparentFill 1 Transparent moHorizontalFill 2 Horizontal moVerticalFill 3 Vertical moUpwardDiagonalFill 4 Upward Diagonal moDownwardDiagonalFill 5 Downward Diagonal moCrossFill 6 Cross moDiagonalCrossFill 7 Diagonal Cross moLightGrayFill 8 Light Gray Fill moGrayFill 9 Gray Fill moDarkGrayFill 10 DarkGray Fill See Also Polygon Object. Symbol Object ProgrammersReference.Layers.MoveToTop 1 End If End If End Sub FillStyle Constants MapObjects defines the following constants for use with fill symbols.Add(iLayer) Then Map1. 10:00 AM .tif)|*.tif” CommonDialog1. MapObjects Programmer’s Reference 209 Image(*. a ListBox named List1. Selecting and deselecting the Filter Strings checkbox will limit the fields listed in the ListBox to non-string types. and that a points layer is available. improving the performance of your application. a Statistics object should be created from the Recordset. then press the CommandButton. select an operator. although the filter will also work with MapLayer’s based on shapefiles. In these cases. Syntax object. a CommandButton named Command1 and two CheckBoxes named Check1 and Check2. FilterOrder Property Example This example sets the FilterExpression property to limit which features of the MapLayer are visible. and the number of records taken from the Count property of this Statistics object. To try this example.DataConnection ProgrammersReference. See Also FilterFields Property. Option Explicit Dim dc As New MapObjects2. and enter a value in the TextBox. Option2.FilterExpression [= filter ] The FilterExpression property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. It can be used to limit the amount of information being returned from the SDE server. filter A string expression that specifies the filter expression to be used with the MapLayer. FilterOperator Property. a TextBox named Text1. When using a FilterExpression. and Option3. Click on a Field. the Count property may no longer be used on the MapLayer objects Recordset. Now press F5. Remarks FilterExpression is intended for use with SDE. The FilterFields property is used to limit the fields which are available to perform the FilterExpression on. Ensure that the properties of the DataConnection are set correctly for your SDE instance. to obtain the correct Count of the Recordset. as there is no header information available to determine the correct record Count. 210 MapObjects Programmer’s Reference 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. paste the code into the Declarations section of a form containing three OptionButtons named Option1. 10:00 AM . where much of the processing may be carried out on the server.pmd 210 10/28/2004. Strings Set Map1.Records Screen.List(List1.Layers(0).Refresh End Sub Private Sub Check2_Click() Screen.MousePointer = vbHourglass If Check2 Then Set Map1.Refresh End Sub ProgrammersReference.Caption End If exp = exp & Text1.FilterFields = noStrings End If Map1.Text Map1.ListIndex) If Option1 Then exp = exp & Option1.Layers(0).FilterOrder 3 Else .Caption ElseIf Option3 Then exp = exp & Option3.Caption ElseIf Option2 Then exp = exp & Option2.MousePointer = vbDefault End Sub Private Sub Command1_Click() Dim exp As String exp = List1.Layers(0).Refresh listFields Map1. MapObjects Programmer’s Reference 211 Dim useFields As New MapObjects2.FilterFields = useFields Else Dim noStrings As New MapObjects2.FilterExpression = exp Map1.Strings Private Sub Check1_Click() With Map1.Layers(0) If Check1 Then .pmd 211 10/28/2004.Layers(0). 10:00 AM .FilterOrder 1 End If End With Map1. Name) .Name.GeoDatasets ‘Here.Records ‘ List is created of all Fields.Password = “userpass” dc. 212 MapObjects Programmer’s Reference Private Sub Form_Load() ‘ The values for Server.i) If dataName = “Points” Then Dim layer As New MapObjects2.Caption = “=” Option3.Caption = “Filter Layer” If dc.Caption = “>” Option2.Caption = “Allow SDE to optimize Filter Order” Check2.Layers.Connect Then Dim gs As Object For Each gs In dc. and Password will ‘ need to be changed for your particular sde connection dc.Caption = “<“ Text1.pmd 212 10/28/2004. 10:00 AM .Add layer Exit For ProgrammersReference. Database.Name.Database = “sde1” Check1. Len(gs.Recordset Dim f As MapObjects2.field layer.User = “user” dc.MapLayer Dim rs As MapObjects2. “.GeoDataset = gs Set rs = layer.Text = “” Command1.Value = 0 Option1. User.”) dataName = Right(gs. for use in FilterExpression listFields rs ‘ All strings fields are added to a list for us in FilterFields filterStrings rs Map1.Server = “server” dc. the first Point dataset found is added to the map as a layer. Dim dataName As String Dim i As Integer i = InStrL(gs.Caption = “Filter String Fields” Check2. MapObjects Programmer’s Reference 213 End If Next gs Else MsgBox “Connection Error” End If End Sub Private Sub listFields(recs As MapObjects2.pmd 213 10/28/2004.AddItem field.Fields ‘ Put all non-string fields in a strings collection which ‘ may be used to set FilterFields property If field.Recordset) List1.Name ‘End If Next field End Sub Private Sub filterStrings(recs As MapObjects2. inString.Name End If Next field End Sub ‘ Returns the character position of the last occurrence ‘ of srchString in inString.Fields ‘ Put all numeric fields in the ListBox ‘If field. vbTextCompare) ProgrammersReference.Type = 5 Then List1.Type <> 8 Then useFields.Recordset) Dim field As Object For Each field In recs.Add field. srchString. 10:00 AM .Clear Dim field As Object For Each field In recs. srchString As String) _ As Integer Dim iLastPos As Integer ‘Set to 0 on initialization ‘ Check srchString — a 0-length string will match every time If Len(srchString) Then ‘ Set iLastPos to the last matching position Dim iCurPos As Integer Do iLastPos = iCurPos iCurPos = InStr(iCurPos + 1. Private Function InStrL(inString As String. FilterOrder Property. It can be used to limit the amount of information being returned from the SDE server. FilterOperator Property. See Also FilterExpression Property.pmd 214 10/28/2004.FilterOperator [=opType ] The FilterOperator property syntax has these parts: ProgrammersReference. When this property is set. listing the Fields to filter on for the MapLayer. improving the performance of your application. Strings Object Example See FilterExpression Property FilterOperator Property Applies To MapLayer Object Description This property works in conjunction with the FilterShape property. 214 MapObjects Programmer’s Reference Loop Until iCurPos = 0 End If 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. Remarks FilterFields only works with a SDE layers. and returns or sets the type of FilterShape operation used in the filter. fields A object expression that evaluates to a Strings object. 10:00 AM .FilterFields [=fields ] The FilterFields property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Syntax object. only the Fields in the Strings object will be returned from SDE. Syntax object. Try clicking different OptionButtons to use different FilterOperator constants in the Filter. the first Polygon dataset found is added to the map as _ a layer.GeoDatasets ‘Here. FilterOrder Property Example This example sets the FilterShape and FilterOperator properties to limit which features of the MapLayer are visible. 10:00 AM .pmd 215 10/28/2004. FilterFields Property.Database = “sde” If dc. Ensure that the properties of the DataConnection are set correctly for your SDE instance. although the filter will also work with MapLayers based on shapefiles. and track a polygon onto the map.Connect Then Dim gs As Object For Each gs In dc. User. and Password will ‘ need to be changed for your particular sde connection dc. FilterExpression Property. opType One of the SearchMethodConstants listed in settings below Settings The settings for opType are SearchMethodConstants Remarks FilterOperator and FilterShape are intended for use with SDE. MapObjects Programmer’s Reference 215 Part Description object An object expression that evaluates to an object in the Applies To list. Dim dataName As String Dim i As Integer ProgrammersReference. The default FilterOperator is moExtentOverlap See Also SearchMethod Constants.Polygon Dim operator As Integer Dim dc As New MapObjects2. Option Explicit Dim poly As New MapObjects2. where much of the process- ing may be carried out on the server.DataConnection Private Sub Form_Load() ‘ The values for Server.Password = “password” dc. To try this example. Option2.User = “user” dc. Press F5. paste the code into the Declarations section of a form containing a Map named Map1 and four OptionButtons named Option1. Option3 and Option4. Database.Server = “server” dc. i) If dataName = “Points” Then Dim layer As New MapObjects2.Caption = “Method: Contained By” Option3. Len(gs.Layers. srchString As String) _ As Integer Dim iLastPos As Integer ‘Set to 0 on initialization ‘ Check srchString — a 0-length string will match every time If Len(srchString) Then ‘ Set iLastPos to the last matching position Dim iCurPos As Integer Do iLastPos = iCurPos iCurPos = InStr(iCurPos + 1.Name. x _ As Single.Name) . 10:00 AM .Caption = “Method: Area Intersect” Option2. inString.MapLayer layer. srchString.”) dataName = Right(gs.GeoDataset = gs Map1.TrackPolygon If Not poly Is Nothing Then Set Map1.Add layer Exit For End If Next gs Else MsgBox “Connection Error” End If Option1. vbTextCompare) Loop Until iCurPos = 0 End If InStrL = iLastPos End Function Private Sub Map1_MouseDown(Button As Integer.Value = True Option1.pmd 216 10/28/2004. 216 MapObjects Programmer’s Reference i = InStrL(gs.Caption = “Method: Containing” Option4. Shift As Integer.Name. y As Single) Set poly = Map1.FilterShape = poly End If ProgrammersReference.Caption = “Method: Extent Overlap” End Sub Private Function InStrL(inString As String. “.Layers(0). 10:00 AM . FilterShape Property FilterOrder Property Applies To MapLayer Object Description This property returns or sets the order that filter operations are carried out by SDE.pmd 217 10/28/2004. Syntax object.Layers(0). MapObjects Programmer’s Reference 217 If Option1. FilterExpression Property.Value Then operator = 8 ElseIf Option3. FilterOrder Property.FilterOrder [= order] The FilterOrder property syntax has these parts: ProgrammersReference.FilterOperator = operator Map1.Refresh End Sub FilterOrder Constants MapObjects defines the following constants for defining the filter order when defining filters on MapLayers.Value Then operator = 6 ElseIf Option2.Value Then operator = 0 End If Map1.Value Then operator = 9 ElseIf Option4. Constant Value Description moAttributeFirst 1 Applies the FilterExpression first moShapeFirst 2 Applies the FilterShape first moOptimize 3 Allows SDE to optimize the filter order See Also MapLayer Object. where much of the process- ing may be carried out on the server.FilterShape [= filterShape] The FilterShape property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. filterShape A variant expression that specifies a shape to use as a filter for the MapLayer Remarks When setting a FilterShape on a MapLayer. It can be used to limit the amount of information being returned from the SDE server. FilterExpression Property. For example. you can use a three-dimensional Rect- angle as your filter shape. by using the moAttributeFirst FilterOrder Constant. although the filter will also work with MapLayers based on shapefiles. 10:00 AM . if your layer has a FilterExpression set which eliminates the majority of the layer. Syntax object. Features are filtered based on their Z coordinates. FilterOperator Property Example See FilterExpression Property FilterShape Property Applies To MapLayer Object Description This property returns or sets the FilterShape on a MapLayer. FilterOperator and FilterShape are intended for use with SDE. If your MapLayer contains features with Z values. improving the performance of your application. in addition to ProgrammersReference. Remarks This property will only affect a MapLayer that is an SDE layer with more than one filter set on it. order One of the FilterOrder constants listed in Settings below Settings The settings for order are FilterOrderConstants.pmd 218 10/28/2004. then you can ensure this expression is applied before the FilterShape is applied. You should set the property to optimize the filter performance. 218 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list. See Also FilterFields Property. you should first set the FilterOperator to the appropriate SearchMethodConstants. itemName A string expression whose index position in the collection to return. FilterOperator Property Example See FilterOperator Property Find Method Applies To Strings Collection Description Returns the index of a string in a Strings collection. Press F5.Find ( itemName. Find returns the index position of the string and may be used for a variety of purposes in MapObjects. Syntax Set variable = object.pmd 219 10/28/2004. startpos An optional numeric expression that indicates the index position from which to start the search. paste the code into the Declarations section of a Form that contains a Map named Map1. You can use startpos to find the next instance of itemName in the collection. MapObjects Programmer’s Reference 219 their X and Y coordinates. 10:00 AM . perhaps most usefully for determining the position of an argument. Find starts at the first index position. [ startpos]) The Find method syntax has these parts: Part Description variable A variable declared as an Integer or Long that evaluates to the index position of itemName in the Strings collection. If startpos is omitted. Find returns -1. To try this example. Note that moExtentOverlap is the only SearchMethodConstants that allows three-dimensional filtering. See Also Valid Property. See Also Add Method Example This example uses the Find method to count how many instances of a string are in a Strings collection. object An object expression that evaluates to an object in the Applies To list. 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. Option Explicit Private Sub Form_Load() ProgrammersReference. pmd 220 10/28/2004. idx + 1) Loop MsgBox “Found “ & iNumFound & “instances of the string in _ the collection” End Sub 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.Add “apples” .Add “bananas” .Unique = False ‘allows multiple instances to be added .Add “pears” . See Also FindApproximateMatches Method.Strings Dim iNumFound As Integer Dim idx As Integer With sMyStrs .Add “plums” . 220 MapObjects Programmer’s Reference Dim sMyStrs As New MapObjects2.Find(“apples”) ‘start at the beginning of the ‘collection Do While idx <> -1 iNumFound = iNumFound + 1 idx = sMyStrs. Locate Method.FindAllPlaceNames( prefix) The FindAllPlaceNames method syntax has these parts: ProgrammersReference.Find(“apples”. 10:00 AM .Add “apples” .Add “guavas” .Add “apricots” End With iNumFound = 0 idx = sMyStrs.Add “peaches” . PlaceNameTable Property Syntax Set variable = object. Clear ‘attempt an exact match of the place name Set pts = pl. object An object expression that evaluates to an object in the Applies To list.Text) ‘If we’ve found one or many exact matches. Passing an empty string to FindAllPlaceNames will return an empty Strings collection. You will need to change the GeoDataset name.PlaceLocator Dim pts As Mapobjects2. or select several names from the list and then double-click. the field name on which to build the index. a CommandButton named Command1.Points Dim gdname As String Dim fldname As String Public places As New Collection Private Sub Command1_Click() Dim p As Mapobjects2.Point Dim strs As New Mapobjects2. double-click on a name in the list to flash it on the map.Count > 0 Then ProgrammersReference. a CheckBox named Check1. MapObjects Programmer’s Reference 221 Part Description variable An object expression that evaluates to a Strings collection. and the FindApproximateMatches method does not return any successful matches. add then to the List If pts. Remarks You may wish to use the FindAllPlaceNames method if the first characters of a place name are known but the remainder of the name’s spelling is unsure. To try this example. a TextBox named Text1. Option Explicit Dim pl As New Mapobjects2.pmd 221 10/28/2004. prefix A string expression that specifies the first characters in the place names to search for. 10:00 AM . or the first few characters.Strings Dim i As Integer Dim s As Variant Set places = Nothing List1. Example This example uses the Locate method and the FindAllPlaceNames method to locate place names. Red point symbols are drawn at the matched place locations. and a ListBox named List1 (set the Multi-Select property to 2). in Text1 and press the CommandButton. Matches display in the ListBox. Press F5 and try typing an exact placename.Locate(Text1. paste the code into the Declarations section of a form that contains a Map with a MapLayer containing a place name field. and the path for the DataConnection to point to the correct locations and names for your data. Add p Next p strs.1 Set pts = pl.FindAllPlaceNames(Text1.TrackingLayer.Text) Else ‘or find approximate matches for text entered Set strs = pl.Count .Count > 0 Then Set places = Nothing List1.Add Text1.pmd 222 10/28/2004. vbInformation End If End If If strs.Text) If strs.Add p Next p Next i End If End If ‘populate the list with place names For Each s In strs List1.FindApproximateMatches(Text1.Text Else ‘otherwise.AddItem s Next s ‘draw place name locations Map1.Value = 0 Then Set strs = pl. find all places starting with text specified If Check1.Locate(strs(i)) For Each p In pts places.Clear For i = 0 To strs. 10:00 AM . 222 MapObjects Programmer’s Reference For Each p In pts places.Count = 0 Then MsgBox “No approximate matches found”.Refresh True End Sub Private Sub Form_Load() Dim dc As New DataConnection gdname = “counties” fldname = “name” ProgrammersReference. Layers. False) Then MsgBox “Couldn’t build index” End If Dim layer As New MapLayer layer.SearchShape _ (places(List1. 4 Else ‘exact match or multiple places with same name Dim i As Integer For i = 1 To places.Color = moPaleYellow Command1.FlashShape result.Count .Fields(“shape”).Value.1 Set result = Map1.PlaceNameTable = dc.ListIndex + 1).FlashShape result. “”) Map1.SearchShape(places(i).Fields(“shape”). _ moPointInPolygon. “”) Map1.Connect Set pl. 10:00 AM .Recordset If List1.FindGeoDataset(gdname) Map1.Layers(0). 4 If places.FindGeoDataset(gdname) If Not pl. “MapObjects”) If res = vbNo Then Exit For End If End If ProgrammersReference.BuildIndex(fldname. moPointInPolygon.Symbol.Text = “” Check1. MapObjects Programmer’s Reference 223 ‘Change the paths below to ones appropriate for your data dc.GeoDataset = dc.Value = 0 End Sub Private Sub List1_Click() Dim result As Mapobjects2.Count > 1 Then Dim res As Integer res = MsgBox(“Flash another place?”.Add layer layer.ListCount > 1 Then ‘wild card returned multiple matches Set result = Map1.Caption = “Locate” Text1.Value.Layers(0).Database = “C:\Program Files\ESRI\MapObjects2\Samples\Data\USA” dc.Caption = “Approximate match” Check1.pmd 223 10/28/2004. vbYesNo. Extent = Map1.TrackRectangle End If End Sub Private Sub Text1_Change() List1.Symbol Dim p As Mapobjects2.Point sym.Size = 7 For Each p In places Map1.OLE_HANDLE) If Not places Is Nothing Then Call DrawPlaces(places) End If End Sub Sub DrawPlaces(places As Collection) Dim sym As New Mapobjects2.DrawShape p. Shift As Integer) If KeyCode = vbKeyReturn Then Command1_Click End If End Sub ProgrammersReference.Clear End Sub Private Sub Text1_KeyDown(KeyCode As Integer. y As Single) If Shift = vbShiftMask Then Map1.Extent = Map1.Style = moCircleMarker sym. 224 MapObjects Programmer’s Reference Next i End If End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole. sym Next p End Sub Private Sub Map1_MouseDown(Button As Integer.pmd 224 10/28/2004. x _ As Single.Color = moRed sym.SymbolType = moPointSymbol sym. 10:00 AM . Shift As Integer.FullExtent Else Map1. Syntax variable = object. object An object expression that evaluates to an object in the Applies To list.FindApproximateMatches( name) The FindApproximateMatches method syntax has these parts: Part Description variable An object expression that evaluates to a Strings collection that contains the results of the method’s action. name A string expression that evaluates to the name of an ARC/INFO projection file.FindArcInfoCoordinateSystem (name) The FindArcInfoCoordinateSystem method syntax has these parts: Part Description variable A variable previously declared as an object. Syntax Set variable = object. 10:00 AM .pmd 225 10/28/2004. name A string expression that specifies the street name or place name to find approximate matches for. ProgrammersReference. object An object expression that evaluates to a DataConnection object. MapObjects Programmer’s Reference 225 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. See Also FindAllPlaceNames Method Example See FindAllPlaceNames Method FindArcInfoCoordinateSystem Method Applies To DataConnection Object Description Locates an ARC/INFO Coordinate System and creates either a GeoCoordSys or ProjCoordSys object. Press F5 and then navigate through the folders in the Directory list to a folder that contains a coverage with projection information.path dc.DataConnection Dim foundProj As Object path = Dir1.ConnectError Else Label1. paste the code into the Declarations section of a form containing a DirListBox control Dir1.Caption = “” Set foundProj = dc. Option Explicit Private Sub Command1_Click() Dim path As String Dim dc As New MapObjects2. and contains parameters describing the projection. a PRJ file may contain the following information: Projection GEOGRAPHIC Zunits NO Units DD Spheroid CLARKE1866 Xshift 0. For example. units and projection-specific parameters of the coordinate system. a CommandButton named Command1 and a Label named Label1. spheroid or z units of the coordinate system (among others).Connect Then MsgBox “Could not connect to database” & Chr(13) & dc. The file is an ASCII text file. You can use the IsProjected property on the variable to discover which type of coordinate system has been returned.000000000 Yshift 0.Caption = “No projections found in current folder” Else ProgrammersReference. 226 MapObjects Programmer’s Reference Remarks ARC/INFO stores information about a coverage’s coordinate system in a PRJ file within the workspace directory.000000000 Parameters Once set. See Also FindCoordinateSystem Method Example This example uses the FindArcInfoCoordinateSystem method. The file may also contain optional parameters describing the datum.Database = path & “ If Not dc.adf”) If foundProj Is Nothing Then Label1. the returned variable may be interrogated like any other GeoCoordSys or ProjCoordSys. 10:00 AM . To try this example.pmd 226 10/28/2004.FindArcInfoCoordinateSystem(“prj. prj exten- sion.Caption = “Find Arc/Info Coordinate System” End Sub FindCoordinateSystem Method Applies To DataConnection Object Description Locates a coordinate system. MapObjects Programmer’s Reference 227 Label1. object An object expression that evaluates to a DataConnection object. To try this example.prj) file. ProgrammersReference. If no coordinate system is found. you can check the IsProjected property of the returned variable. name A string expression that evaluates to the name of a coordinate system (. See Also FindArcInfoCoordinateSystem Method Example This example uses the FindCoordinateSystem method. Syntax variable = object. with a . The metadata file has the same file name as the shapefile.Caption = “” Command1. and then navigate through the folders in the Dialog Box to find a prj file. If the FindCoordinateSystem method finds a prj file of the specified name. 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. the variable is not set. Press F5. in the same location as the shapefile.pmd 227 10/28/2004. situated in the DataConnection’s Database location.FindCoordinateSystem name The FindCoordinateSystem method syntax has these parts: Part Description variable A variable previously declared as an object. 10:00 AM .Caption = “Name: “ & foundProj. Remarks Coordinate system information for a shapefile is stored in a separate file. and creates either a GeoCoordSys or ProjCoordSys object. click Command1.Type End If End If End Sub Private Sub Form_Load() Label1.Name & vbNewLine & “Type: “_ & foundProj. the prj file is read and a ProjCoordSys or GeoCoordSys object is created. To determine the type of coordinate system that has been returned. Select the required prj file and press Open. FindEvent (tag) The FindEvent method syntax has these parts: ProgrammersReference.FindCoordinateSystem(CommonDialog1.1) Debug.DataConnection Dim foundProj As Object path = Left(CommonDialog1.prj” End Sub FindEvent Method Applies To TrackingLayer Object Description Finds a GeoEvent object on the TrackingLayer using its Tag property value Syntax object.ShowOpen Dim path As String Dim dc As New MapObjects2.pmd 228 10/28/2004.Len(CommonDialog1.ConnectError Else List1.FileTitle) If foundProj Is Nothing Then List1. 228 MapObjects Programmer’s Reference Option Explicit Private Sub Command1_Click() CommonDialog1.Connect Then MsgBox “Could not connect to database” & Chr(13) & dc.AddItem “No projections of that name found” Else List1.Type End If End If End Sub Private Sub Form_Load() CommonDialog1.Print path dc.Name List1.FileTitle) . 10:00 AM .Database = path If Not dc.Clear Set foundProj = dc.FileName) _ .AddItem foundProj. Len(CommonDialog1.FileName.Filter = “ESRI Projection files|*.AddItem foundProj. paste the code into the Declarations section of a form containing a CommonDialog control.FindGeoDataset( name) The FindGeoDataset method syntax has these parts: Part Description variable A variable that has been declared as a GeoDataset. it is recommended that the Connect method is called first. name A string expression that evaluates to a name of a GeoDataset. Press F5 and then click Command1. to allow the application to handle potential connection errors. Syntax Set variable = object. sDataSetName As String Dim sFileDirectory As String ProgrammersReference. MapObjects will automatically attempt to Connect first. tag The tag value of the GeoEvent required See Also RemoveEvent Method. In the Open dialog that displays. Remarks If you call FindGeoDataset and the DataConnection is not connected. MapObjects Programmer’s Reference 229 Part Description object An object expression that evaluates to a TrackingLayer object. To try this ex- ample. 10:00 AM . a CommandButton named Command1 and a Map named Map1. If no GeoDataset is found. The code then adds the MapLayer to a Map.pmd 229 10/28/2004. navigate to a folder that contains shapefiles and select one. the variable is not set. However. Option Explicit Private Sub Command1_Click() Dim strFileTitle As String. object An object expression that evaluates to an object in the Applies To list. See Also GeoDataset Object Example This example uses the DataConnection object’s FindGeoDataset method to associate a GeoDataset with a MapLayer. AddEvent Method FindGeoDataset Method Applies To DataConnection Object Description Locates a GeoDataset object by name. 4) ‘remove the extension Set lyr.shp)|*. 230 MapObjects Programmer’s Reference Dim dc As New MapObjects2.Database = sFileDirectory ‘the directory containing the ‘selected file If . 1.FindGeoDataset(sDataSetName) Map1.Layers.FileName.Filter = “Shapefiles (*.GeoDataset = dc.ConnectError. InStr(.FileTitle ‘just the name with the _ ‘shp extension If strFileTitle <> “” Then With CommonDialog1 sFileDirectory = Left$(. Len(strFileTitle) . ProgrammersReference.Connect Then sDataSetName = Mid(strFileTitle.ShowOpen strFileTitle = CommonDialog1.shp” CommonDialog1.DataConnection Dim lyr As New MapObjects2. .FileTitle) . 10:00 AM .FileName. 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.pmd 230 10/28/2004.MapLayer CommonDialog1.1) End With With dc .Add lyr Else MsgBox “Data Connection error #” & dc. Caption = “Fitted” ProgrammersReference. paste the code into the Declarations section of a form containing a CheckBox named Check1 and a Map named Map1. Remarks If the width of the character string is less than the distance between the points. Toggle the CheckBox to see the effect of the property. Settings The settings for boolean are: 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.TextSymbol Private Sub check1_Click() Map1. Fitted does not affect the height and width of the text.Line Dim oTSym As New MapObjects2. False (Default) MapObjects will not adjust the gap between characters of the TextSymbol object. See Also LabelRenderer Object. FittedField Property 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. 10:00 AM .TrackingLayer. 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. MapObjects will increase the gap between characters. It only adjusts the gap between charac- ters.pmd 231 10/28/2004.Refresh True End Sub Private Sub Form_Load() Check1. as described in Settings.Fitted [= boolean] The Fitted property syntax has these parts: Part Description object An object expression that evaluates to a TextSymbol object. To try this example. MapObjects Programmer’s Reference 231 Syntax object. Option Explicit Dim oLine As MapObjects2. Press F5 and then track a two-point line on the Map. 232 MapObjects Programmer’s Reference End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.OLE_HANDLE) Dim oFont As New StdFont If Not oLine Is Nothing Then oFont.Name = “Arial” oFont.Size = 36 Set oTSym.Font = oFont oTSym.Height = 0 oTSym.Color = moRed If Check1.Value = 0 Then oTSym.Fitted = False ElseIf Check1.Value = 1 Then oTSym.Fitted = True End If Map1.DrawText “Map”, oLine, oTSym End If End Sub Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x _ As Single, y As Single) Set oLine = Map1.TrackLine Map1.TrackingLayer.Refresh True 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. Syntax object.FittedField [= value] The FittedField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. value A string expression that specifies a name of a Field in a Recordset. If specified, the LabelRenderer makes use of the value contained in the Field ProgrammersReference.pmd 232 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 233 to determine whether to fit label text between a two-point Line associated with the feature. 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. See Also TextSymbol Object, Fitted Property 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 don’t have to select all three fields, if your data doesn’t have appropriate fields. Click the Label button to display the text. Option Explicit Private Sub combo1_Click() If Combo1.ListIndex <> -1 Then Command1.Enabled = True End Sub Private Sub combo2_Click() If Combo2.ListIndex <> -1 Then Command1.Enabled = True End Sub Private Sub combo3_Click() If Combo3.ListIndex <> -1 Then Command1.Enabled = True End Sub Private Sub Command1_Click() Dim oRenderer As New MapObjects2.LabelRenderer Set Map1.Layers(0).Renderer = oRenderer ProgrammersReference.pmd 233 10/28/2004, 10:00 AM 234 MapObjects Programmer’s Reference 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 Private Sub Form_Load() Dim oRecset As MapObjects2.Recordset Dim oField As MapObjects2.Field Set oRecset = Map1.Layers(0).Records For Each oField In oRecset.Fields Combo1.AddItem oField.Name Combo2.AddItem oField.Name Combo3.AddItem oField.Name Next Combo1.Text = “<choose XOffsetField>” Combo2.Text = “<choose YOffsetField>” Combo3.Text = “<choose FittedField>” Combo1.ListIndex = -1 Combo2.ListIndex = -1 Combo3.ListIndex = -1 Command1.Caption = “Label” Command1.Enabled = False End Sub Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X _ As Single, Y As Single) If Button = 1 Then Map1.Extent = Map1.TrackRectangle Else Map1.Extent = Map1.FullExtent End If End Sub ProgrammersReference.pmd 234 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 235 FlashShape Method Applies To Map Object Description Flashes a shape on a Map. Syntax object.FlashShape shape, nTimes The FlashShape method syntax has the following object qualifier and arguments: Part Description object Required. An object expression that evaluates to an object in the Applies To list. shape Required. A reference to the shape to flash. Point, Points, Line, Rectangle, Ellipse or Polygon objects are supported. nTimes Required. A numeric expression that evaluates to the number of times to flash the shape. Each flash represents approximately 0.25 seconds. See Also Symbol Object, MapLayer Object 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 Private Sub Command1_Click() Dim recs As MapObjects2.Recordset Set recs = Map1.Layers(0).Records Map1.FlashShape recs.Fields(“Shape”).Value, 4 End Sub Flattening Property Applies To Spheroid Object Description Sets or returns a value that identifies the Flattening parameter upon which the Spheroid is based. Syntax object.Flattening [= value ] ProgrammersReference.pmd 235 10/28/2004, 10:00 AM 236 MapObjects Programmer’s Reference The Flattening property syntax has these parts: Part Description object An object expression that evaluates to a Spheroid object. value A numeric expression that specifies the flattening parameter, f. 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. See Also Datum Object Example See Axis Property 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. Syntax object.Flip [= boolean] The Flip property syntax has these parts: Part Description object An object expression that evaluates to a LabelRenderer object. boolean A boolean expression specifying whether the LabelRenderer object will flip text labels so that they appear right-side up, as described in Settings. Settings The settings for boolean are: Setting Description True (Default) The LabelRenderer object will flip text labels. False The LabelRenderer object will not flip text labels. ProgrammersReference.pmd 236 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 237 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. See Also TextSymbol Object 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 Private Sub Check1_Click() Command1_Click End Sub Private Sub Command1_Click() Dim oRenderer As New MapObjects2.LabelRenderer Dim oFnt As New StdFont If List1.ListIndex <> -1 Then oFnt.Name = “Arial” oFnt.Size = 6 Set Map1.Layers(0).Renderer = oRenderer With oRenderer ‘ Symbol property returns a reference to a TextSymbol .Symbol(0).Font = oFnt .Symbol(0).Height = 0 ‘use Size of fnt .Field = List1.List(List1.ListIndex) .AllowDuplicates = False .SplinedText = True .Flip = Check1.Value End With End If Map1.Refresh ProgrammersReference.pmd 237 10/28/2004, 10:00 AM 238 MapObjects Programmer’s Reference End Sub Private Sub Form_Load() Dim oRect As MapObjects2.Rectangle Dim oRecset As MapObjects2.Recordset Dim oField As MapObjects2.Field ‘ zoom in at the start Set oRect = Map1.FullExtent oRect.ScaleRectangle (0.25) Map1.Extent = oRect Set oRecset = Map1.Layers(0).Records For Each oField In oRecset.Fields If oField.Type = moString Then List1.AddItem oField.Name End If Next Check1.Caption = “Flip” Command1.Caption = “Label” Check1.Value = 1 End Sub Private Sub List1_Click() fldname = List1.List(List1.ListIndex) End Sub Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X _ As Single, Y As Single) Map1.Extent = Map1.TrackRectangle End Sub Floor Property Applies To Rectangle Object Description Return or set the bottom height coordinate of a Rectangle object. Syntax object.Floor [= value] The Floor property syntax has these parts: ProgrammersReference.pmd 238 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 239 Part Description object An object expression that evaluates to an object in the Applies To list. value A numeric expression specifying a height coordinate. See Also Line Object Example See Ceiling Property Font Property Applies To Symbol Object, TextSymbol Object Description Returns a reference to a Font object. Syntax object.Font The Font property syntax has the following object qualifier and part: Part Description object Required. An object expression that evaluates to an object in the Applies To list. Remarks See Visual Basic Help’s Font object topic for more information about Fonts. See Also LabelRenderer Object Example This example lets you set a TextSymbol object’s 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 Private Sub Command1_Click() Dim oFont As New StdFont With CommonDialog1 .Flags = cdlCFBoth Or cdlCFEffects .ShowFont oFont.name = .FontName oFont.Size = .FontSize oFont.Bold = .FontBold ProgrammersReference.pmd 239 10/28/2004, 10:00 AM 240 MapObjects Programmer’s Reference oFont.Italic = .FontItalic oFont.Strikethrough = .FontStrikethru oFont.Underline = .FontUnderline End With Set oTextsymbol.Font = oFont ‘ set the TextSymbol object’s font oTextsymbol.Color = CommonDialog1.Color Map1.TrackingLayer.Refresh True End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.OLE_HANDLE) Static bTextDrawn As Boolean 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. Syntax object.FromGeoCoordSys [= fromCoordSys ] The FromGeoCoordSys property syntax has these parts: Part Description object An object expression that evaluates to a GeoTransformation object. fromCoordSys An object expression that evaluates to a GeoCoordSys object. See Also GeoCoordSys Object, ToGeoCoordSys Property, Direction Property Example See Direction Property ProgrammersReference.pmd 240 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 241 FromMapDistance Method Applies To Map Object Description Converts a linear measurement in map coordinates to a distance in control space. Syntax object.FromMapDistance distance The FromMapDistance method syntax has the following object qualifier and argument: Part Description object Required. An object expression that evaluates to an object in the Applies To list. distance The linear measurement in map units. 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. See Also FromMapPoint Method, ToMapDistance Method, ToMapPoint Method 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 Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X _ As Single, Y As Single) Dim ln As MapObjects2.Line Dim report As String 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.” MsgBox report, vbInformation, “Distance Measured” End Sub ProgrammersReference.pmd 241 10/28/2004, 10:00 AM 242 MapObjects Programmer’s Reference FromMapPoint Method Applies To Map Object Description Converts a Point in map coordinates to coordinates in control space. Syntax object.FromMapPoint MapPoint, xControl, yControl The FromMapPoint method syntax has the following object qualifier and arguments: Part Description object Required. An object expression that evaluates to an object in the Applies To list. MapPoint An object expression that evaluates to a Point. xControl An object expression declared to be of single data type. Contains the X coordinate of the MapPoint in control coordinates. yControl An object expression declared to be of single data type. Contains the Y coordinate of MapPoint in control coordinates. 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. See Also FromMapDistance Method, ToMapDistance Method, ToMapPoint Method 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 Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X _ As Single, Y As Single) Dim newX As Single Dim newY As Single ProgrammersReference.pmd 242 10/28/2004, 10:00 AM newX.SymbolType = moPointSymbol sym.FromMapPoint Loc.FullExtent [= rectangle] The FullExtent property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.TrackingLayer.OutlineColor = moBlue Map1. MapObjects Programmer’s Reference 243 Dim report As String report = “Event coordinates (map units): “ & vbNewLine Set rect = Map1. vbInformation. “Coordinate Information” End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ stdole.Y.Color = moRed Map1. 0) MsgBox report.X. Syntax object.pmd 243 10/28/2004. 10:00 AM .” & vbTab & Round(newY. 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. sym sym. ProgrammersReference.Style = moTransparentFill sym.Center Map1.OLE_HANDLE) If Not rect Is Nothing Then Dim sym As New MapObjects2. 0) & “.TrackRectangle Set Loc = rect. 0) & “.Refresh True ‘draw the Rectangle and its center report = report & Round(Loc.DrawShape Loc. 0) _ & vbNewLine & vbNewLine & “Derived coordinates (control units): “ _ & vbNewLine & Round(newX. newY Map1.” & vbTab & Round(Loc.Style = moCircleMarker sym.DrawShape rect.Symbol sym. Syntax object. X _ As Single. boolean A boolean expression specifying whether to redraw the map after a scroll or pan event. drag a rectangle to zoom in on the map and then click Com- mand1 to zoom back to the full extent of the map. See Also Rectangle Object Example This example uses the FullExtent property to set the Extent of a Map to its FullExtent. 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.TrackRectangle If Not Rectangle Is Nothing Then Map1. 244 MapObjects Programmer’s Reference rectangle An object of type Rectangle that MapObjects exposes. and then press F5.Extent = Map1. Y As Single) Dim Rectangle As MapObjects2. To try this example.Rectangle If Shift = 0 Then Set Rectangle = Map1. Option Explicit Private Sub Command1_Click() Map1.FullExtent End Sub Private Sub Map1_MouseDown(Button As Integer. as described in Settings.FullRedrawOnPan [= boolean] The FullRedrawOnPan property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 10:00 AM . Shift As Integer.Pan End If 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. Settings The settings for boolean are: ProgrammersReference.pmd 244 10/28/2004.Extent = Rectangle Else Map1. MapObjects Programmer’s Reference 245 Setting Description True Redraws the Map completely after a scroll or pan event. See the Remarks section of the help topic associated with FullRedrawOnPan for more information. In your code. This will force the Map control to perform a complete redraw. you might choose to set this property to True programmatically only when zoomed to a small extent. 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. 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.Value = 0 Then Map1. guaranteeing the legibility of your custom symbols.Value = 0 ProgrammersReference. In order to dramatically increase drawing speeds. In this way. and then press F5.FullRedrawOnPan = False ElseIf Check1. 10:00 AM . As a zoom out occurs. drag a rectangle to zoom in on the map and then use the right button of the mouse to pan. and at that point.FullRedrawOnPan = True End If End Sub Private Sub Form_Load() Check1. You should only consider using FullRedrawOnPan when using certain types of custom symbols or specialized renderers. See Also Pan Method. set FullRedrawOnPan to True. Option Explicit Private Sub Check1_Click() If Check1. To try this example. For instance. Recordsets at small extents are conversely small and optimizations are of lesser importance.Value = 1 Then Map1. Additionally.pmd 245 10/28/2004. MapObjects makes certain assumptions about which areas of the display need to be redrawn during a pan or scroll event. the extent could again be used to determine when to turn the optimizations back on to provide the best possible drawing speed. Custom symbols that are large or whose geographic position may change during scrolling or panning may result in a display in which they appear distorted or only partially drawn. symbols which happen to be very large at this extent would be drawn correctly when the map is panned. Refresh Method Example This example uses the FullRedrawOnPan property to control whether to redraw the map completely after a scroll or pan event. you can keep track of when the conditions are probable for this type of problem. Toggle the CheckBox to see the effect of the property. Return Values The GenerateCandidates method returns GeocodeSuccessConstants. The number of candi- dates found can be varied based on the object’s SpellingSensitivity properties.pmd 246 10/28/2004.GenerateCandidates = [success] The GenerateCandidates method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. CandidateCount Property. 10:00 AM . Shift As Integer. A suitable ProgrammersReference.Caption = “FullRedrawOnPan” End Sub Private Sub Map1_MouseDown(Button As Integer. See Also Candidate Property.TrackRectangle Else Map1. 246 MapObjects Programmer’s Reference Check1. SpellingSensitivity Property. A street network is assigned to the Geocoder object by setting the StreetTable property with a suitable GeoDataset . success A variable declared to be of integer data type. and returns a GeocodeSuccess constant indicating the status of the candidates associated with the Geocoder object. Syntax object. LocateCandidate Method Example See Candidate Property Geocoder Object An Geocoder object lets you specify an individual address or street intersection. X _ As Single. Y As Single) If Button = 1 Then Map1. or supply a table of addresses to match against a street network.Pan End If End Sub GenerateCandidates Method Applies To Geocoder Object Description Generates possible matching candidate addresses. The object’s CandidateCount property indicates how many candidates are found.Extent = Map1. you can examine the LastError property to check the type of error.mat) US addresses with zone information. StreetTables with single house range (us_srng1.mat) US 9 digit ZIP codes.mat) US addresses without zone information (us_addr2. or an ARC/ INFO coverages containing point or polygon features attributed with land parcel information. you can test the value of the Valid property.pmd 247 10/28/2004.mat) US 5 digit ZIP codes. Given a string with either a street address or an intersection (two streets delimited with an “&” symbol). Matching different types of addresses are supported in MapObjects. An address needs to be standardized before matching.mat) US addresses without zone information.mat) US intersections without zone information (us_intsc2. use the AddIndex and BuildIndices methods to create a geocoding index for the StreetTable. 10:00 AM .mat) The first time you work with the StreetTable. StreetTables with ZIP+4 centroids (zip4. To verify that the Geocoder has a valid StreetTable and that the fields specified are valid. If it is not Valid. You can verify that an index exists for the GeoDataset with the IndexStatus method. StreetTables with ZIP+4 centroids (zip4rng. You can find the following matching rule files in the Georules folder of the MapObjects installation folder: US addresses with zone information (us_addr1.mat) US addresses without zone information. StreetTables with single house range (us_srng2. you select the appropriate matching rules by specifying the MatchRules and IntersectionMatchRules properties. MapObjects Programmer’s Reference 247 GeoDataset may consist of either a line shapefile attributed with road names. and associate it with the Geocoder object’s Standardizer property before you can geocode an address. An index is searched based on the queries defined in the SearchQueries property.mat) US 9 digit ZIP codes.mat) US intersections with zone information (us_intsc1. StreetTables with Polygon or Point information (us_snum2. You must set a Standardizer object’s properties.mat) US addresses with zone information. you can invoke the GenerateCandidates method to get the possible matching ProgrammersReference. StreetTables with Polygon or Point information (us_snum1. StreetTables with 5 digit ZIP centroids (zip. 248 MapObjects Programmer’s Reference candidates. creating a new shapefile containing the results of the matching. Standardizer Object Example To try this example. You can create Geocoder objects in Visual Basic like this: Dim geo as New MapObjects2. Substitute appropriate values for the data paths and then press F5. and SqueezeFactor properties. Offset. ProgrammersReference. During the batch matching process. which returns an AddressLocation object. You can then match the address against the best candidate with the LocateCandidate method. paste the code into the Declarations section of a form that contains a Map named Map1. a CommandButton named Command1.pmd 248 10/28/2004.Geocoder Remarks MapObjects supports foreign language (8-bit) geocoding. Properties BatchMatchVariableField MatchVariable Offset Candidate MatchVariableCount SearchQueries CandidateCount MatchVariableField Standardizer IntersectionMatchRules MatchVariableIntersectionLink IntersectionMatchVariableCount SpellingSensitivity SqueezeFactor LastError MatchWhenAmbigous Valid MatchRules MinimumMatchScore Methods AddIndex EraseIndices ListIndices BatchMatch GenerateCandidates LocateCandidate BuildIndices IndexStatus See Also AddressLocation Object. If you have address data in a Table you can use the BatchMatch method to perform address matching on each record. you can control the sensitivity of the matching process by adjusting the values in the MatchWhenAmbiguous and MinimumMatchScore properties. 10:00 AM . You can also set other geocoding preferences that apply to both interactive and batch matching with the SpellingSensitivity. and two TextBoxes named Text1 and Text2. StandardizingRules = “C:\Program Files\ESRI\MapObjects2\ _ ProgrammersReference.AddressLocation If stan.CandidateCount > 0 Then Set foundLoc = geo.DataConnection Dim gd As Object Dim lyr As New MapObjects2. set it with an empty string Private Const m_FromLeft = “L_f_add” Private Const m_FromRight = “R_f_add” Private Const m_ToLeft = “L_t_add” Private Const m_ToRight = “R_t_add” Private Const m_PreDir = “Prefix” Private Const m_PreType = “Pre_type” Private Const m_StreetName = “Name” Private Const m_StreetType = “Type” Private Const m_SufDir = “Suffix” Private Const m_LeftZone = “Zipl” Private Const m_RightZone = “ZipR” Private Sub Command1_Click() ‘Locate an address to its best candidate Dim foundLoc As MapObjects2.Text geo.FlashShape foundLoc.Standardizer ‘Set global variables with field names in the StreetTable ‘Modify if fields names in StreetTable are different ‘If a field is not available.pmd 249 10/28/2004.Text) Then stan. 10:00 AM .location.StandardizeAddress(Text1.LocateCandidate(0) Map1.MapLayer Dim f. 3 End If End If End Sub Private Sub Form_Load() Dim dc As New MapObjects2.FieldValue(“ZN”) = Text2. MapObjects Programmer’s Reference 249 Option Explicit Dim geo As New MapObjects2.Geocoder Dim stan As New MapObjects2.GenerateCandidates If geo. i As Integer Dim name As String ‘Set up Standardizer stan. MatchVariableField(“ToLeft”) = m_ToLeft geo.mat” geo.Add lyr geo.MatchVariableIntersectionLink(“StreetType”.Symbol.pmd 250 10/28/2004.MatchVariableField(“LeftZone”) = m_LeftZone geo.Connect If Not dc.MatchVariableIntersectionLink(“PreDir”. mgLinkPrimary) _ = “PreType1” geo.FindGeoDataset(“redlands”) lyr.Standardizer = stan dc.MatchVariableField(“FromLeft”) = m_FromLeft geo. mgLinkPrimary) _ = “StreetName1” geo.MatchVariableField(“PreDir”) = m_PreDir geo.IntersectionStandardizingRules = “C:\Program Files\ _ ESRI\MapObjects2\GeoRules\us_intsc.GeoDataset = gd lyr.Color = moBlue Map1. 250 MapObjects Programmer’s Reference GeoRules\us_addr. mgLinkPrimary) = “PreDir1” geo.mat” ‘ Link the Match Variables to fields in the StreetTable geo.MatchVariableIntersectionLink(“StreetName”.MatchVariableField(“SufDir”) = m_SufDir geo.MatchVariableField(“RightZone”) = m_RightZone ‘ Link the intersection group 1 variables geo.MatchVariableField(“StreetName”) = m_StreetName geo.MatchVariableField(“PreType”) = m_PreType geo.connected error” End End If ‘Set up the StreetTable Set gd = dc.Database = “C:\Program Files\ESRI\MapObjects2\ _ Samples\Data\Redlands” dc.StreetTable = gd ‘Set up the match rules and variables geo.stn” geo.Connected Then MsgBox “dc. mgLinkPrimary) _ ProgrammersReference.MatchVariableField(“ToRight”) = m_ToRight geo.MatchVariableIntersectionLink(“PreType”.MatchVariableField(“StreetType”) = m_StreetType geo.MatchVariableField(“FromRight”) = m_FromRight geo.MatchRules = “C:\Program Files\ESRI\MapObjects2 _ \GeoRules\us_addr1. 10:00 AM .Layers.IntersectionMatchRules = “C:\Program Files _ \ESRI\MapObjects2\GeoRules\us_intsc1.stn” stan. MatchVariableIntersectionLink(“SufDir”. _ mgIndexExists Then If Not geo.AddIndex(m_StreetName.MatchVariableIntersectionLink(“RightZone”. mgLinkPrimary) _ = “LeftZone1”_ geo. mgLinkSecondary) _ = “PreType2” geo. mgIndexTypeNormal) Then MsgBox “Cannot build geocoding index. mgLinkSecondary) _ = “StreetName2” geo. mgLinkSecondary) _ = “SufDir2” geo.MatchVariableIntersectionLink(“PreDir”. mgIndexTypeSoundex) Then MsgBox “Cannot build geocoding index. mgLinkPrimary) _ = “RightZone1” ‘ Link up intersection group 2 variables geo. vbCritical End Else MsgBox “Indices are built. MapObjects Programmer’s Reference 251 = “StreetType1” geo.BuildIndices(True) Then MsgBox “Cannot build geocoding index. mgLinkSecondary) _ = “RightZone2” ‘Build indices if haven’t If Not geo.”.MatchVariableIntersectionLink(“StreetType”. vbCritical End End If If Not geo. mgLinkSecondary) _ = “PreDir2” geo.pmd 251 10/28/2004.” End If End If ProgrammersReference.”. mgLinkSecondary) _ = “LeftZone2” geo. m_RightZone.MatchVariableIntersectionLink(“LeftZone”.IndexStatusConstants. mgLinkPrimary) _ = “SufDir1” geo. “”.MatchVariableIntersectionLink(“RightZone”.”.MatchVariableIntersectionLink(“LeftZone”. mgLinkSecondary) _ = “StreetType2” geo.MatchVariableIntersectionLink(“StreetName”. vbCritical End End If If Not geo.IndexStatus = MapObjects2.MatchVariableIntersectionLink(“PreType”.AddIndex(m_LeftZone.MatchVariableIntersectionLink(“SufDir”. 10:00 AM . Add “SN? & ZN” queries. which is defined in the PrimeMeridian property. with one best candi- date. mgGeocodeSuccessMultipleBest 2 Successful match. A geographic coordinate system is based on a datum.SearchQueries = queries Command1.Add “SN?” Set geo. with multiple best candidates. 10:00 AM . mgGeocodeSuccessSingleBest 1 Successful match.Strings queries. The line of zero longitude is named the prime meridian. MatchCode Property GeoCoordSys Object A geographic coordinate system describes positions on the earth using a coordinate system based on latitude-longitude coordinates. defined in the Datum property.Text = “92373” End Sub GeocodeSuccess Constants MapObjects defines the following constants for use with the Geocoder object’s GenerateCandidates method. The units of the coordinate system are defined in the Unit property. No candidates were found. Constant Value Description mgGeocodeFailed 0 Geocode failed.Caption = “Locate Address” Text1.Text = “260 Cajon St” Text2.pmd 252 10/28/2004. mgGeocodeSuccessPartial 3 Geocode was partially successful. See Also Geocoder Object. ProgrammersReference. but no candidates greater or equal to the minimum match score. 252 MapObjects Programmer’s Reference ‘Set search queries Dim queries As New MapObjects2. Syntax object. MapObjects Programmer’s Reference 253 A standard geographic coordinate system can be created by setting the Type property with a GeographicCoordSysConstants. geoCoordSys An object expression that evaluates to a GeoCoordSys object Remarks The GeoCoordSys property contains a GeoCoordSys object defining the geographical coordinate system from which the ProjCoordSys is projected. using the GeoCoordSys object’s Transform method.pmd 253 10/28/2004. 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. Projection Object. a user-defined geographic coordinate system can be defined by setting the Datum. PrimeMeridian and Unit properties of a GeoCoordSys object to specific objects. Alternatively. Coordinate system metadata can be stored on disk for later retrieval using the GeoCoordSys object’s Export method. A GeoCoordSys can be applied to a MapLayer or Map Control via the CoordinateSystem property of these objects.GeoCoordSys [= geoCoordSys ] The GeoCoordSys property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. MapLayer Object. 10:00 AM . which include over two-hundred and fifty pre-defined geographic coordinate systems. An individual shape can be projected to another ProjCoordSys or GeoCoordSys. ProgrammersReference. Properties Datum Name Type Unit IsProjected PrimeMeridian Methods Export ReturnDescription Transform See Also Map Object. a command button named Command1 and a ListView named ListView1. curLayer.CoordinateSystem. 254 MapObjects Programmer’s Reference See Also GeoCoordSys Object Example This example uses the GeoCoordSys property of a ProjCoordSys object to summarize the geographic coordinate systems applied to projected layers.Symbol Private Sub Command1_Click() Dim itmX As ListItem Dim curLayer As MapObjects2.CoordinateSystem.Add(.SubItems(1) = curLayer.Add(.Add(3. 10:00 AM .ColumnHeaders.MapLayer For Each curLayer In Map1.Name itmX.Add(1.ColumnHeaders.SubItems(1) = “<Layer not projected>” itmX. “Geographic CS”) End Sub ProgrammersReference.Name ElseIf Not curLayer.pmd 254 10/28/2004.ListItems. “Layer”) Set lvwHead1 = ListView1.ListItems. Map1 should contain more than one MapLayer.CoordinateSystem. . curLayer.CoordinateSystem. Press F5. . paste the code into the Declarations section of a form containing a Map named Map1. .Name) itmX.GeoCoordSys.SubItems(2) = curLayer. each having a coordinate system set. “Projected CS”) Set lvwHead1 = ListView1.CoordinateSystem. Option Explicit Dim symPCS As New MapObjects2.Layers If curLayer.ColumnHeaders. .IsProjected Then Set itmX = ListView1.Name End If Next curLayer End Sub Private Sub Form_Load() Command1.View = lvwReport Dim lvwHead1 As ColumnHeader Set lvwHead1 = ListView1.SubItems(2) = curLayer.Caption = “Summarise CS” ListView1. To try this example. and click the command button.IsProjected Then Set itmX = ListView1.Symbol Dim symGCS As New MapObjects2.Name) itmX.Add(2. . Name is the default property for a GeoDataset object. Syntax Set variable = object. Use the HasZ and HasMeasure properties to test whether the GeoDataset supports Z values or Measures. Properties AllowSharing HasMeasure HasZ Name See Also DataConnection Object.GeoDatasets ProgrammersReference. Database Property GeoDatasets Property Applies To DataConnection Object Description Returns a reference to the collection of GeoDatasets in a DataConnection. 10:00 AM . MapObjects Programmer’s Reference 255 GeoDataset Object A GeoDataset object represents a layer of geographic data. Properties Count Methods Item See Also DataConnection Object. To share the GeoDataset with other applications for reading and writing (while you are not editing it) set AllowSharing to True. which will determine which GeoDatasets are returned. This geographic data may be held in any of the vector data formats supported by MapObjects. A DataConnection object’s Database property includes a data source specific suffix for certain data sources. GeoDatasets Property GeoDatasets Collection A GeoDatasets collection contains all GeoDataset objects found in a DataConnection.pmd 255 10/28/2004. The GeoDataset object is associated with the MapLayer object in order to display the data in a Map. Note: if used with a CAD DataConnection. See Also GeoDataset Object. the GeoDatasets property will return a collection containing all files in the directory.Clear ‘For each type of database connection For i = 0 To 2 searchDir (i) Next i End Sub Private Sub searchDir(Index As Integer) Dim dc As New MapObjects2.DataConnection Dim oDataset As MapObjects2. To try this example. as errors will occur if you set a MapLayer’s GeoDataset with an unsupported file format. MapLayer Object Example This example uses the GeoDatasets property to list all the Shapefile. and a ListBox named List1.pmd 256 10/28/2004.Connect Then ProgrammersReference. 10:00 AM . Remarks A DataConnection object’s Database property includes a data source specific suffix for certain data sources. VPF and Coverage GeoDatasets in a DataConnection object’s Database. i. Option Explicit Dim dbSuffix(0 To 3) As String Private Sub dir1_Change() Dim i As Integer List1. 256 MapObjects Programmer’s Reference The GeoDatasets property syntax has these parts: Part Description variable A variable that has been declared as a collection of GeoDatasets. TableDesc Object.e. paste the code into the Declarations section of a form containing a DirListBox control named Dir1. the Database property begins with ‘[CAD]’.Database = dbSuffix(Index) & Dir1. which will determine which GeoDatasets are returned to the GeoDatasets collection.path If . object An object expression that evaluates to an object in the Applies To list. Press F5 and then navigate through the folders in the Directory list to a folder that represents a Database that contains GeoDatasets. Be careful to select the correct GeoDataset.GeoDataset ‘Check for Geodatasets in current database With dc . You can use the Index property with the TrackingLayer object’s Event property and RemoveEvent method.path = path Else Dir1.GeoDatasets List1.path = “C:\” End If End Sub GeoEvent Object A GeoEvent object represents a geographically referenced phenomenon whose position may change. Each GeoEvent is depicted with a Symbol. Polygon or Ellipse. Line. identified by it’s by SymbolIndex. Points.Count > 0 Then For Each oDataset In .AddItem oDataset. The read-only Index property returns the GeoEvent object’s current position on the TrackingLayer. 10:00 AM .pmd 257 10/28/2004.ocx”) If Len(path) <> 0 Then Dir1.Name Next End If End If End With End Sub Private Sub Form_Load() dbSuffix(0) = “” dbSuffix(1) = “[ARC]” dbSuffix(2) = “[VPF]” Dim path As String path = Dir(“C:\Program Files\ESRI\MapObjects2\Mo20. Properties Index Shape SymbolIndex Tag Methods ProgrammersReference. A GeoEvent displays on a Map object’s TrackingLayer. Rectangle. and may be a Point. You can return the location of GeoEvent using its X and Y properties. MapObjects Programmer’s Reference 257 If . You can move a GeoEvent with the Move or MoveTo methods.GeoDatasets. You must also set a CoordinateSystem on the Map and on the MapLayer. See the online help for a full list of GeographicCoordSysConstants. Type Property GeographicTransformation Property Applies To MapLayer Object Description Returns or set the GeographicTransformation of a MapLayer. 258 MapObjects Programmer’s Reference Move MoveTo See Also TrackingLayer Object GeographicCoordSys Constants MapObjects defines over one hundred and fifty constants for use with the Type property of a GeoCoordSys object.pmd 258 10/28/2004. MapObjects will re- project the MapLayer. ProgrammersReference. MapLayers that do not have a CoordinateSystem set will be displayed unprojected. This property is used for on- the-fly projection of a MapLayer.GeographicTransformation [= trans] The GeographicTransformation property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Remarks When a MapLayer has its GeographicTransformation property set. trans A variant expression which equals a valid GeoTransformation object. Syntax object. Type Property GeographicTransformation Constants MapObjects defines over one hundred and fifty constants for use with the Type property of a GeoTransformation object. 10:00 AM . See Also GeoCoordSys Object. on the fly. according to that geographic transformation. See Also GeoTransformation Object. See the online help for a full list of GeographicTransformationConstants. Type = moGeoTransformation_NAD27_To_NAD83_CONUS ‘ Define two map layers Dim lyA As MapObjects2.Layers(1) ‘this layer contains the NAD83 based dataset Set lyB = Map1. Now try running the code with the indicated GeographicTransformation property line commented out to see the differ- ence. paste the code into the Declarations section of a new Form which has a Map named Map1 containing two MapLayers. Then press F5.GeoTransformation m_GT. in this case we are using datasets that are ‘ based on NAD27 and NAD83 datum gcs_nad27. Dim m_GT As New MapObjects2. ‘ Define two geographic coordinate systems Dim gcs_nad27 As New MapObjects2.Type = moGeoCS_NAD1983 ‘ Create a GeoTransformation object and set it to the ‘ pre-defined type ‘ NAD27_To_NAD83_CONUS ‘ Using this geotransformation will take us from NAD27 to NAD83 ‘ as we have used the default direction “forward”.. To try this example. and set them appropriately ‘this layer contains the NAD27 based dataset Set lyA = Map1. 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 Private Sub Form_Load() ‘ You will need to modify the code for the specific ‘ GeoCoordSys or ProjCoordSys that your data is based upon.Type = moGeoCS_NAD1927 gcs_nad83. and zoom in on a small area of the Map.MapLayer ‘. Type Property. 10:00 AM .GeoCoordSys ‘ and set them .Layers(0) ‘ Set each layer to have the appropriate geographic ‘ coordinate system ProgrammersReference.MapLayer Dim lyB As MapObjects2. Name Property Example This example demonstrates the use of a GeoTransformation object which is set as the GeographicTransformation property on a MapLayer. MapObjects Programmer’s Reference 259 See Also Valid Property..pmd 259 10/28/2004.GeoCoordSys Dim gcs_nad83 As New MapObjects2. .Extent = Map1.OutlineColor = moBlue .Outline = True . Transformations can be defined in both forward and reverse directions ProgrammersReference.OutlineColor = moMaroon . it is possible to use a GeoTransformation object to perform a geographic transformation or datum shift.CoordinateSystem = gcs_nad27 lyB. 10:00 AM .pmd 260 10/28/2004.Style = moUpwardDiagonalFill .GeographicTransformation = m_GT ‘. which include nearly one thousand pre-defined geographic transformations. MapObjects implements industry standard geographic transformations.CoordinateSystem = gcs_nad83 ‘Set the MapLayer symbols so we can see both layers With lyA.Size = 1 End With End Sub Private Sub Map1_MouseDown(Button As Integer.Symbol .TrackRectangle End Sub GeoTransformation Object When converting vector data from one coordinate system to another.. finally. The majority of these pre-defined geographic transformations define transformations from a range of datum to the WGS1984 datum.Symbol . These can be created by setting the Type property with an appropriate GeographicTransformationConstants.Size = 2 End With With lyB.Style = moTransparentFill . Y As Single) Map1.Color = moRed . X As _ Single. 260 MapObjects Programmer’s Reference lyA.Outline = True . set the map control to display using the NAD83 ‘ geographic coordinate System Map1.CoordinateSystem = gcs_nad83 ‘.. Shift As Integer.and set the NAD27 based layer to use the NAD27_to_NAD83 ‘ GeoTransformation to see the difference between the accuracy ‘ of the transformation without using the GeoTransformation object ‘ comment this line out lyA.. The GetParameter. Use the FromGeoCoordSys and ToGeoCoordSys properties to define the GeoCoordSys that the transformation starts from and transforms to. Set the Method property with a MethodConstant to specify which mathematical methodology is used to transform the geographic coordinates. allowing for the change in datum between the coordinate systems. Use GetParameter to read these parameters. Restrictions: It is not possible to extract information. NB. other than the name and direction. It is not possible to set up a two stage user-defined transformation. 10:00 AM . The Z values on all the points of a shape will be modified appropriately. about the second stage of a two stage predefined transformation. You can use the SecondType and SecondDirection properties to create a two-stage transformation. Each parameter of the transformation Method can be set using the SetParameter method. Alternatively. neither of which is based on the WGS1984 datum. FromGeoCoordSys and Method properties of a GeoTransformation object to specific objects. GeoCoordSys Object ProgrammersReference. therefore transformations can also be specified from the WGS1984 datum to an alternative datum. MapObjects Programmer’s Reference 261 by setting the Direction property. Properties Direction Name SecondName ToGeoCoordSys FromGeoCoordSys SecondDirection SecondType Type Method Methods GetParameter SetParameter See Also Projection Object. ToGeoCoordSys and FromGeoCoordSys methods and properties will return values and objects that have also been set using the Type property. Method. Name. It is not possible for one stage of a two stage transformation to be predefined and the other stage user-defined. a user-defined geographic transformation can be defined by setting the ToGeoCoordSys. Many situations require a transformation between two coordinate systems.pmd 261 10/28/2004. paste the code into the Declarations section of a new Form which has two Map controls named Map1 and Map2. ptIn As MapObjects2.Point Dim curMap As Integer Dim sym As New MapObjects2. and displayed on both maps. ‘We need to check if the type before assigning the ‘FromGeoCoordSys and ToGeoCoordSys Dim map1Projected As Boolean Dim map2Projected As Boolean If Map1. an appropriate GeoTransformation is created for transforming ‘the selected Point.Symbol Private Function transformPoint(direction As _ MapObjects2.DirectionConstants.Point) As Point ‘Here.IsProjected Then map2Projected = True Else map2Projected = False End If ‘If changing from WGS1984 to other datum If direction = moDirection_Forward Then If map1Projected Then ProgrammersReference.pmd 262 10/28/2004. To try this example. Then press F5. Each Map should contain a MapLayer with geographical locations in common.CoordinateSystem. Dim myGT As New MapObjects2.CoordinateSystem. 262 MapObjects Programmer’s Reference Example This example demonstrates the Direction property of the GeoTransformation object. The point will be transformed to the other maps coordinate system.Type = moGeoTransformation_OSGB1936_To_WGS1984_1 ‘Set the appropriate direction. Ensure the coordinate systems of each MapLayer are set appropriately. Option Explicit Dim fromPt As New MapObjects2. This should be changed appropriately for the ‘CoordinateSystem of your Map2 MapLayer. FromGeoCoordSys and ToGeoCoordSys myGT.GeoTransformation myGT. 10:00 AM .Point Dim toPt As New MapObjects2.direction = direction ‘A CoordinateSystem may be either ProjCoordSys or GeoCoordSys. and click on either Map.IsProjected Then map1Projected = True Else map1Projected = False End If If Map2. sym End If End Sub Private Sub Map1_MouseDown(Button As Integer. MapObjects Programmer’s Reference 263 myGT. myGT) End If End Function Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ stdole.Color = moBlue Map1.ToGeoCoordSys = Map1.CoordinateSystem.CoordinateSystem. 10:00 AM .Color = moRed Map1. fromPt.ToGeoCoordSys = Map1. .pmd 263 10/28/2004. myGT) ElseIf direction = moDirection_Reverse Then If map1Projected Then myGT.CoordinateSystem.CoordinateSystem. X _ ProgrammersReference.GeoCoordSys Else myGT.Transform _ (Map1.Transform _ (Map2.CoordinateSystem End If Set transformPoint = Map1. Shift As Integer.DrawShape toPt.CoordinateSystem.ToGeoCoordSys = Map2.GeoCoordSys Else myGT.OLE_HANDLE) If (Not fromPt Is Nothing) And curMap = 1 Then sym. fromPt.FromGeoCoordSys = Map2.FromGeoCoordSys = Map1.FromGeoCoordSys = Map1.CoordinateSystem.DrawShape fromPt.CoordinateSystem.CoordinateSystem End If Set transformPoint = Map2.CoordinateSystem.ToGeoCoordSys = Map2. sym End If If (Not toPt Is Nothing) And curMap = 2 Then sym.FromGeoCoordSys = Map2.CoordinateSystem End If If map2Projected Then myGT. .GeoCoordSys Else myGT.CoordinateSystem End If If map2Projected Then myGT.GeoCoordSys Else myGT. Y) Set toPt = transformPoint(moDirection_Forward. ‘Map2 should contain a MapLayer based on a different Datum ‘You should ensure the CoordinateSystem of both layers is set ‘correctly.Layers(0).Refresh (True) Map2. Y) Set toPt = transformPoint(moDirection_Reverse.ToMapPoint(X.Refresh (True) End Sub Private Sub Form_Load() ‘Map1 should contain a MapLayer based on the WGS1984 Datum.OLE_HANDLE) If (Not fromPt Is Nothing) And curMap = 2 Then sym.Color = moBlue Map2.Layers(0). Y As Single) Set fromPt = Map2. fromPt) curMap = 1 Map1. sym End If End Sub Private Sub Map2_MouseDown(Button As Integer.ToMapPoint(X.GeoCoordSys gcs. Dim pcs As New MapObjects2. Y As Single) Set fromPt = Map1.Color = moRed Map2. for ‘example the World Countries sample dataset.TrackingLayer.TrackingLayer. 10:00 AM .pmd 264 10/28/2004.CoordinateSystem = gcs ‘Here the CoordinateSystem of each map is set to the ‘CoordinateSystem of its MapLayer ProgrammersReference.Refresh (True) Map2. Shift As Integer. 264 MapObjects Programmer’s Reference As Single.ProjCoordSys pcs.Type = moProjCS_BritishNationalGrid Map2.DrawShape toPt.Type = moGeoCS_WGS1984 Map1.TrackingLayer.TrackingLayer. sym End If If (Not toPt Is Nothing) And curMap = 1 Then sym. X As _ Single.CoordinateSystem = pcs Dim gcs As New MapObjects2. fromPt) curMap = 2 Map1.DrawShape fromPt.Refresh (True) End Sub Private Sub Map2_AfterTrackingLayerDraw(ByVal hDC As _ stdole. Press F5 and then drag at least two polygons that cross on the Map.Left + Map1. MapObjects Programmer’s Reference 265 Map1. 5000 Map2.pmd 265 10/28/2004. Rectangle Object Description Returns a Points collection whose members represent the points at which two objects cross.Width + 60 Form1.Size = 4 . 60. Map1.Width.Width = Map2. object An object expression that evaluates to an object in the Applies To list. _ Map1. Line Object. Points Collection. Points.Layers(0). 10:00 AM . paste the code into the Declarations section of a form containing a Map named Map1.Move 60.Left + Map2.Top + Map2.SymbolType = moPointSymbol . Syntax Set variable = object.Outline = False . See Also Intersect Method Example This example uses the GetCrossings method to return a Points collection whose members represent the points at which two objects cross. 5000. To try this example.Width + 100.CoordinateSystem Map2. Line.Style = moTriangleMarker End With ‘Arrange controls Map1. shape An object expression that evaluates to a Point.CoordinateSystem = Map1.Height + 60 End Sub GetCrossings Method Applies To Point Object.CoordinateSystem = Map2. Polygon or Rectangle object.Move Map1.CoordinateSystem With sym .Height Form1. Polygon Object. Option Explicit Private moPolys As New Collection ProgrammersReference. Map1.Top.GetCrossings( shape) The GetCrossings method syntax has these parts: Part Description variable An object expression that evaluates to a Points object.Height = Map2.Layers(0). Polygon Dim oPoint As MapObjects2.Symbol Dim oPolygon As MapObjects2.TrackPolygon If moPolys.Point Dim oCrossings As MapObjects2.OLE_HANDLE) Dim oSymbol As New MapObjects2.DrawShape oPolygon.pmd 266 10/28/2004.DrawShape oPoint.Style = moCircleMarker .Refresh True End Sub ProgrammersReference.SymbolType = moPointSymbol .Count = 2 Then Set oCrossings = moPolys(1). x _ As Single.Polygon Set oPolygon = Map1. y As Single) Dim oPolygon As New MapObjects2.TrackingLayer.Points ‘symbol for polygons With oSymbol .OutlineColor = moRed End With ‘symbol for crossing points With oSymbol2 . oSymbol Next If moPolys. 266 MapObjects Programmer’s Reference Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole. Shift As Integer.Remove 2 End If moPolys.Symbol Dim oSymbol2 As New MapObjects2.Count = 2 Then moPolys. oSymbol2 Next End If End Sub Private Sub Map1_MouseDown(Button As Integer. 10:00 AM .Color = moBlue End With For Each oPolygon In moPolys Map1.Style = moTransparentFill .GetCrossings(moPolys(2)) For Each oPoint In oCrossings Map1.Add oPolygon Map1. MapObjects Programmer’s Reference 267 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. Syntax Set variable = object.GetParameter paramType 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 object An object expression that evaluates to an object in the Applies To list. paramType A value or constant that identifies which parameter’s value is to be read, as specified in Settings Settings The settings for paramType are ParameterTypeConstants 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. See Also SetParameter Method, ParameterTypeConstants 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. It’s 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 Private Sub Combo1_Click() ProgrammersReference.pmd 267 10/28/2004, 10:00 AM 268 MapObjects Programmer’s Reference Dim getParam As String Dim pcsParams As New MapObjects2.Strings 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 Private Sub Command1_Click() Dim val As Double val = Text1.Text choice = Combo1.List(Combo1.ListIndex) ‘New PCS Object is defined here Dim proj As New MapObjects2.Projection proj.Type = PCS.Projection.Type Dim currParam As String currParam = stripProj(choice) newPCS.Type = PCS.Type newPCS.SetParameter currParam, val ‘As the PCS is now Custom (type = -1) we cannot access it’s ‘properties as before Label1.Caption = “New custom PCS set” End Sub Private Sub Form_Load() Combo1.Clear Text1.Text = “” List1.Clear Command1.Caption = “Set Parameter” Label1.Caption = “No custom PCS” ProgrammersReference.pmd 268 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 269 Dim projCoord As New MapObjects2.Strings projCoord.PopulateWithProjectedCoordSys Dim i As Variant For Each i In projCoord Combo1.AddItem “ProjCoordSys: “ & i Next i Combo1.ListIndex = 0 End Sub Function stripProj(theProjection As String) As Variant ‘Get position of open bracket Dim openB As Integer openB = InStr(theProjection, “[“) stripProj = Left(Right(theProjection, Len(theProjection) - openB), _ Len(theProjection) - openB - 1) End Function 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. Syntax Private Sub object_GotFocus() The GotFocus event syntax has one part: Part Description object An object expression that evaluates to a Map control. 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- ProgrammersReference.pmd 269 10/28/2004, 10:00 AM 270 MapObjects Programmer’s Reference 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 Count DrawBackground Renderer Methods Add Remove See Also ChartRenderer Object, ClassBreaksRenderer Object, DotDensityRenderer Object, LabelRenderer Object 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 Private Sub Command1_Click() Map1.Extent = Map1.FullExtent End Sub Private Sub Form_Load() ‘establish the ChartRenderer’s properties With cr .ChartType = moPie .FieldCount = 5 .Field(0) = “married” .Color(0) = moKhaki .Field(1) = “divorced” .Color(1) = moGreen .Field(2) = “separated” .Color(2) = moOrange ProgrammersReference.pmd 270 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 271 .Field(3) = “nevermarry” .Color(3) = mogrey .Field(4) = “widowed” .Color(4) = moOlive .MinPieSize = 8 .MaxPieSize = 24 .SizeField = “pop1990” .NormalizationField = “area” End With ‘strings collection to hold unique values Dim strs As New MapObjects2.Strings strs.Unique = True Dim recset As MapObjects2.Recordset Set recset = Map1.Layers.Item(“states”).Records Do While Not recset.EOF strs.Add recset.Fields(“sub_region”).ValueAsString recset.MoveNext Loop ‘establish the properties of the ValueMapRenderer With vmr .UseDefault = True .SymbolType = moFillSymbol .Field = “sub_region” .ValueCount = strs.Count Dim s As Variant Dim i As Integer ‘ set the values for the renderer i = 0 For Each s In strs .Value(i) = s .Symbol(i).Color = QBColor(i + 1) i = i + 1 Next s End With ‘add the two renderers to the GroupRenderer ‘note that the last one added is the last one drawn gr.Add vmr gr.Add cr ProgrammersReference.pmd 271 10/28/2004, 10:00 AM 272 MapObjects Programmer’s Reference ‘assign the GroupRenderer as the MapLayer’s renderer Map1.Layers.Item(“states”).Renderer = gr End Sub Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x _ As Single, y As Single) If Button = 1 Then Map1.Extent = Map1.TrackRectangle Else Map1.Pan End If End Sub HasMeasure Property Applies To GeoDataset Object Description Returns a value indicating whether the GeoDataset object has the ability to support measures. Syntax object.HasMeasure [= hasM] The HasMeasure property syntax has these parts: Part Description object An object expression that evaluates to a GeoDataset object. hasM A boolean expression specifying whether the dataset has measures. See Return Values. Return Values The HasMeasure return values are: Value Description True The GeoDataset supports measures False The GeoDataset does not support measures 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. ProgrammersReference.pmd 272 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 273 See Also Recordset Object, Table Object HasZ Property Applies To GeoDataset Object Description Returns a value indicating whether the GeoDataset object supports Z values. Syntax object.HasZ [= hasZ] The HasZ property syntax has these parts: Part Description object An object expression that evaluates to a GeoDataset object. hasZ A boolean expression specifying whether the dataset has Z values. See Return Values. Return Values The HasZ return values are: Value Description True The GeoDataset supports height (Z) values. False The GeoDataset does not support height (Z) values. 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. See Also Recordset Object, Table Object 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 Private Sub Command1_Click() ProgrammersReference.pmd 273 10/28/2004, 10:00 AM 274 MapObjects Programmer’s Reference Dim oConnection As New MapObjects2.DataConnection Dim theGDS As New MapObjects2.GeoDataset Dim oDataset As MapObjects2.GeoDataset 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 Private Sub Form_Load() ‘Change the file location as appropriate Text1.Text = “C:\Files\Testing” 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. Syntax object.Height [= number] The Height property syntax has these parts: ProgrammersReference.pmd 274 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 275 Part Description object An object expression that evaluates to an object in the Applies To list. number A numeric expression specifying the dimensions of an object. Measure- ments are from the center of the object’s border so that objects with different border widths align correctly. These properties use the scale units of the object’s container. If object is a TextSymbol, then number is a numeric expression in map units specifying the height to draw the text. If number is set to zero (0.0), DrawText will use the Size property of the Font of the TextSymbol object. See Also Bottom Property, Top Property, Width Property 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 Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x _ As Single, y As Single) Dim oRectangle As MapObjects2.Rectangle Set oRectangle = Map1.TrackRectangle 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. Syntax object.HeightField [= value] The HeightField property syntax has these parts: ProgrammersReference.pmd 275 10/28/2004, 10:00 AM 276 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list. value A string expression that specifies a name of a Field in a Recordset. If specified, the LabelRenderer makes use of the value of the specified Field to set the height of the label. The Field specified by HeightField stores the height to render the label in Map control units. Remarks If you set the HeightField property, you will override the Size property of the TextSymbol object’s Font. See Also TextSymbol Object 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 Private Sub Command1_Click() Dim oLayer As New MapObjects2.LabelRenderer Dim oFont As New StdFont If Combo1.ListIndex <> -1 And Combo2.ListIndex <> -1 Then oFont.Name = “Arial” With oLayer .HeightField = Combo1.List(Combo1.ListIndex) .Field = Combo2.List(Combo2.ListIndex) .SymbolCount = 1 Set .Symbol(0).Font = oFont End With Map1.Layers(0).Renderer = oLayer Map1.Refresh End If ProgrammersReference.pmd 276 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 277 End Sub Private Sub Form_Load() Dim oRecset As MapObjects2.Recordset Dim oField As MapObjects2.Field Set oRecset = Map1.Layers(0).Records For Each oField In oRecset.Fields If oField.Type < moString Then Combo1.AddItem oField.Name End If Combo2.AddItem oField.Name Next Label1.Caption = “Height Field” Label2.Caption = “Text Field” Label1.AutoSize = True Label2.AutoSize = True Label1.Left = Map1.Left Label2.Left = Map1.Left Label1.Top = Map1.Top + Map1.Height + (Label1.Height * 2) Label2.Top = Label1.Top + (Label2.Height * 2) Combo1.Left = Label1.Left + (Label1.Width * 1.5) Combo2.Left = Combo1.Left Combo1.Top = Label1.Top Combo2.Top = Label2.Top Combo1.Text = “” Combo2.Text = “” Combo1.ListIndex = -1 Combo2.ListIndex = -1 Command1.Left = Combo1.Left + Combo1.Width * 1.25 Command1.Top = Label1.Top Command1.Caption = “Label” 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. ProgrammersReference.pmd 277 10/28/2004, 10:00 AM Refresh End Sub Private Sub Option1_Click(Index As Integer) ‘vertical alignment If Combo1. 10:00 AM . Note that only the Left.Symbol(0). a ComboBox named Combo1 and a Map named Map1 that contains one MapLayer. Once the Map draws. paste the code into the Declarations section of a form containing two Frame controls named Frame1 and Frame2. To try this example.HorizontalAlignment = moAlignCenter .HorizontalAlignment [= value] The HorizontalAlignment property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. For each OptionButton. Once you’ve created the OptionButtons and the Frames.Symbol(0). value A value or constant that determines the horizontal alignment as described in Settings.pmd 278 10/28/2004. Right and Center AlignmentConstants are valid for HorizontalAlignment.List(Combo1.ListIndex <> -1 Then Select Case Index ProgrammersReference. set its Index to 0 in the Control Properties dialog box to create a control array of one element. See Also VerticalAlignment Property 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. cut Option1 and paste it into Frame1 and cut Option2 and paste it into Frame2.VerticalAlignment = moAlignCenter End With Map1. Settings The settings for value are AlignmentConstants. Option Explicit Dim oRenderer As MapObjects2.ListIndex) . Click the option buttons to alter the alignment properties.Field = Combo1. two OptionButton controls named Option1 and Option2.LabelRenderer Private Sub Combo1_Click() With oRenderer . Select Press F5 and choose the field in Combo1 whose values will serve as the text for the labels. you can try out the various text alignment combinations. 278 MapObjects Programmer’s Reference Syntax object. Symbol(0).Extent = Map1.Symbol(0). x _ As Single.Symbol(0).Symbol(0). 10:00 AM .pmd 279 10/28/2004.Symbol(0).VerticalAlignment = moAlignBaseline End Select Map1.VerticalAlignment = moAlignCenter Case 2 oRenderer.Symbol(0). Shift As Integer.VerticalAlignment = moAlignTop Case 1 oRenderer.HorizontalAlignment = moAlignLeft Case 1 oRenderer.Refresh End If End Sub Private Sub Option2_Click(Index As Integer) ‘horizontal alignment If Combo1.VerticalAlignment = moAlignBottom Case 3 oRenderer.ListIndex <> -1 Then Select Case Index Case 0 oRenderer.TrackRectangle Else Map1.Field iBorder = 1000 ProgrammersReference.FullExtent ‘different than the usual example End If End Sub Private Sub Form_Load() Dim I As Integer Dim iBorder As Integer Dim ofield As MapObjects2.Refresh End If End Sub Private Sub Map1_MouseDown(Button As Integer.HorizontalAlignment = moAlignCenter Case 2 oRenderer.Symbol(0).Extent = Map1.HorizontalAlignment = moAlignRight End Select Map1. y As Single) If Button = 1 Then Map1. MapObjects Programmer’s Reference 279 Case 0 oRenderer. Layers(0).1).LabelRenderer Set oRenderer = Map1.Height + 40 Option1(I). Load Option1(I) ‘ Set the location of the new option button.Left Frame2.400 Map1.Height + 300 ‘position the first option button Option1(0).Width = 1500 Frame1.Width = iBorder + Map1.Height = Map1.Left = 100 Option2(0).Left = 100 ‘position the second option button Option2(0).Width = Map1.Renderer ‘size and position the map Map1.Top + Map1.Height + iBorder ‘ setup the frames Frame1.Left = Map1.Width + iBorder Me.Top = Map1.Top + Option1(0).Caption = “Center” Option1(2).Left = iBorder .Caption = “Horizontal Alignment” Frame1. 10:00 AM .Layers(0).pmd 280 10/28/2004.Caption = “Bottom” ProgrammersReference.Top = 300 Option1(0).Renderer = New MapObjects2.Height Frame2.Top = Map1.Width + 40 Frame2.Width Frame1.Left = Map1.Top = 200 For I = 1 To 3 ‘ Create three more instances of Option1.Height + 40 Frame2.800 Map1.Top Frame1. 280 MapObjects Programmer’s Reference ‘establish the renderer for the MapLayer Set Map1.Top = iBorder .Caption = “Vertical Alignment” Frame2.Top = Option1(I .Height = iBorder + Map1.Height = Option2(0). Option1(I).Caption = “Top” Option1(1).Visible = True Next I ‘set labels for vertical options Option1(0).Width = 5000 ‘size the form Me.Height = 3800 Map1.Left + Map1. pmd 281 10/28/2004.Left Combo1.Records.Caption = “Right” ‘position and size the combo box Combo1.hWnd [= handle] The hWnd property syntax has these parts: ProgrammersReference.Top . 10:00 AM .Top = Map1.Caption = “Center” Option2(2). MapObjects Programmer’s Reference 281 Option1(3).Value = True ‘create a list of string fields For Each ofield In Map1.Layers(0).Left = Map1.Value = True Option2(1).AddItem ofield.Left = Option2(I .Width + 40 Option2(I).1).Width * 0.Name End If Next Combo1. Syntax object.Caption = “Baseline” For I = 1 To 2 ‘ Create two more instances of Option2.5 ‘intialize the Center option buttons to be the default Option1(1).Left + Option2(0).Width = Map1.Caption = “Left” Option2(1). Load Option2(I) ‘ Set the location of the new option button.Fields If ofield.Type = moString Then Combo1.40 Combo1.Visible = True Next I ‘set labels for horizontal options Option2(0).Combo1.Text = “<Choose a field name>” End Sub hWnd Property Applies To Map Object Description The hWnd property is a standard ActiveX property that returns a handle to a control.Height . Option2(I). and then press F5. 282 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list. Y As Single) dragging = True g_hwnd = Map1.hwnd g_hdc = GetDC(g_hwnd) SetROP2 g_hdc.pmd 282 10/28/2004. vbPixels) ys = ScaleY(Y. _ ByVal nDrawMode As Long) As Long Private Const R2_NOTXORPEN = 10 Private Const R2_NOT = 6 Dim g_hdc As Long Dim g_hwnd As Long Dim dragging As Boolean Dim xs As Integer. ys As Integer Private Sub Form_Load() dragging = False End Sub Private Sub Map1_MouseDown(Button As Integer. Shift As Integer. vbPixels) ProgrammersReference. vbTwips. _ ByVal hDC As Long) As Long Private Declare Function SetROP2 Lib “gdi32” (ByVal hDC As Long. Option Explicit Private Declare Function Rectangle Lib “gdi32” (ByVal hDC As Long. click and drag the Rectangle over the Map. vbTwips. 10:00 AM . See Also Map Object Example This example uses the hWnd property to draw a rectangle on a Map using Windows API calls. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. ByVal X2 As Long. _ ByVal X1 As Long. Once the Map displays. Remarks For more information about the hWnd property. ByVal Y1 As Long. To try this example. X As _ Single. R2_NOTXORPEN xs = ScaleX(X. ByVal Y2 As _ Long) As Long Private Declare Function GetDC Lib “user32” (ByVal hwnd As Long) As _ Long Private Declare Function ReleaseDC Lib “user32” (ByVal hwnd As Long. set the Visual Basic online reference. handle A value of Long data type specifying the Windows API handle of the object. MapObjects Programmer’s Reference 283 Rectangle g_hdc. ys . xs + 10. xs . xs + 10. Use the Layers property of a Map object to retrieve its Layers collection.10.10. ys + 10 End Sub Private Sub Map1_MouseMove(Button As Integer. Each ImageLayer object’s File property represents the name of the file on disk. You can create ImageLayer objects in Visual Basic with code like this: Dim ilyr as New MapObjects2.ImageLayer Properties Extent Tag UpdateWhileDrawing ProgrammersReference.10. Using the Valid property. X As _ Single. Shift As Integer. ys + 10 xs = ScaleX(X. The Layers collection includes a MapLayer or an ImageLayer object for each layer defined for a map. xs + 10.10. 10:00 AM . ys + 10 End If End Sub Private Sub Map1_MouseUp(Button As Integer. vbTwips. ys .10. g_hdc dragging = False End Sub ImageLayer Object An ImageLayer represents a layer that is based on geo-referenced raster data stored in an image file. Y As Single) Rectangle g_hdc. ys .pmd 283 10/28/2004. Shift As Integer. ys . vbTwips. ys + 10 ReleaseDC g_hwnd. xs .10. xs . you can determine whether a layer is valid before adding it to the collection. vbPixels) ys = ScaleY(Y. X As _ Single. see the individual image format descrip- tions in the online help. xs . To find out which image files should have a world file. You can access members of the Layers collection either by numeric index or by the Name of the ImageLayer. vbPixels) Rectangle g_hdc.10. Y As Single) If dragging Then Rectangle g_hdc. xs + 10. 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.10. then press F5. Remarks The current index is the internal index of the GeoEvent. To try this example. oBotRight As MapObjects2. GeoEvents can be added at a specified Index.GeoEvent Private Sub Form_Load() Dim oFont As New StdFont Dim oTopLeft As MapObjects2.Point ProgrammersReference. Option Explicit ‘ Global list of TrackingLayer events Private moEventList() As MapObjects2. a ListBox named List1.Point Dim fXSpace As Double. If the referenced event’s Index value is -1. Note that MapObjects reassigns a new index value to remaining events automatically. Syntax object. TrackingLayer Object Index Property Applies To GeoEvent Object Description Returns the current Index of the GeoEvent. fYSpace As Double Dim i As Integer Dim oEventPoint As New MapObjects2. and a Label named Label1. MapLayer Object. The index represents the GeoEvent object’s current position in the collection of events on the TrackingLayer. See Also TrackingLayer Object Example This example uses the Index property to reference a GeoEvent on the TrackingLayer. it means the event has been removed.pmd 284 10/28/2004. 284 MapObjects Programmer’s Reference File Transparent Valid LayerName TransparentColor Visible See Also Map Object. Remove events by clicking the event in the list box.Index The Index property syntax has these parts: Part Description object An object expression that evaluates to a GeoEvent object. MapObjects renumbers the Index of all subsequent events if your application removes an event. 10:00 AM .Point. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. Color = moBlue .Show ‘ Use ESRI font oFont.SymbolCount = 4 For i = 0 To 3 With Map1.x = oTopLeft.Map1.Map1.AddEvent oEventPoint.oTopLeft.y = oTopLeft.Size = 36 .y + (i + 1) * fYSpace . Map1.Left.TrackingLayer With . i ‘ Add event to global list ReDim Preserve moEventList(i) Set moEventList(i) = .pmd 285 10/28/2004.Style = moTrueTypeMarker . _ Height .TrackingLayer. 0) Set oBotRight = Map1.Symbol(i) .oTopLeft.ToMapPoint(0.Top) fXSpace = (oBotRight.CharacterIndex = 74 + i End With ‘ Create the event and place it on the Map oEventPoint.Width . MapObjects Programmer’s Reference 285 ‘ The map must be displayed in order ‘ for ToMapMoint to work correctly Me.Name = “ESRI Environmental & Icons” ‘ Figure out event spacing Set oTopLeft = Map1.Caption = “Click event in list box to remove it (-1 = _ ProgrammersReference. 10:00 AM .y .ToMapPoint(Map1.x) 5 fYSpace = (oBotRight.Event(i) End With Next ListEvents Label1.x + (i + 1) * fXSpace oEventPoint.Font = oFont .y) 5 ‘ Add events Map1.x . List(i) = “gEventList(“ & i & “). vbExclamation.”. Return Values The Indexed property return values are: ProgrammersReference. 286 MapObjects Programmer’s Reference removed)” End Sub Private Sub List1_Click() Dim iEvent As Integer iEvent = moEventList(List1.Indexed The object placeholder is an object expression that evaluates to an object in the Applies To list. Syntax object. 10:00 AM .Index Next End Sub Indexed Property Applies To PlaceLocator Object Description Returns a value that indicates whether an index exists for an object. _ “Remove Event” End If End Sub Sub ListEvents() Dim i As Integer List1.RemoveEvent iEvent ListEvents Else MsgBox “This event has already been removed.ListIndex).Index = “ & _ moEventList(i).pmd 286 10/28/2004.Index If iEvent > -1 Then Map1.TrackingLayer.Clear For i = 0 To UBound(moEventList) List1. If the object is a PlaceLocator object. When a MapLayer is drawn using an EventRenderer. by default no indexing of events in the MapLayer takes place. This index is created only once. you can create an index of the events in your MapLayer before drawing takes place. See Also StreetTable Property. Remarks The default setting of the boolean value is False. However. For large datasets this process may take some time. False An index does not exist for the object.IndexEvents [= boolean] The IndexEvents property syntax has these parts: Part Description object An object expression that evaluates to a EventRenderer. MapObjects Programmer’s Reference 287 Value Description True An index exists for the object. BuildIndex Method Example See Geocoder Object 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. and therefore slow down the drawing of a MapLayer with an EventRenderer. the index is a spatial index. which will speed up the drawing time. PlaceNameTable Property. 10:00 AM . you should create an EventRenderer and set it’s IndexEvents property to True. the index is a searchable index for string searching index. an index is created on the events in the EventTable. not each time the MapLayer is drawn. Remarks In the object is a MapLayer object.pmd 287 10/28/2004. If you wish to index all of the events in your MapLayer prior to it’s display. The same index is therefore used every time your MapLayer is drawn with the EventRenderer. boolean A boolean expression specifying whether or not an index is created on the events in a MapLayer when an EventRenderer is assigned to it. and then assign the ProgrammersReference. Syntax object. This example uses the Highways sample shapefile.DATABASE= _ C:\Program Files\ESRI\MapObject2\Samples\Data\Events” accTbl. See Also IndexExtent Property. or partially within. you can also set the IndexExtent property. If you set the IndexEvents property to true when the EventRenderer is already assigned to a MapLayer. InvalidateIndex Method Example This example demonstrates indexing of events when displaying a MapLayer with an EventRenderer. In this case. which will increase the speed of the indexing operation. As more features are displayed.DataConnection Dim ptRend As New MapObjects2. only events on features within that extent will be indexed. You can use the InvalidateIndex method to refresh the index on any particular route. and more events will be indexed as you pan. which is used later on when your MapLayer is drawn. events will be indexed at draw time as features are drawn. Only features lying within.database = “dBASE IV. If your EventTable is a dataset shared between many users. Option Explicit Dim dc As New MapObjects2. Therefore if the user is zoomed in on a MapLayer when IndexEvents is set to True. Press F5. 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.MapLayer Private Sub setupEventRenderer() ‘Now set up the EventRenderers Screen. Only the events within the Map Extent are indexed. 10:00 AM . If you only wish to display a small area of the whole MapLayer. alter the path to this folder if required. and the MapLayer will display with an EventRenderer displaying the point events contained in the Accidents dbf file. the specified Extent are indexed. the events contained in the dataset may change periodically. Click the ‘pavements’ option and the MapLayer is displayed with an EventRenderer showing the line events contained in the pavements dbf file. 288 MapObjects Programmer’s Reference EventRenderer to a MapLayer.Table accTbl. events on those features which become visible will also be indexed.EventRenderer Dim lyr As New MapObjects2. and a Command Button named Command1. An index of events is created at this point.EventRenderer Dim lnRend As New MapObjects2.Name = “Accident” ProgrammersReference.pmd 288 10/28/2004.MousePointer = vbHourglass Dim accTbl As New MapObjects2. for example if the user pans across the MapLayer. for example when you Refresh your Map. the index MapObjects created on the events assigned to the MapLayer will be outdated. Also add two OptionButtons named Option1 and Option2. Right-Click to pan about the map. Table paveTbl.EventRouteIDField = “RKEY” .Style = moCircleMarker .DrawBackground = True .Symbol(1).pmd 289 10/28/2004.EventTable = accTbl .Symbol(0).IndexEvents = True .StartMeasureField = “MILE” End With Dim paveTbl As New MapObjects2. 10:00 AM .Symbol(1).StartMeasureField = “MILE” .Color = moPurple .SymbolType = moPointSymbol .SymbolType = moPointSymbol .UseDefault = True .DefaultSymbol.FeatureRouteIDField = “rkey” .Color = moYellow .EndMeasureField = “tmp” .Value(0) = “L” .Style = moSolidLine .FeatureRouteIDField = “RKEY” .StartMeasureField = “fmp” . MapObjects Programmer’s Reference 289 With ptRend .EventRouteIDField = “rkey” .Size = 2 .Symbol(0).Value(1) = “M” .Symbol(1).ValueCount = 3 .DefaultSymbol.Size = 2 .Size = 4 .Symbol(0).EventTable = paveTbl .DefaultSymbol.Color = moGreen .DefaultSymbol.IndexEvents = True .Value(2) = “N” ProgrammersReference.database = “dBASE IV.SymbolType = moLineSymbol .SymbolField = “rideq” .Style = moSolidLine .Name = “Pavement” With lnRend .DrawBackground = True .DATABASE=C:\ _ Program Files\ESRI\MapObjects2\Samples\Data\Events” paveTbl. Symbol(2).Symbol. 290 MapObjects Programmer’s Reference .MousePointer = vbDefault End Sub Private Sub Form_Load() dc.54782958 ext.Style = moSolidLine .ScrollBars = False Dim ext As New MapObjects2.Left = 1654104.Connect Then End Set lyr.Right = 1665961.MousePointer = vbHourglass lyr.Refresh Screen.Bottom = 1534984.Symbol(2).FindGeoDataset(“Highway”) If lyr.Valid Then Map1.Color = moRed lyr.03468352 ext.Size = 3 Option1.Rectangle ext.MousePointer = vbHourglass lyr.Color = moBlue End With Screen.MousePointer = vbDefault End Sub Private Sub Option1_Click() Screen.GeoDataset = dc.MousePointer = vbDefault End Sub Private Sub Option2_Click() Screen.37821543 Set Map1.Value = 1 Option2.Refresh Screen. 10:00 AM .Symbol(2).Caption = “Render accidents” Option2.Layers.Caption = “Render pavements” Option1.pmd 290 10/28/2004.92190812 ext.Renderer = lnRend Map1.Size = 2 .Add lyr lyr.database = “C:\Program Files\ESRI\MapObjects2 _ Samples\Data\Events” If Not dc.Value = 0 Map1.Extent = ext ProgrammersReference.Symbol.Renderer = ptRend Map1.Top = 1544924. events on those features which become visible will also be indexed.IndexEvents [= rect] The IndexEvents property syntax has these parts: Part Description object An object expression that evaluates to a EventRenderer. which will increase the speed of the indexing operation. ProgrammersReference.Pan End If 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 EventRenderer’s EventTable should be indexed. this may slow down the drawing of the Map. Remarks If you only wish to display a small area of a MapLayer. specifying the extent which contains the features for which events should be indexed. X As _ Single. rect An object expression that evaluates to a Rectangle object. As more features are displayed. Syntax object. If you set the IndexEvents property to true when the EventRenderer is already assigned to a MapLayer. If there are a considerable amount of new events to be indexed. events will be indexed at draw time as features are drawn. only events on features within that extent will be indexed. or partially within.Extent = Map1. the specified Extent are indexed. Shift As Integer. MapObjects Programmer’s Reference 291 setupEventRenderer End Sub Private Sub Map1_MouseDown(Button As Integer. 10:00 AM . Y As Single) If Button = vbLeftButton Then Map1.pmd 291 10/28/2004. you can set the IndexExtent prop- erty. Only features lying within.TrackRectangle ElseIf Button = vbRightButton Then Map1. Therefore if the user is zoomed in on a MapLayer when IndexEvents is set to True. for example if the user pans across the MapLayer. 292 MapObjects Programmer’s Reference You can use the IndexExtent property in this situation to index the whole area which the user may display. status A variable declared to be of integer data type. Description Geocoder Object Syntax object. Setting the IndexExtent property appropriately would prevent the indexing occurring at draw time while the user pans about the Map. 10:00 AM . See Also IndexEvents Property. IndexStatus [= status] The IndexStatus method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Return Values The IndexStatus method returns GeocodeSuccessConstants. ProgrammersReference. See Also Geocoder Object. Constant Value Description mgIndexNonexistant 0 The index does not exist. IndexStatus Method IndexStatus Method Applies To Returns an IndexStatusConstant indicating the current status of the index associated with the Geocoder Object. mgIndexExists 3 The index exists and is usable. InvalidateIndex Method Example See IndexEvents Property IndexStatus Constants MapObjects defines the following constants for use with the Geocoder object’s IndexStatus method. mgIndexUnreadable 2 The index is not readable. mgIndexInvalid 1 The index is invalid or corrupted.pmd 292 10/28/2004. 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. MapObjects Programmer’s Reference 293 See Also AddIndex Method.Insert( index. 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. Constant Value Description mgIndexTypeSoundex 0 Soundex hash index mgIndexTypeNormal 1 Normal (random hash) index See Also Geocoder Object. ProgrammersReference. paste the code into the Declarations section of a form containing a Map named Map1. Point An object expression that evaluates to a Point or Points object. AddIndex Method Insert Method Applies To Points Collection. Point) The Insert method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. EraseIndex Method. See Also Set Method. index An integer that represents the position of the member in the Parts or Points collection. Syntax object. and then press F5. BuildIndices Method Example See AddIndex Method IndexType Constants MapObjects defines the following constants for use with the Geocoder object’s AddIndex method. To try this example. Remove Method Example This example uses the Insert method to insert a new Point into a collection of Points. 10:00 AM .pmd 293 10/28/2004. Point Dim oPoints As New MapObjects2.Count .Parts(0).Parts(0). poly As Polygon) Dim oPoint As New MapObjects2. Shift As Integer.pmd 294 10/28/2004.Point.Item(vertex). X _ As Single.1).Points Dim i As Integer fTol = Map1.Parts(0) For i = 0 To oPoints.Y = (moPoly.Y + _ moPoly.Parts(0) If vertex = 0 Then vertex = moPoly.Parts(0). 294 MapObjects Programmer’s Reference Option Explicit Dim moPoly As MapObjects2.Insert vertex.ToMapDistance(100) Set oPoints = oPoly. 10:00 AM .Item(vertex .X + _ moPoly.2 If oPoints(i).Item(vertex).Count .Y) / 2 oPoints. oPoint End If End Sub Function SelectVertex(oPoint As MapObjects2.Parts(0).DistanceTo(oPoint) < fTol Then SelectVertex = i Exit Function End If Next SelectVertex = -1 End Function Private Sub Map1_MouseDown(Button As Integer.1 ‘ create the point to be inserted at the midpoint of the ‘ selected vertex and the previous vertex oPoint.X = (moPoly.Parts(0).Item(vertex . Y As Single) Dim iVertex As Integer ProgrammersReference.Polygon Sub InsertVertex(vertex As Integer.1).X) / 2 oPoint. oPoly As _ Polygon) As Integer Dim fTol As Double Dim oPoints As MapObjects2.Points Dim fOffset As Double If vertex >= 0 Then Set oPoints = moPoly. Color = moPaleYellow oPtSym. oSym For Each oPoint In moPoly.Point Dim oSym As New MapObjects2. Y).Bottom = 0: oRect.Symbol If Not moPoly Is Nothing Then oSym. 10:00 AM . oPtSym Next End If End Sub Private Sub Form_Load() Dim oRect As New Rectangle oRect.TrackPolygon ElseIf Not moPoly Is Nothing Then iVertex = SelectVertex(Map1.Top = 100 Map1.TrackingLayer. moPoly End If End If Map1.DrawShape moPoly.ToMapPoint(X. moPoly) If iVertex <> -1 Then InsertVertex iVertex. Rectangle Object Description Decreases the width and height of an object.SymbolType = moPointSymbol oPtSym.pmd 295 10/28/2004.Left = 0: oRect.Refresh True End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As Stdole. MapObjects Programmer’s Reference 295 If Button = 1 Then Set moPoly = Map1.Extent = oRect End Sub Inset Method Applies To Ellipse Object.Parts(0) Map1. ProgrammersReference.Right = 100: oRect.Symbol Dim oPtSym As New MapObjects2.OLE_HANDLE)_ Dim oPoint As MapObjects2.DrawShape oPoint.Color = moRed Map1. pmd 296 10/28/2004. the inset rectangle is shaded with a green fill pattern. 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.Height * 0. deltaY The Inset method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. ByVal hDC As Stdole. ByVal _ canceled As Boolean.OLE_HANDLE) Dim oSymbol As New MapObjects2. To try this example. The Map’s extent is shaded with a red fill pattern.1.Inset .1 End With With oSymbol . . Offset Method Example This example uses the Inset method to draw a Rectangle inset from the Extent of the map. 296 MapObjects Programmer’s Reference Syntax object.Width * 0.Style = moUpwardDiagonalFill ProgrammersReference. oSymbol With moRectangle . Option Explicit Dim moRectangle As MapObjects2.Symbol If Not moRectangle Is Nothing Then With oSymbol .SymbolType = moFillSymbol .Inset deltaX. 10:00 AM . deltaX A numeric expression that represents the distance in the X direction to decrease the width of the object. See Also Intersect Method. 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.Style = moDownwardDiagonalFill .Rectangle Private Sub Map1_AfterLayerDraw(ByVal index As Integer.Size = 0 End With Map1. deltaY A numeric expression that represents the distance in the Y direction to decrease the height of the object.Color = moRed .DrawShape moRectangle. pmd 297 10/28/2004.Refresh End Sub Intersect Method Applies To Point Object. MapObjects Programmer’s Reference 297 . Syntax Set resultShape = object. Will contain the resulting shape after the intersection operation. For a list of which shapes may result from an Intesect operation.Color = moGreen End With Map1. This is second of the two shape objects whose intersection is to be calculated. then use an interim Object and then test the result using its ShapeType property to see what type of object it is. object An object expression that evaluates to an object in the Applies To list. 10:00 AM . Shift As Integer. This is the first of the two shape objects whose intersection is to be calculated. Remarks If the two Shapes do not have a valid Intersect. Rectangle or Polygon).Extent Map1. oSymbol End If End Sub Private Sub Map1_MouseDown(Button As Integer. see the online help. (See Remarks). intersectShape An object expression that evaluates to an object in the Applies To list.DrawShape moRectangle.g. the resultShape will be Nothing. extent An object expression that evaluates to a Rectangle object. This Rectangle should entirely contain the object’s extent. Where the resultShape could be more than one object type (e.Intersect (intersectShape [. Polygon Object. Points Collection.extent]) The Intersect method syntax has these parts: Part Description resultShape An object expression that evaluates to a shape object. Rectangle Object. Line Object. ProgrammersReference. y As Single) Set moRectangle = Map1. Ellipse Object Description Returns a shape that represents the geometric intersection of one shape object with another shape object. x As _ Single. and is used internally. Valid Object expected as argument. If you do. You can however use a self-intersecting Line.AddEvent(interShape. an intersection of two lines may be a point. many points.Intersect(shape2. or a line If interShape.TrackingLayer. See Also Buffer Method.pmd 298 10/28/2004.GeoEvent Set shape2 = shape Set interShape = shape1.TrackingLayer. Note. Difference Method.shapeType = moShapeTypeLine Then Set interEvent = Map1. points. paste the code into the Declarations section of a form containing a Map named Map1 that has at least one MapLayer. or a line. Map1. 298 MapObjects Programmer’s Reference You cannot use the Intersect method with a self-intersecting Polygon. XOr Method Example This example uses the Intersect method to allow the user to perform intersect operations lines. To try this example.AddEvent(interShape.shapeType = (moShapeTypePoint Or _ moShapeTypeMultipoint) Then Set interEvent = Map1. Option Explicit Dim shape1 As Object Dim shape2 As Object Dim inter As Boolean Private Sub doIntersect(shape As Object) If Not inter Then Set shape1 = shape inter = True ElseIf inter Then Dim interShape As Object ‘MapObjects2. 3) End If End If Set shape1 = Nothing inter = False ProgrammersReference. The line and the new shape generated by the Intersect operation are added to the tracking layer as GeoEvents. 10:00 AM .FullExtent) If Not interShape Is Nothing Then ‘Result could be a point. Care must be taken to add events to the tracking layer using the appropriate symbol for the resultant shape type. and then click on the map to track two lines. Union Method. an exception is raised in Visual Basic. 2) ElseIf interShape. specifying Error 5000. which is checked here by reading the ShapeType property of the returned shape. press F5.line Dim interEvent As New MapObjects2. SymbolType = moLineSymbol . 10:00 AM .TrackingLayer.SymbolType = moPointSymbol .Style = moDashLine .Size = 4 End With With Map1.Size = 3 End With End Sub ProgrammersReference.AddEvent(line.Color = moRed .Style = moTriangleMarker .TrackingLayer.Size = 3 End With With Map1.Rectangle Set r = Map1.Symbol(2) .Color = moBlue .SymbolCount = 4 With Map1.TrackingLayer. x As _ Single.SymbolType = moLineSymbol .Extent = r Exit Sub ElseIf Button = 1 Then ‘Line intersect Dim line As New MapObjects2.TrackRectangle Map1.pmd 299 10/28/2004.Color = moRed .Symbol(1) .TrackingLayer. Shift As Integer.TrackLine Set eventLine = Map1.GeoEvent Set line = Map1.Symbol(3) . MapObjects Programmer’s Reference 299 End If End Sub Private Sub Map1_MouseDown(Button As Integer.TrackingLayer.line Dim eventLine As New MapObjects2. 1) Call doIntersect(line) End If End Sub Private Sub Form_Load() inter = False Map1.Style = moSolidLine . y As Single) If Button = 2 Then Dim r As New MapObjects2. rule filename A string expression that specifies the path of the Intersection Match rule file name. IntersectionMatchVariableCount Property. Syntax object.pmd 300 10/28/2004. See Also MatchRule Property. Index must be a number from 0 to a number that is one less than the ProgrammersReference. 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.IntersectionMatchRules [= rule filename] The IntersectionMatchRules property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. index A numeric expression that specifies the relative position of a member of the group of IntersectionMatchVariable names associated with the Geocoder object. Syntax object.IntersectionMatchVariable (index) [=intName] The IntersectionMatchVariable property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 300 MapObjects Programmer’s Reference IntersectionMatchRules Property Applies To Geocoder Object Description Returns or sets the intersection match rule file name associated with the Geocoder object. MatchVariableIntersectionLink Property Example See MatchRules Property 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. 10:00 AM . IntersectionMatchVariableCount [=count] The IntersectionMatchVariableCount property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. ProgrammersReference. MapObjects Programmer’s Reference 301 value of the Geocoder object’s IntersectionMatchVariableCount prop- erty. intName An object declared as a string data type that evaluates to the returned variable name. MatchVariableIntersectionLink Property Example See MatchRules 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. 10:00 AM . MatchVariableIntersectionLink Property Example See MatchRules Property IntersectionStandardizingRules Property Applies To Standardizer Object Description Returns or sets the intersection standardization rule command file associated with the Standardizer object. See Also MatchVariable Property.mat file specified in the IntersectionMatchRules property. IntersectionMatchVariableCount Property. The intersection match variables are defined in the . IntersectionMatchVariable Property. Syntax object. IntersectionMatchRules Property.pmd 301 10/28/2004. count A variable declared to be of integer data type. Remarks Use this property to return details of the intersection match variables which have been set on a Geocoder object. See Also IntersectionMatchRules Property. StandardizeAddress Method Example See Standardizer Object Intersects Method Applies To Rectangle Object Description Returns a value that indicates whether a Rectangle object intersects another Rectangle. you should avoid using an ‘&‘ in an address string if it is not an intersection. rule filename A string expression that specifies the Intersection Standardization rule command file path and name.IntersectionStandardizingRules [= rule filename] The IntersectionStandardizingRules property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 302 10/28/2004.. street intersection addresses. For this reason. Remarks An intersection is delimited by using an address string containing the symbol ‘&’. ProgrammersReference.stn Standardizes U. 302 MapObjects Programmer’s Reference Syntax object. the Standardizer will check if the address string contains an ampersand symbol (‘&‘). You can find the following Intersection Standardization rule command file in the Georules folder: Intersection Standardization RuleCommand File Name/Description us_intsc. 10:00 AM . It will automatically apply the appropriate standardization rule and return the standardized FieldValues. e. See Also StandardizingRules Property.Intersects rectangle The Intersects method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. ‘N Main St & First Ave’. If a Standardizer object is has both StandardizationRules and IntersectionStandardizationRules properties set.S. MapObjects provides standardizing rule files for street intersection addresses.g. Syntax object. 10:00 AM .Extent = OrigExtent End If End Sub Private Sub Form_Load() Dim Rect As MapObjects2. See Also Buffer Method. the extent reverts to the original extent.Rectangle Dim deltaX.Height * 0.Extent = Rect Else Map1. Press F5 and then click Command1. Intersect Method. deltaY As Double Set Rect = Map1. Option Explicit Dim OrigExtent As MapObjects2. If it does.pmd 303 10/28/2004. False The rectangles do not intersect.Rectangle Set Rect = Map1.1 Rect.1 deltaY = Map1. deltaY ‘offset the extent If OrigExtent.Extent.Width * 0.ScaleRectangle (0. 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. the code uses the rectangle to pan the map. Union Method.Extent. Difference Method.Rectangle Private Sub Command1_Click() Dim Rect As MapObjects2. GetCrossings Method.Offset deltaX.75) ProgrammersReference. otherwise. MapObjects Programmer’s Reference 303 rectangle An object expression that evaluates to a Rectangle object.Extent Rect. Return Values The Intersects method returns these values: Value Description True The rectangles intersect.Intersects(Rect) Then Map1. 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.Extent deltaX = Map1. In this case. You can use the InvalidateIndex method to refresh the index on any particular route. from the EventRenderer’s EventTable. the events contained in the dataset may change periodically. See Also IndexExtent Property.pmd 304 10/28/2004. Syntax object. InvalidateIndex Method Example See IndexEvents Property IsCustom Property Applies To Projection Object Description Returns a value that indicates whether a Projection object has been user-defined. boolean A string evaluating to the RouteID of the feature for which the events index should be refreshed.Extent End Sub InvalidateIndex Method Applies To EventRenderer Object Description Causes the index of events on a particular RouteID to be refreshed. 10:00 AM . Syntax object. Remarks If your EventTable is a dataset shared between many users. and a new index of events for that RouteID will be created from the current EventTable. The index of events currently stored for that RouteID will be removed.IsCustom [= custom] The IsCustom property syntax has these parts: ProgrammersReference.InvalidateIndex (RouteIDKey) The InvalidateIndex method syntax has these parts: Part Description object An object expression that evaluates to a EventRenderer.Extent = Rect Set OrigExtent = Map1. using the Custom property. 304 MapObjects Programmer’s Reference Map1. the index MapObjects created on the events assigned to the MapLayer will be outdated. a Command Button named Command1. a Combo Box named Combo1.ProjCoordSys Dim newProj As New MapObjects2. Return Values The IsCustom property returns these values: Value Description True The projection is user-customized. paste the code into the Declarations section of a form which has a Label named Label1. and click the CommandButton to set this projection as a property of the MapLayer’s CoordinateSystem. see Return Values.Type = Map1.Layers(0). Type Property Example This example demonstrates the use of the IsCustom property of the Projection object. See Also Custom Property. 10:00 AM . Option Explicit Private Sub Command1_Click() Dim PCS As New MapObjects2.Layers(0). False The projection is one of the ProjectionConstants.Projection newProj.CoordinateSystem = PCS End Sub Private Sub Form_Load() Dim proj As New MapObjects2.pmd 305 10/28/2004.Type PCS. and Map named Map1 containing one MapLayer which has a ProjCoordSys set. and also demonstrates the setting of a new Projection object as a property of a ProjCoordSys object.ListIndex)) PCS.Strings Dim item As Variant ProgrammersReference.CoordinateSystem.Projection = newProj Map1.Type = stripProj(Combo1. Now select a new projection type from the ComboBox. To try this example. Then press F5. MapObjects Programmer’s Reference 305 Part Description object An object expression that evaluates to an object in the Applies To list. The IsCustom property is read to determine if the existing projection set on the MapLayer is a Custom one.List(Combo1. custom An boolean expression that indicates if a projection is custom or not. Layers(0).IsFullyMeasured [= boolean] The IsFullyMeasured property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.AddItem “<Select new projection>”.AddItem item Next item Combo1.PopulateWithProjections For Each item In proj Combo1.openB .Caption = “Set Projection” If Map1. 306 MapObjects Programmer’s Reference Combo1. Syntax object. boolean A boolean indicating if the object is fully measured. See Return Values Return Values The IsFullyMeasured property return values are: ProgrammersReference.CoordinateSystem. “[“) stripProj = Left(Right(theProjection.Caption = “Custom Projection Object” Else Label1.Caption = “Pre-Defined Projection Object” End If End Sub Function stripProj(theProjection As String) As Variant ‘Get position of open bracket Dim openB As Integer openB = InStr(theProjection. 10:00 AM .pmd 306 10/28/2004. _ Len(theProjection) .1) End Function IsFullyMeasured Property Applies To Line Object Description Returns a value indicating whether all vertices of a Line object have a non-null measure value.IsCustom Then Label1. 1 Combo1.openB).ListIndex = 1 Command1.Projection. Len(theProjection) .Clear proj. Refresh End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer.Symbol Private Sub Command1_Click() Map1. a CommandButton named Command1. and Map named Map1 with a MapLayer containing line features.Recordset Set recs = Map1.EOF Dim gLine As New MapObjects2. copy the code into the Declarations section of a form that contains a CheckBox named Check1. Press F5 and click on a line.Line Set gLine = recs(“Shape”).Records recs.DrawShape gLine. Fully measured lines will be drawn with a solid blue line.UpdateMeasures End If If gLine.Symbol Public symIsNot As New MapObjects2.MoveFirst While Not recs. symIsNot End If recs. 10:00 AM .pmd 307 10/28/2004. whereas lines not fully measured will be drawn with a red dotted line.DrawShape gLine.Value If (Check1.OLE_HANDLE) Dim recs As New MapObjects2. some of which are fully mea- sured.IsFullyMeasured) Then gLine. False Not all vertices of the Line have a Measure value set. To try this example. symIs Else Map1. Option Explicit Public symIs As New MapObjects2.Value) And (Not gLine.IsFullyMeasured Then Map1. See Also Point Object. MapObjects Programmer’s Reference 307 Value Description True All vertices of the Line have a Measure value set against them. The UpdateMeasures method can also be applied if lines in the Recordset are not already fully measured.Layers(0). ByVal _ canceled As Boolean.MoveNext Wend ProgrammersReference. ByVal hDC As stdole. Measure Property Example This example makes use of the IsFullyMeasured property to draw lines on a map with appro- priate symbols. SearchShape Method ProgrammersReference.Color = moBlue . point An object expression that evaluates to a Point object Return Values The IsPointIn method returns these values: Value Description True The point is located within the boundary of object.Caption = “Refresh Map” With symIs .IsPointIn point The IsPointIn method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. See Also Intersects Method. 308 MapObjects Programmer’s Reference End Sub Private Sub Form_Load() Check1.SymbolType = moLineSymbol . False The point is located outside the boundary of object.Style = moDotLine .Color = moRed . Polygon Object.Caption = “Update Measures” Command1.Size = 2 End With With symIsNot .Size = 2 End With End Sub IsPointIn Method Applies To Ellipse Object.Style = moSolidLine . 10:00 AM . Syntax object.SymbolType = moLineSymbol . Rectangle Object Description Returns a value that indicates whether a Point falls within an object.pmd 308 10/28/2004. Title:=”Identify” Exit Do End If oRecset. 10:00 AM .ToMapPoint(x.Extent = oRectangle Case vbRightButton Set oPoint = Map1.IsPointIn(oPoint) Then ‘change field name in next line to reflect your data MsgBox prompt:=oRecset(“state_name”). Press F5 and click the button. To try this example.Fields(“shape”).pmd 309 10/28/2004.MoveNext Loop Case Else ‘ Don’t respond End Select End Sub ProgrammersReference.Value If oShape. MapObjects Programmer’s Reference 309 Example This example uses the IsPointIn method to identify features on a map.Layers(0).EOF Set oShape = oRecset. y) Set oRecset = Map1.5) Map1.Point Dim oRecset As MapObjects2.ScaleRectangle (0. clicking with the right mouse button identifies the feature. Shift As Integer. You may want to change the name of the field from “State_Name” to the name of a field appropriate to your data.Recordset Dim oShape As MapObjects2. Clicking the map with the left mouse button zooms in.Polygon Select Case Button Case vbLeftButton Set oRectangle = Map1. x As _ Single. y As Single) Dim oRectangle As MapObjects2. paste the code into the Declarations section of a form containing a Map named Map1 that contains one MapLayer with polygon features.Records Do While Not oRecset.Extent oRectangle. Option Explicit Private Sub Map1_MouseDown(Button As Integer.Rectangle Dim oPoint As MapObjects2. Points Collection.Item( index) The Item method syntax has the following object qualifier and part: Part Description object Required. ProgrammersReference. and is therefore of type ProjCoordSys. Return Values The IsProjected property returns these values: Value Description True The coordinate system is projected.IsProjected The IsProjected property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 310 MapObjects Programmer’s Reference IsProjected Property Applies To GeoCoordSys Object. Parts Collection. and is therefore of type GeoCoordSys.pmd 310 10/28/2004. False The coordinate system is not projected. GeoDatasets Collection Description Returns a specific member of a collection. Strings Collection. See Also Projection Object Example See IsCustom Property Item Method Applies To Layers Collection. ProjCoordSys Object Description Returns a value that indicates whether a coordinate system is projected. 10:00 AM . Fields Collection. Syntax object. by position. An object expression that evaluates to an object in the Applies To list. Syntax object. This property can be used to distinguish an object of type GeoCoordSys from one of type ProjCoordSys. Press F5. Index must be a number from 0 to a number that is one less than the value of the collection’s Count property or a valid name. an error occurs.Layers Dim iLayer As Integer ProgrammersReference. Option Explicit Private Sub Form_Load() Dim oLayers As MapObjects2.Extent = Map1. The Item method is the default method for most MapObjects collections. To try this example. Remarks In the case of the following objects. 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. assuming “roads” is the first layer: Map1. 10:00 AM .Extent Note that you can refer to a layer by name as well as by index. Item returns a reference to the member of the collection: GeoDatasets.Extent Map1.Layers(0). Layers. MapObjects Programmer’s Reference 311 index Required. The following table summarizes which objects you can access by numeric expression and which you can access by string expression: numeric access string access GeoDatasets Fields Layers Layers Parts Points Strings See Also Count Property Example This example uses the Item method to iterate through the Layers collection of a Map to list each layer’s name.Layers(“roads”). If the value provided as index does not match any existing member of the collection. the following lines of code are equivalent. Therefore.Item(0). and Parts.Layers.Extent Map1. A numeric expression that specifies the position or string expres- sion that specifies the name of a member of the collection. All lines return the extent of the first layer in the map.pmd 311 10/28/2004. The string matching for the name is not case-sensitive.Extent = Map1.Extent = Map1. pmd 312 10/28/2004. 312 MapObjects Programmer’s Reference List1.Item(iLayer). Syntax Private Sub object_KeyDown(keyCode As Integer. shift As Integer) The KeyDown event syntax has these parts: Part Description object An object expression that evaluates to a Map control. and may have the following values Constant Value Description vbShiftMask 1 The SHIFT key is pressed vbCtrlMask 2 The CTRL key is pressed vbAltMask 4 The ALT key is pressed The value of keyCode evaluates to a keycode constant. MouseDown Event ProgrammersReference. LostFocus Event.AddItem oLayers. see the Visual Basic online refer- ence. KeyPress Event. keyCode An integer specifying a key code corresponding to the Key which was pressed. which occurs when the user clicks on the map.Count . The KeyPress event occurs after the KeyDown event. as described in Values.name Next End Sub KeyDown Event Applies To Map Object Description The KeyDown event is a standard ActiveX control event. For a list of keycode constants.Clear Set oLayers = Map1. shift An integer specifying the status of the Shift key.1 List1. MouseMove Event. DblClick Event. 10:00 AM . KeyDown Event.Layers For iLayer = 0 To oLayers. See Also Click Event. Values The value of shift evaluates to a Visual Basic constant. by drawing a string text on each feature in a MapLayer. Remarks For more information about the KeyPress event. you should specify which value in the ValueField corresponds to which Symbol in the symbol array by setting the value array. A LabelPlacer gives the option of using a range of TextSymbols to display label text. An integer that returns a standard numeric ANSI keycode. For example. MouseDown Event LabelPlacer Object A LabelPlacer is an object that symbolizes features. In addition. Syntax Private Sub object_KeyPress(keyAscii As Integer) The KeyPress event syntax has these parts: Part Description object An object expression that evaluates to a Map control. You should then set a TextSymbol for each Symbol in the symbol array. The ValueField property specifies which Field in the MapLayer’s Recordset contains a value indicating which TextSymbol from the Symbol array is used to draw the labels. as de- scribed in Values. keyAscii An integer corresponding to a standard numeric ASCII keycode. which occurs when the user clicks on the map. KeyDown Event. DblClick Event.pmd 313 10/28/2004. 10:00 AM . see the Visual Basic online reference).g: ProgrammersReference. using the Symbol. KeyPress Event. MapObjects Programmer’s Reference 313 KeyPress Event Applies To Map Object Description The KeyPress event is a standard ActiveX control event. LostFocus Event. MouseMove Event. Value. you should set the first Value in the value array to equal ‘Road’. if you wish to label features with a value of ‘Road’ in the SymbolField with the first Symbol in the symbol array (Symbol(0)). The KeyPress event occurs after the KeyDown event. The text strings which are used to symbolize each feature are stored in a Field in the MapLayer’s Recordset. ValueCount and ValueField properties. e. By setting the ValueCount property you can determine how many values of its ValueField property the LabelPlacer will provide a Symbol for. See Also Click Event. The Field property specifies which Field should be used for the label text. A LabelPlacer is a creatable object in MapObjects. PlaceOn. paste the code into the Declarations section of a form that contains a CommandButton named Command1. 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. two CheckBox controls named Check1 and Check2. Dim placer as New MapObjects2.LabelPlacer See Also ChartRenderer Object. You can click- drag to zoom in or use the right-mouse button to pan. you can determine the position of the label relative to the feature with which it is associated. and a Map control named Map1 that contains a MapLayer with line features. ClassBreaksRenderer Object. DotDensityRenderer Object. Use SymbolHeight and SymbolWidth to establish the space occupied by a Point feature’s Symbol so the label does not conflict with the Symbol . To try this example. LabelRenderer Object. and PlaceBelow properties. You can determine whether or not to mask the labels by setting MaskLabels property. for example. You can control whether or not to draw the features in the MapLayer 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. or for which a corresponding Value is not set. In addition. you set the color of the mask with MaskColor. ProgrammersReference. The example assumes the MapLayer is based on the Redlands shapefile in the sample data. 10:00 AM . 314 MapObjects Programmer’s Reference 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. in addition you can specify a BackgroundRenderer property to determine how those features are displayed . Press F5. ValueMapRenderer Object Properties AllowDuplicates MaskLabels SymbolWidth BackgroundRenderer PlaceAbove UseDefault DefaultSymbol PlaceBelow Value DrawBackground PlaceOn ValueCount Field Symbol ValueField MaskColor SymbolHeight Example This example uses the properties and methods of the LabelPlacer to render a street network.pmd 314 10/28/2004. By setting the PlaceAbove. Value = vbChecked Then LabelPlacer.Refresh End Sub Private Sub Check2_Click() If Check1.0285801368372 r.Symbol. 10:00 AM .047951088234 r.DrawBackground = True ElseIf Check2.Extent = r ‘ default color for the layer Map1.Caption = “Full Extent” ‘ set an initial extent Dim r As New Rectangle r.75 Set Map1.Left = -117.pmd 315 10/28/2004.Color = moNavy ‘ create a font to be used by the LabelPlacer Dim fnt As New StdFont ProgrammersReference.Caption = “DrawBackground” Command1.ScaleRectangle 0.Value = vbUnchecked Then LabelPlacer.AllowDuplicates = True ElseIf Check1. MapObjects Programmer’s Reference 315 Option Explicit Dim LabelPlacer As New MapObjects2.Bottom = 34.Top = 34.183964079772 r.Refresh End Sub Private Sub Command1_Click() Map1.FullExtent End Sub Private Sub Form_Load() Check1.Right = -117.Extent = Map1.Value = vbChecked Then LabelPlacer.LabelPlacer Private Sub Check1_Click() If Check1.DrawBackground = False End If Map1.Value = vbUnchecked Then LabelPlacer.Caption = “Allow Duplicates” Check2.AllowDuplicates = False End If Map1.160018438746 r.Layers(0). MaskLabels = True LabelPlacer.TrackRectangle Else Map1. Shift As Integer.pmd 316 10/28/2004. 316 MapObjects Programmer’s Reference fnt.Font = fnt LabelPlacer. The Field property is the name of the Field in the Recordset that stores the text ProgrammersReference.DrawBackground = True ‘ default symbol LabelPlacer.Bold = True Set LabelPlacer.Height / 150 Set LabelPlacer. 10:00 AM . y As Single) If Button = 1 Then Map1.FullExtent.Pan End If End Sub LabelRenderer Object A LabelRenderer is an object that represents a way of symbolizing features by drawing text on a feature.Extent = Map1.MaskColor = Map1.ValueField = “CFCC” LabelPlacer.Value = vbUnchecked ‘AllowDuplicates control ‘ add a specific value for major roads LabelPlacer.Field = “NAME” Check2.Name = “Times” fnt.FullExtent.BackColor End Sub Private Sub Map1_MouseDown(Button As Integer. x As _ Single.Layers(0).DefaultSymbol.AllowDuplicates = False Check1.Renderer = LabelPlacer LabelPlacer.DefaultSymbol.Symbol(0).Height = Map1.Symbol(0).Value(0) = “A31” fnt.Bold = False Set Map1.Height / 100 ‘ mask the labels LabelPlacer.ValueCount = 1 LabelPlacer.Value = Checked ‘DrawBackground control LabelPlacer.Height = Map1.Font = fnt LabelPlacer. for example $OFFSETY should be referenced as OFFSETY. 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. MapObjects Programmer’s Reference 317 values to use as labels. labels display on the Map. You can set the Field that specifies the height in map units of each label with the HeightField. Developers familiar with ARC/INFO annotation feature classes will recognize that many of these properties map well onto the pseudo items associated with annotation. Since splined text follows the order of Points of a Line. A LabelRenderer is a creatable object in MapObjects. The Symbol property returns the TextSymbol that you use to draw the text. If you base the MapLayer you’re working with on an ARC/INFO coverage.LabelRenderer RemarksThe LabelRenderer by default places labels at the centroid of the feature which is labeled. See Also ChartRenderer Object.Layers(0).Renderer = New MapObjects2. You can toggle several properties to control the appearance of the renderer. In addition to its Field 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 control which levels the LabelRenderer will draw. you may need to set the Flip property to True in order to enhance the appearance of splined text. you can control whether or not to draw duplicate labels on the MapLayer with the AllowDuplicates property. you can assign a level value to each label in the Field specified by the LevelField property. You can set the rotation angle of each label by specifying a RotationField that contains the angle to rotate each label. you can set a property and refer to the coverage’s pseudo items using the name of the pseudo item without the preceding dollar sign ($). here’s one way to create a LabelRenderer: Set Map1. You can also set the Field that specifies whether or not to fit labels between two-point line features with the FittedField property. In Visual Basic. 10:00 AM . ValueMapRenderer Object Properties AllowDuplicates MinLevel SymbolField ProgrammersReference. the LabelRenderer provides several field-based properties that let you drive how and even whether. The SymbolCount property contains the number of symbols associated with the LabelRenderer. LabelPlacer Object. You can control whether or not to draw the features in addition to the labels by setting the DrawBackground property. ClassBreaksRenderer Object. Using the label’s level value in concert with the MaxLevel and MinLevel properties. Finally. and you can determine whether or not to spline text along line features with the SplinedText property.pmd 317 10/28/2004. DotDensityRenderer Object. Substitute appropriate values for the data paths. BatchMatch Method 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. You should find that your Standardizer is Valid. 10:00 AM . Return Values The return values for the LastError property are EnhancedGeocodingErrorConstants. but your Geocoder does not have any MatchVariableField proper- ties set. info As String) Dim msg As String If Not obj. Syntax object. info ProgrammersReference. value An integer that indicates the last error (See return Values). vbCritical. paste the code into the Declarations section of a form containing a Map named Map1.”. Option Explicit Sub ReportError(obj As Object.Valid Then MsgBox “The object is not valid. To try this example. the code returns a message about the type of error. LocateCandidate Method. If a problem exists. Press F5.pmd 318 10/28/2004. PlaceLocator Object Description Returns a value that specifies the type of error that exists in the Geocoder or Standardizer objects. See Also StandardizeAddress Method. 318 MapObjects Programmer’s Reference DrawBackground MaxLevel UseDefault Field RotationField Tag HeightField SplinedText XOffsetField LevelField Symbol YOffsetField MaxLevel SymbolCount LastError Property Applies To Geocoder Object.LastError [= Value] The LastError property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. LastError Case 1 msg = “Unknown error” Case 2 msg = “Internal error” Case 3 msg = “Match rules unspecified” Case 4 msg = “Intersection match rules unspecified” Case 5 msg = “Standardizer unspecified” Case 6 msg = “Street table unspecified” Case 7 msg = “Standardization rules unspecified” Case 8 msg = “Specified standardizer is invalid” Case 9 msg = “Cannot open match rules” Case 10 msg = “Cannot find match variables” Case 11 msg = “Out of memory” Case 12 msg = “Error in match rules syntax” Case 13 msg = “Match rules warnings triggered” Case 14 msg = “No candidates” Case 15 msg = “Too many handles allocated” Case 16 msg = “No address standardized” Case 17 msg = “Cannot access database” Case 18 msg = “Cannot open standardization rules” ProgrammersReference.LastError = mgErrorNone Then MsgBox “No error”. info Else Select Case obj.pmd 319 10/28/2004. MapObjects Programmer’s Reference 319 End If If obj. 10:00 AM . vbInformation. Standardizer Dim dc As New MapObjects2.Geocoder Dim stan As New MapObjects2.pmd 320 10/28/2004. 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 Private Sub Form_Load() Dim geo As New MapObjects2.DataConnection Dim lyr As New MapObjects2.MapLayer ProgrammersReference. key information is _ too complex” Case 30 msg = “Could not find specified key field in database” Case 31 msg = “The query is too complex. 10:00 AM . 320 MapObjects Programmer’s Reference 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. Connect If Not dc.GeoDataset = gd lyr.IntersectionStandardizingRules = “C:\Program Files _ \ESRI\MapObjects2\GeoRules\us_intsc.connected error” End End If Set gd = dc.stn” stan.mat” ReportError geo.LastError = mgErrorMatchVariableKeyFieldUnspecified Then MsgBox “The match variable fields have not been set here. “Check Error for Geocoder” If geo.pmd 321 10/28/2004. MapObjects Programmer’s Reference 321 Dim gd As Object ‘Change the paths below to ones appropriate for your data stan. vbInformation End If End Sub ProgrammersReference.Standardizer = stan geo.Add lyr geo.StandardizingRules = “C:\Program Files _ \ESRI\MapObjects2\GeoRules\us_addr.MatchRules = “C:\Program Files\ESRI\ _ MapObjects2\GeoRules\us_addr1.FindGeoDataset(“redlands”) lyr.IntersectionMatchRules = “C:\Program Files\ _ ESRI\MapObjects2\GeoRules\us_intsc1.Color = moBlue Map1.mat” geo. Check _ the sample of the Geocoder Object’s MatchVariableField _ property.Database = “C:\Program Files _ \ESRI\MapObjects2\Samples\Data\Redlands” dc.”.Connected Then MsgBox “dc. 10:00 AM .StreetTable = gd ‘Change the paths below to ones appropriate for your data geo.stn” ReportError stan. “Check Error for Standardarizer” ‘Change the paths below to ones appropriate for your data dc.Layers.Symbol. Layers [= lyrCollection] The Layers property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. cities. 10:00 AM . Each layer in the collection may either consist of vector data. MapLayer Object. Properties Count Methods Add Item MoveToBottom Remove Clear MoveTo MoveToTop See Also Map Object. locations of customers. in which case it is referenced by an ImageLayer object. etc. and lakes. rivers. Use the Layers property of a Map object to retrieve its Layers collection. or soil types.either human or natural phenomena. 322 MapObjects Programmer’s Reference Layers Collection A Layers collection object represents the collection of geographical data layers defined for a Map. Syntax object. You can access members of the Layers collection either by numeric index or by the Name of the MapLayer. ProgrammersReference.pmd 322 10/28/2004. in which case it is refer- enced by a MapLayer object or it may consist of geographically referenced raster image data. highways. lyrCollection An object expression that evaluating to a MapObjects Layers collection. Using the Valid property. The default property of Layers is Item. for example. well sites. you can determine whether a MapLayer or an ImageLayer is valid before adding it to the collection. political boundaries. TrackingLayer Object Layers Property Applies To Map Object Description Returns a reference to the collection of MapLayer or ImageLayer objects belonging to a Map control. A MapLayer or an ImageLayer represents a kind of spatial information . the Add and Remove methods). See Also MapLayer Object. and then press F5. To try this example.MapLayer For Each l In Map1.pmd 323 10/28/2004. adding the name of each MapLayer to a List.AddItem l. or MapLayer displaying vector data.LayerType [= lyrType] The LayerType property syntax has these parts: ProgrammersReference. Constant Value Description moMapLayer 0 The layer represents a MapLayer moImageLayer 1 The layer represents an ImageLayer See Also MapLayer Object LayerType Property Applies To MapLayer Object. MapObjects Programmer’s Reference 323 Remarks You can manipulate members of the Layers collection using standard collection methods (for example. Option Explicit Private Sub Command1_Click() Dim l As MapObjects2.Layers List1. Once the Map displays. Syntax object. 10:00 AM . a ListBox named List1. ImageLayer Object Description Returns a value that indicates whether the layer is an ImageLayer displaying raster data. paste the code into the Declarations section of a form containing a CommandButton named Command1.Name Next l End Sub LayerType Constants MapObjects defines the following LayerType constants to describe the layers in a Map. click Command1. and a Map named Map1 that contains at least one MapLayer. Layers Collection Example This example uses the Layers property to iterate through all the Layers of a Map. Each element in the collection can be accessed by its index. Valid Property 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.AddItem “Visible: “ & Str(. and a Map named Map1 that has at least one MapLayer.Visible) List1. a ListBox named List1.Name List1. lyrType A LayerTypeConstant.Refresh End If End With End Sub Left Property Applies To Ellipse Object.LayerType = moMapLayer Then List1. See Also ShapeType Property. if it is a MapLayer. Return Values The return values for the LayerType property are LayerTypeConstants.field With Map1.Layers. it’s added to the bottom of the list of layers and others layers will be drawn on top of it.LayerType = moImageLayer Then Map1. Press F5 and click Command1.AddItem “Symbol color: “ & Str(.Fields List1.Name num = num + 1 Next f ElseIf . 10:00 AM . To try this example paste the code into the Declarations section of a form containing a CommandButton named Command1.color) num = 1 For Each f In .Records.pmd 324 10/28/2004. if the layer is an ImageLayer.AddItem “Name: “ & . Rectangle Object ProgrammersReference.AddItem “Field “ & num & “: “ & f.Layers(0) If .Symbol. 324 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list. Option Explicit Private Sub Command1_Click() Dim num As Integer Dim f As MapObjects2.MoveToBottom 0 Map1. the code reports on some of the layer’s properties. the code maintains the dimensions of the border around the Map. Option Explicit Private Sub Form_Resize() Dim lBorder As Long lBorder = Map1. When you resize the form. See Also Top Property Example This example uses the Left property to set a border around a Map.Move lBorder. then resize the form by dragging one of its corners. To try this example.(lBorder * 2) End Sub Length Property Applies To Line Object Description Returns the length of a Line object in map units. ScaleWidth . 10:00 AM .Left Map1. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. _ ScaleHeight . distance A double indicating the length of the object.(lBorder * 2). Press F5. lBorder. Syntax object. See Also Area Property. Read only. value A numeric expression specifying distance. Perimeter Property ProgrammersReference.Length [= distance] The Length property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Syntax object.Left [= value] The Left property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 325 10/28/2004. MapObjects Programmer’s Reference 325 Description Returns or sets the distance between the internal left edge of an object and the left edge of its container. SearchByDistance(oPoint. copy the code into the Declarations section of a form that contains a Map named Map1 that contains a MapLayer with Line features.Recordset Dim oPoint As MapObjects2. If you set a LevelField and its value for ProgrammersReference. Y) Set oRecset = Map1.MoveFirst ‘reset the cursor ‘report the results MsgBox “Length: “ & oField. Levels are stored in the LevelField associated with a LabelRenderer. Option Explicit Private Sub Map1_MouseDown(Button As Integer.Field Set oPoint = Map1.Point Dim oField As MapObjects2. Map1. 326 MapObjects Programmer’s Reference Example This example makes use of the Length property to report back the length of a Line segment you select. Shift As Integer. X _ As Single. Remarks You can use levels to control whether a label for a feature draws on a Map. Y As Single) Dim oRecset As MapObjects2. “”) If Not oRecset. If specified.ToMapPoint(X.Layers(0).LevelField [= value] The LevelField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. _ ToMapDistance(100). the LabelRenderer makes use of the value of the specified Field to control whether it will draw a label for a feature. value A string expression that specifies a name of a Field in a Recordset. To try this example.EOF Then Set oField = oRecset(“shape”) oRecset.Value. Syntax object.pmd 326 10/28/2004. Press F5 and click on a line. 10:00 AM .Length End If End Sub LevelField Property Applies To LabelRenderer Object Description Returns or sets the Field that contains level information for a LabelRenderer object. the label for the feature will not draw.Refresh End If End Sub Private Sub Map1_MouseDown(Button As Integer. 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.pmd 327 10/28/2004. 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. Label2. Press F5.LevelField = Combo1. See Also TextSymbol Object 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.ListIndex <> -1 Then Map1.Field = Combo2.LabelRenderer If Combo1. Shift As Integer.Min .ListIndex) . and three Label controls named Label1. and Label3.MaxLevel = Slider1.Extent = oRect End Sub Private Sub Slider1_Click() combo2_Click End Sub ProgrammersReference.Value End With Map1. The Form_Load event code will position all the controls except the Map. Option Explicit Private Sub combo2_Click() Dim oRenderer As New MapObjects2. a Slider control named Slider1.List(Combo1.TrackRectangle Set Map1.Renderer = oRenderer With oRenderer . You can use the slider to change the MaxLevel property. 10:00 AM . X As _ Single.MinLevel = Slider1.Value MsgBox “Min = “ & Slider1.Layers(0). MapObjects Programmer’s Reference 327 the feature is outside the range of MinLevel and MaxLevel.Min & “ max=” & Slider1.ListIndex) . Y As Single) Dim oRect As Rectangle Set oRect = Map1. To try this example.List(Combo2. Caption = “Level” Label1.5 Slider1.AutoSize = True Label2.AutoSize = True Label3.Max = 3 Slider1.AutoSize = True Combo1.5 Combo1.Top = Label1.Text = “” Slider1.Height + Label1.Top + Label1.Left Slider1.Top End Sub ProgrammersReference.Top = Label2.Top + Map1.Top + Label2.Left Combo2.pmd 328 10/28/2004.Left Label1.SmallChange Label1.Left = Map1.Height * 2.Left = Map1.Value = 1 Slider1.ListIndex = -1 Combo2.ListIndex = -1 Combo1.Left = Map1.Height * 1.Width * 1.LargeChange = Slider1.Left = Combo1.Left Label2.Top = Map1.Left + Label1.Caption = “Level field” Label2.Top Label3.5 Combo2.Top = Label2.Left = Map1.Type < moString Then Combo1.Records For Each oField In oRecset.AddItem oField.AddItem oField.Min = 0 Slider1.5 Combo1.Height * 2. 328 MapObjects Programmer’s Reference Private Sub Form_Load() Dim oRecset As MapObjects2.Name Next Label1. 10:00 AM .Recordset Dim oField As MapObjects2.Left = Combo1.Left Label3.Name End If Combo2.Text = “” Combo2.Top = Label1.Caption = “Text field” Label3.Top Label2.Top = Label3.Layers(0).Field Set oRecset = Map1.Fields If oField. a Line with two or more Parts is a multi-part Line. Points. Each vertex of the part should be added using a Point object. add the Points object to the Parts collection of the Line. which represents the vertices of a part of the Line. The Line object supports Linear Referencing. You can retrieve the bounding rectangle of a line with its Extent property.Line Dim pts As New MapObjects2. To return the set of Points at which another object crosses the Line.Y = 100 pts.Y = 200 pts. which makes it possible to record relative positions on or along Lines using measures. or Rectangle object. OffsetMeasures. Intersect. MapObjects Programmer’s Reference 329 Line Object A Line object represents a geometric shape that has two or more vertices.Point pt. which represent the vertices of that part of the Line. A Line may have one or many discontinuous Parts. You can test whether a Line object has measure values for all of its vertices using the IsFullyMeasured property. This can be done in Visual Basic with code like this: Dim new_line as New MapObjects2. 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. Each member of the Parts collection is a Points object.Add pt pt. The geometric methods Buffer. SetMeasures.Line Note that in order to add points that represent vertices to a new Line object you must first create a Points object.Add pt ProgrammersReference.Points Dim pt As New MapObjects2. 10:00 AM . You can create Line objects in Visual Basic with code like this: Dim myLine as New MapObjects2. You can also return Point and Line events using the ReturnLineEvent and ReturnPointEvents methods. In addition. You can use the DistanceTo method to return the distance in map units to another Point. XOr and Union are supported for Lines. Polygon.X = 100 pt.pmd 329 10/28/2004.X = 200 pt. Difference. A multi-part Line acts as a single shape for methods such as SearchShape. SetMeasuresAsLength and UpdateMeasures methods. Once you have built up the part. The ReturnMeasure method can be used to calculate measure values along a Line. and you can update the measure values using the MultiplyMeasures. Line. you can return the length of a Line with the read-only Length property. use the GetCrossings method. Parts. Symbol Object ProgrammersReference.Y = 300 pts. 10:00 AM .Add pt new_line. Constant Value Description moSolidLine 0 Solid line moDashLine 1 Dash line moDotLine 2 Dot line moDashDotLine 3 Dash Dot line moDashDotDotLine 4 Dash Dot Dot line See Also Line Object. 330 MapObjects Programmer’s Reference pt.pmd 330 10/28/2004.Add pts See Also Points Object.X = 300 pt. TrackLine Method Properties Extent Length ShapeType IsFullyMeasured Parts Methods Buffer Offset SetMeasuresAsLength Difference OffsetMeasures Union DistanceTo ReturnLineEvent UpdateMeasures GetCrossings ReturnMeasure XOr Intersect ReturnPointEvents MultiplyMeasures SetMeasures LineStyle Constants MapObjects defines the following constants for use with line symbols. BuildIndices Method. object An object expression that evaluates to an object in the Applies To list. mgLinkSecondary 1 Secondary street link variable. MapObjects Programmer’s Reference 331 LinkGroup Constants MapObjects defines the following constants for use with the Geocoder object’s MatchVariableIntersectionLink property.ListIndices The ListIndices method syntax has these parts: Part Description variable A MapObjects Strings collection that stores the index definitions defined by the Geocoder object’s AddIndex method. Syntax Set variable = object. Constant Value Description mgLinkPrimary 0 Primary street link variable. See Also AddIndex Method. SearchQueries Property Example See 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 ProgrammersReference. See Also Geocoder Object. 10:00 AM . MatchVariableIntersectionLink Property ListIndices Method Applies To Geocoder Object Description Returns the logical indices associated with the Geocoder object as a MapObjects Strings object.pmd 331 10/28/2004. index A numeric expression that specifies the relative position of a member of the candidate group associated with the Geocoder object. Syntax Set variable = object. more than one candidate in ProgrammersReference.Locate( placeName) The Locate method syntax has these parts: Part Description variable An object expression that evaluates to a Points collection. object An object expression that evaluates to an object in the Applies To list. Remarks The Geocoder object’s GenerateCandidates method generates a list of candidates for matching. 332 MapObjects Programmer’s Reference Syntax Set variable = object. with the first candidate in the list being the one with the highest score. The candidates in the list are ranked by their score. See Also Buildndex Method. Part Description variable An object expression that evaluates to an AddressLocation. Indexed Property. PlaceNameTable Property Example See FindAllPlaceNames Method LocateCandidate Method Applies To Geocoder Object Description Matches the specified address against a candidate address. placeName A string expression that specifies the place name to find.pmd 332 10/28/2004. Remarks Each Point in the Points collection represents the centroid of the feature which the placeName was matched to. and returns the corresponding AddressLocation. If GenerateCandidates returns mgGeocodeSuccessMultipleBest as a GeocodeSuccessConstant. FindAllPlaceNames Method. If MapObjects can not find the placeName. object An object expression that evaluates to an object in the Applies To list. 10:00 AM .LocateCandidate ( index) The LocateCandidate method syntax has these parts. the Points collection will be empty. Standardizer ProgrammersReference. See Also MatchScore Property. The AddressLocation object can be displayed on a Map using the Location property.Location The Location property syntax has these parts: Part Description variable An object expression that evaluates to a Point. The example also demonstrates the use of the Matched property to determine if the address specified resulted in a match. a Map named Map1. The code reports the side of the street the address falls on.Geocoder Dim stan As New MapObjects2. 10:00 AM . IntersectionMatchVariableCount Property Example See Geocoder Object Location Property Applies To AddressLocation Object Description Returns the location of the match as a Point object. MapObjects Programmer’s Reference 333 the list have the same highest score. The Location of the geocoded address will be affected by the SqueezeFactor and Offset if these properties are set. Enter an address in the TextBox and press Match. See Also AddressLocation Object. a TextBox named Text1. which returns an AddressLocation. the geographical location of the matched address can be returned using the Geocoder’s LocateCandidate method. Remarks After a successful address match. Example This example demonstrates how to use the StreetSide property to report which side of the street a matched address falls on. StreetTable Property. MatchVariableCount Property. StreetSide Property Syntax Set variable = object. then press F5 and click the Load button to specify a GeoDataset that represents a street network. GenerateCandidates Method.pmd 333 10/28/2004. Option Explicit Dim theGeocoder As New MapObjects2. paste the code into the Declarations section of a form that contains a CommonDialog control named CommonDialog1. You can review the score of each candidate by examining the object’s Candidate property. object An object expression that evaluates to an object in the Applies To list. and two CommandButton controls named Command1 and Command2. To try this example. StreetSide = 0 Then msg = “left” Else msg = “right” End If Map1. “MapObjects” Else MsgBox “MapObjects couldn’t match this address”.GenerateCandidates If theGeocoder.TrackingLayer. 10:00 AM .AddressLocation Private Sub Command2_Click() If Len(Text1.Text) = 0 Then MsgBox “Please enter an address in the text box” Exit Sub End If Dim msg As String If theGeocoder.Symbol Dim addLoc As MapObjects2.ClearEvents If addLoc. vbInformation.LastError Unload Me Exit Sub End If End Sub Private Sub Command1_Click() Dim dcx As New MapObjects2.pmd 334 10/28/2004.CandidateCount > 0 Then Set addLoc = theGeocoder.Valid Then theGeocoder. vbCritical.Refresh MsgBox “The address is on the “ & msg & “ side of _ the street”.DataConnection ProgrammersReference.LocateCandidate(0) Map1. 334 MapObjects Programmer’s Reference Dim sym As New MapObjects2.SetFocus End If Else MsgBox “The geocoder is not valid” & Chr(13) & _ theGeocoder. _ “MapObjects” Text1. MapObjects Programmer’s Reference 335 Dim sts As MapObjects2.Add ml Map1.stn” If stan.shp)|*.shp” .Layers(0).Database = Left(fn. 10:00 AM .SetFocus Command1. fn As String. Len(ft) .StreetTable = dcx.Enabled = False Command2. “MapObjects” End End If ft = . Len(fn) .MapLayer Dim ft As String.1) dcx.Connect Set theGeocoder.Len(ft) .FileName End With X = Left(ft..DefaultExt = “*.FindGeoDataset(X) Map1.pmd 335 10/28/2004.Filter = “ESRI Shapefiles (*.Color = moBlue Call setupGeocoder Text1.Valid Then ProgrammersReference.exiting”.StandardizingRules = “C:\Program Files\ESRI\MapObjects2 _ \GeoRules\us_addr...FindGeoDataset(X) ml. _ vbCritical.4) dcx.GeoDataset = dcx.Symbol.InitDir = “C:\Program Files\ESRI\MapObjects2” On Error Resume Next .shp” . X As String With CommonDialog1 .ShowOpen If Err..Number = cdlCancel Then MsgBox “No street table selected.” & Chr(13) & “.CancelError = True ‘Change the path below if necessary .FileTitle fn = .Layers.GeoDataset Dim ml As New MapObjects2.Enabled = True End Sub Private Sub setupGeocoder() ‘Set up the standardizer stan. StandardizeAddress (Text1. mgIndexTypeSoundex) Then MsgBox “Cannot build geocoding index. mgIndexTypeSoundex) Then MsgBox “Cannot build geocoding index.AddIndex(“Name”. “”.”.MatchVariableField(“FromRight”) = “R_f_add” theGeocoder. 10:00 AM .Text) Else MsgBox “The standardizer is not valid” & Chr(13) & “Please check _ the standardizer properties” MsgBox stan.MatchRules = “C:\Program Files\ESRI\ _ MapObjects2\Georules\us_addr2.IndexStatus = 3 Then theGeocoder.MatchVariableField(“ToRight”) = “R_t_add” theGeocoder. 336 MapObjects Programmer’s Reference theGeocoder. vbCritical Exit Sub End If If Not theGeocoder.MatchVariableField(“SufDir”) = “suffix” ‘Check and build indices If Not theGeocoder.EraseIndices ‘ Specify the fields and types for the indices If Not theGeocoder.Add “SN? & HN” queries.AddIndex(“Type”.”.SearchQueries = queries ProgrammersReference. “”.Strings queries.Add “SN” Set theGeocoder.MatchVariableField(“ToLeft”) = “L_t_add” theGeocoder.mat” theGeocoder. vbCritical Exit Sub End If If Not theGeocoder.MatchVariableField(“PreDir”) = “prefix” theGeocoder.MatchVariableField(“FromLeft”) = “L_f_add” theGeocoder.MatchVariableField(“StreetType”) = “type” theGeocoder.BuildIndices(True) Then MsgBox “Indices not built” End If End If ‘Specify search queries Dim queries As New MapObjects2.LastError Exit Sub End If ‘Assign the match variables to street table fields theGeocoder.MatchVariableField(“StreetName”) = “name” theGeocoder.Standardizer = stan stan.pmd 336 10/28/2004. To try this example. ByVal _ canceled As Boolean.Enabled = False Text1. and draws a vertical line at that longitude. paste the code into the ProgrammersReference.Color = moRed sym.Size = 6 End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer. ByVal hDC As stdole. value A numeric expression that specifies the zero longitude.pmd 337 10/28/2004. MapObjects Programmer’s Reference 337 End Sub Private Sub Form_Load() Set addLoc = Nothing Command1. 10:00 AM .Longitude [= value ] The Longitude property syntax has these parts: Part Description object An object expression that evaluates to a PrimeMeridian object.DrawShape addLoc.Text = “60 Parkwood Dr” sym. sym End If 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.SymbolType = moPointSymbol sym.location. Syntax object.Caption = “Load” Command2.Caption = “Match” Command2.OLE_HANDLE) If Not addLoc Is Nothing Then Map1. See Also Datum Object Example This example demonstrates how to access the Longitude property of the PrimeMeridian object. Top End With tmpPts.Style = moDashLine End With Dim tempPt As New MapObjects2.Extent.Longitude With meridSym .pmd 338 10/28/2004. each having a ProjCoordSys coordinate system set.Parts.Y = Map1.DrawShape mLine.CoordinateSystem.Color = moRed .Bottom End With tmpPts. Dim meridSym As New MapObjects2.X = currLong .Layers(0). which has at least one MapLayer.SymbolType = moLineSymbol .OLE_HANDLE) Map1. ByVal _ canceled As Boolean.Y = Map1.Extent. Then press F5.PrimeMeridian. meridSym End Sub ProgrammersReference. 10:00 AM .Line Private Sub Form_Load() currLong = Map1.Add tempPt With tempPt .Point Dim tmpPts As New MapObjects2.Add tmpPts End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer.Symbol Dim currLong As Double Dim mLine As New MapObjects2.X = currLong . 338 MapObjects Programmer’s Reference Declarations section of a new Form which has a Map named Map1.Size = 2 . _ GeoCoordSys. ByVal hDC As stdole.Add tempPt mLine.Points With tempPt . LostFocus Event. If you wish to display several MapLayers with data in different coordinate systems. Each layer is based on geographic data (either a MapLayer based on vector data. DblClick Event. which occurs if the Map control has the focus. MapObjects represents these geographic phenomena with GeoEvent objects. 10:00 AM . you may wish to set the RotationAngle or VisibleRegion properties. Syntax Private Sub object_LostFocus() The LostFocus event syntax has one part: Part Description object An object expression that evaluates to a Map control. see the Visual Basic online reference. KeyDown Event. You can simplify your coding tasks by using your development environment’s Properties dialog to set the presentation properties of the Map such as Appearance. A Map control may have a different CoordinateSystem to the MapLayers it contains. BackColor. a Map has a TrackingLayer to display geographic phenomena that may change position. MapObjects Programmer’s Reference 339 LostFocus Event Applies To Map Object Description The LostFocus event is a standard ActiveX control event. To change the way in which your map is displayed. WindowMode. BorderStyle. The default property for a Map object is the Layers collection. In addition. See Also Click Event. ProgrammersReference. or an ImageLayer based on raster data). Remarks For more information about the LostFocus event. ScrollBars. 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. and the user clicks on a different control or Form. or a different control or Form receives focus programmatically. MouseMove Event. MouseDown Event Map Control A Map control displays a collection of Layers. you should also set the CoordinateSystem property of both the MapLayers and the Map control. although ImageLayer objects. KeyPress Event. and GeoEvent objects on the TrackingLayer in a Map share the same coordinate system as the Map control.pmd 339 10/28/2004. if you want to display the shape. You can use the CopyMap method to copy the visible extent of a Map to the Clipboard in enhanced and standard metafile format. TrackPolygon method. MapObjects provides ToMapDistance and ToMapPoint. The Microsoft Windows operating environment identifies each form and control in an applica- tion by assigning it a handle. you can expose it to the entire Windows API. The FullExtent of the Map represents the union of all the MapLayer extents in the Map. Windows API calls use the control’s hWnd. MapObjects provides four methods to output the visible extent of a Map to a variety of destinations. Using the hWnd of a Map. 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. The Pan method provides a way to move the Map object’s extent with the mouse. Set the MinWidth property to determine the minimum width in map units that may be displayed on the Map. To display graphic text on the Map use DrawText. Properties Appearance FullRedrawOnPan RotationAngle ProgrammersReference. To draw geometric shapes or create geometric shapes that you can use to select features first use the TrackCircle method.pmd 340 10/28/2004. This property is read-writeable. use DrawShape in one of the drawing events such as AfterTrackingLayerDraw. 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. or the ToMapPoint method in a MouseDown event to construct the shape. Use the CancelAction property to determine what action to take if the user presses the ESC key when the application draws the Map. use FromMapDistance and FromMapPoint. To convert control units to map units in measurements or to perform other actions. to go from control units to map units. Use the PrintMap method to print the visible extent of the Map to a Printer. you may wish to use the RefreshLayer method instead. 10:00 AM . 340 MapObjects Programmer’s Reference You can control the spatial area displayed on the map by setting the Extent property. To redraw or invalidate the Map. TrackRectangle method. See the hWnd property Example. To flash a feature or other shape on the Map use the FlashShape method. 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. Conversely. use the Refresh method. or hWnd. whereas the CenterAt method provides a way to position the Map so that a specific coordinate pair is at its center. Use the OutputMap method to render the visible extent of the Map to the specified device context (hDC). TrackLine method. you may like to change by using the TrackRectangle method. If you have added new features to a MapLayer. then. MapObjects Programmer’s Reference 341 BackColor Height ScrollBars BorderStyle hWnd Tag CancelAction Layers TrackingLayer CoordinateSystem MinWidth VisibleRegion Enabled MousePointer WindowMode Extent Name FullExtent RefreshCount Methods CenterAt FlashShape RefreshLayer CopyMap FromMapDistance RefreshRect DrawShape FromMapPoint ToMapDistance DrawText OutputMap ToMapPoint EnableGIF OutputMap2 TrackCircle EnableTIFFLZW Pan TrackLine ExportMap PrintMap TrackPolygon ExportMap2 Refresh TrackRectangle Events AfterLayerDraw DragFiles KeyPress AfterTrackingLayerDraw DragOver LostFocus BeforeLayerDraw DrawError MouseDown BeforeTrackingLayerDraw DrawingCancelled Mouse Click DropFiles MouseUp DblClick GotFocus DragDrop KeyDown ProgrammersReference. 10:00 AM .pmd 341 10/28/2004. you can determine whether a MapLayer is valid before adding it to the Layers collection. You can retrieve the Recordset associated with a MapLayer with the Records property. You can perform spatial queries on MapLayer objects and qualify them with SQL ‘where’ clause expressions by using the MapLayer methods SearchByDistance or SearchShape. a MapLayer draws with a single Symbol. TrackingLayer Object MapLayer Object A MapLayer object represents a geo-referenced data layer on a Map. drawn with features from a GeoDataset. Use the Layers property of a Map object to retrieve its Layers collection. You can create MapLayer objects in Visual Basic with code like this: Dim mlyr as New MapObjects2. an SDE layer. The default property of Layers is Item. contributing to the extent of the Map. an ARC/INFO coverage. establish that object as the MapLayer object’s renderer and then set the properties of the renderer. you create a Renderer object. You can also display subsets of the features contained in a MapLayer by setting the FilterExpression or FilterShape properties. Use the Visible property to toggle whether a MapLayer or an ImageLayer is visible or hidden. TrackingLayer Object Properties AreaOfInterest FilterOrder Renderer ProgrammersReference. Each MapLayer also has a CoordinateSystem property. To draw a MapLayer. DataConnection Object. GeoDataset Object. which is used to define the coordi- nate system in which the MapLayer object’s GeoDataset is stored. The bounding rectangle of a MapLayer is stored in its Extent property. projected on-the-fly to a common coordinate system. CAD files and VPF data. data stored in different coordinate systems may be displayed together. By default. 10:00 AM . You can derive a GeoDataset object from an ESRI shapefile. Use SearchExpression to perform logical queries on the Recordset associated with the MapLayer. 342 MapObjects Programmer’s Reference See Also MapLayer Object. You can associate tabular information stored in another table with the Recordset of a MapLayer by creating a relate with the AddRelate method. DataConnection Object. GeoDataset Object. By setting the CoordinateSystem property of each MapLayer appropriate to the underlying data.pmd 342 10/28/2004.MapLayer See Also Map Object. Using the Valid property. MapObjects Programmer’s Reference 343 CoordinateSystem FilterShape ShapeType DensificationTolerance GeoDataset Symbol Extent GeographicTransformation Tag FilterExperssion LayerType Valid FilterFields Name Visible FilterOperator Records Methods AddRelate RemoveRelates SearchExpression BuildIndex SearchByDistance SearchShape MarkerStyle Constants MapObjects defines the following constants for use with marker symbols. 10:00 AM . Syntax object.pmd 343 10/28/2004. Constant Value Description moCircleMarker 0 Circle moSquareMarker 1 Square moTriangleMarker 2 Triangle moCrossMarker 3 Cross moTrueTypeMarker 4 TrueType See Also Point Object. Symbol Object MaskColor Property Applies To LabelPlacer Object Description Returns or sets the color used to mask labels.MaskColor [= color] ProgrammersReference. Refresh End Sub Private Sub Form_Load() Dim fnt As New StdFont fnt. See Also MaskLabels Property Example This example demonstrates the use of the properties associated with label masks of the LabelPlacer. and a Map control named Map1 that contains a MapLayer with line features. To try this example. Remarks The MaskColor property determines the color which is placed behind the label text. color A value or constant that determines the color of the masked area.LabelPlacer Private Sub Check1_Click() If Check1.Refresh End Sub Private Sub Command1_Click() CommonDialog1.Value = vbChecked Then lp.ShowColor lp. Press F5. see the Color settings topic in the online help. 10:00 AM . This property can be used to aid the clarity of the map display. paste the code into the Declarations section of a form that contains a CommonDialog control. You should set the Field property and the DefaultSymbol’s Height property to values appropriate to your data. a CommandButton named Command1.MaskColor = CommonDialog1. a CheckBox named Check1. 344 MapObjects Programmer’s Reference The MaskColor property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 344 10/28/2004.Name = “Arial” ProgrammersReference. Settings The settings of MaskColor are ColorConstants For more information on color settings.Value = vbUnchecked Then lp.MaskLabels = False End If Map1. Option Explicit Dim lp As New MapObjects2.MaskLabels = True ElseIf Check1.Color Map1. Click the button to set a new MaskColor You can click-drag a rectangle to zoom in to an area. Settings The settings for value are: ProgrammersReference. Syntax object.. value A boolean expression that determines whether the LabelPlacer should position a rectangular mask beneath each label and on top of the feature to which it corresponds. x _ As Single.pmd 345 10/28/2004.Caption = “Mask Color.Field = “NAME” .TrackRectangle 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.Height / 25 ‘arbitrary . y As Single) Map1.MaskLabels [= value] The PlaceBelow property syntax has these parts: Part Description object An object expression that evaluates to a LabelPlacer.Bold = True Set Map1.Renderer = lp With lp Set . 10:00 AM .Caption = “Mask Labels” Check1.Value = vbChecked lp.FullExtent.PlaceOn = True End Sub Private Sub Map1_MouseDown(Button As Integer.” Check1.DefaultSymbol.. as described in Settings. MapObjects Programmer’s Reference 345 fnt.Extent = Map1.MaskLabels = True lp.Height = Map1.DefaultSymbol.UseDefault = True .DrawBackground = True ‘draws the features End With Command1.Layers(0). Shift As Integer.Font = fnt . mat) US intersections with zone information (us_intsc1.mat) US intersections without zone information (us_intsc2. The .mat) ProgrammersReference. Syntax object. You can find the following Match rule files in the Georules folder: US addresses with zone information (us_addr1. rule filename A string expression that specifies the Match rule file name.mat file works in conjunction with the Standardizer’s properties.MatchRules [= rule filename] The MatchRules property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.mat) US addresses without zone information (us_addr2. Remarks MapObjects provides a set of match rules for different types of addresses. See Also MaskColor Property Example See MaskColor Property MatchRules Property Applies To Geocoder Object Description Returns or sets the match rule file name associated with the Geocoder object. False The LabelPlacer will not position masks between the labels and the features. 346 MapObjects Programmer’s Reference Setting Description True The LabelPlacer will position masks between the labels and the features. Select the one that is suitable to the type of address you want to match.pmd 346 10/28/2004.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 match rules . 10:00 AM . DataConnection ProgrammersReference. MatchVariable Property. StreetTables with Polygon or Point information (us_snum1.mat) See Also IntersectionMatchRules Property.mat) US 9 digit ZIP codes. Substitute appropriate values for the data paths and then press F5. MatchVariableField Property.mat) US addresses with zone information.Standardizer Dim dc As New MapObjects2.pmd 347 10/28/2004. MatchVariableCount Property.Geocoder Dim stan As New MapObjects2. MatchVariables. StreetTables with single house range (us_srng1.mat) US addresses without zone information. IntersectionRules and MatchVariableIntersectionLink properties of a Geocoder object. set it with an empty string Private Const m_FromLeft = “L_f_add” Private Const m_FromRight = “R_f_add” Private Const m_ToLeft = “L_t_add” Private Const m_ToRight = “R_t_add” Private Const m_PreDir = “Prefix” Private Const m_PreType = “Pre_type” Private Const m_StreetName = “Name” Private Const m_StreetType = “Type” Private Const m_SufDir = “Suffix” Private Const m_LeftZone = “Zipl” Private Const m_RightZone = “ZipR” Private Sub Form_Load() Dim geo As New MapObjects2. 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. MapObjects Programmer’s Reference 347 US addresses with zone information. 10:00 AM . Standardizer Object Example This example demonstrates how to set the MatchRules.mat) US 9 digit ZIP codes. StreetTables with ZIP+4 centroids (zip4rng. These properties are required before you start matching addresses.mat) US 5 digit ZIP codes. StreetTables with ZIP+4 centroids (zip4. Option Explicit ‘Set global variables with field names in the StreetTable ‘Modify if fields names in StreetTable are different ‘If a field is not available. StreetTables with 5 digit ZIP centroids (zip. StreetTables with single house range (us_srng2. StreetTables with Polygon or Point information (us_snum2.mat) US addresses without zone information. stn” geo. 348 MapObjects Programmer’s Reference Dim gd As Object Dim lyr As New MapObjects2.Color = moBlue Map1.IntersectionMatchRules = “C:\Program Files\ _ ESRI\MapObjects2\GeoRules\us_intsc1. i As Integer Dim name As String ‘You must assign a valid Standardizer object to the Geocoder ‘before trying to Geocode and address ‘Change the paths below to ones appropriate for your data stan.Connected Then MsgBox “dc.FindGeoDataset(“Redlands”) lyr.MatchVariableField(“ToRight”) = m_ToRight geo.pmd 348 10/28/2004.MatchVariableField(“FromLeft”) = m_FromLeft geo.mat” ‘ Link the Match Variables to fields in the StreetTable geo.MatchVariableField(“SufDir”) = m_SufDir ProgrammersReference.MatchVariableField(“PreType”) = m_PreType geo.MatchVariableField(“StreetName”) = m_StreetName geo.MatchVariableField(“StreetType”) = m_StreetType geo.Database = “C:\Program Files\ESRI\ _ MapObjects2\Samples\Data\Redlands” dc.MapLayer Dim f.stn” stan.MatchRules = “C:\Program Files\ _ ESRI\MapObjects2\GeoRules\us_addr1.IntersectionStandardizingRules = “C:\Program Files\ _ ESRI\MapObjects2\GeoRules\us_intsc.StandardizingRules = “C:\Program Files\ _ ESRI\MapObjects2\GeoRules\us_addr.Connect If Not dc.Symbol.StreetTable = gd ‘Set up the match rules and variables ‘Change the paths below to ones appropriate for your data geo.MatchVariableField(“PreDir”) = m_PreDir geo. 10:00 AM .connected error” End End If ‘Set up the StreetTable Set gd = dc.Standardizer = stan dc.GeoDataset = gd ‘lyr.MatchVariableField(“ToLeft”) = m_ToLeft geo.Add lyr geo.Layers.mat” geo.MatchVariableField(“FromRight”) = m_FromRight geo. IntersectionMatchVariableCount For i = 0 To f .AddItem (“ “) f = geo.MatchVariableIntersectionLink(“StreetType”. 1) = “PreDir2” geo. 1) = “LeftZone2” geo.MatchVariableIntersectionLink(“RightZone”.MatchVariableIntersectionLink(“LeftZone”. 1) = “SufDir2” geo. 0) = “StreetType1” geo.MatchVariableIntersectionLink(“RightZone”.pmd 349 10/28/2004. 1) = “StreetType2” geo.MatchVariableIntersectionLink(“SufDir”.1 name = geo. 0) = “LeftZone1” geo.AddItem (“ “) List1. 0) = “RightZone1” ‘ Link up intersection group 2 variables geo.AddItem (“Intersection Match Variable Name”) List1.AddItem (“Intersection Match Rule File Name = “ & _ geo.MatchVariableIntersectionLink(“LeftZone”.MatchVariableIntersectionLink(“PreType”. MapObjects Programmer’s Reference 349 geo.MatchVariable(i) List1.IntersectionMatchVariable(i) List1.AddItem (“Match Variable Name” & vbTab & _ “StreetTable Field Name”) List1.MatchVariableIntersectionLink(“StreetName”.AddItem vbTab & name Next i ProgrammersReference.MatchVariableField(“LeftZone”) = m_LeftZone geo.IntersectionMatchRules) List1.MatchVariableField(name) Next i List1.AddItem (“Match Rule File Name = “ & geo.MatchVariableIntersectionLink(“PreType”.MatchVariableIntersectionLink(“SufDir”.1 name = geo.MatchVariableField(“RightZone”) = m_RightZone ‘ Link the intersection group 1 variables geo. 1) = “PreType2” geo. 1) = “StreetName2” geo.AddItem (“ “) List1. 1) = “RightZone2” List1.MatchVariableIntersectionLink(“PreDir”. 0) = “PreDir1” geo. 10:00 AM .AddItem (“ “) List1.AddItem (“ “) f = geo.MatchRules) List1.AddItem name & vbTab & vbTab & vbTab & _ geo.MatchVariableIntersectionLink(“StreetType”. 0) = “PreType1” geo. 0) = “StreetName1” geo.MatchVariableIntersectionLink(“PreDir”. 0) = “SufDir1” geo.MatchVariableCount For i = 0 To f .MatchVariableIntersectionLink(“StreetName”. and a ListBox named List1. you may expect higher MatchScore values if your address string and your StreetTable have data entered to a strict procedure. Option Explicit Dim theGeocoder As New MapObjects2.AddressLocation Dim pt As MapObjects2. Remarks A MatchScore of 100 indicates a perfect match. those below are drawn with a yellow symbol. StreetSide Property Example This example demonstrates the use of the MatchScore property to return the status of an attempt at matching an address.Symbol ProgrammersReference. and you may have to experiment to find the right combination for your data. MatchScores around 30-70 are more usual. these are not hard and fast values.Standardizer Dim sym As New MapObjects2.Symbol Dim sym2 As New MapObjects2. The example below uses the Redlands sample dataset. If you are not using this dataset. 350 MapObjects Programmer’s Reference End Sub MatchScore Property Applies To AddressLocation Object Description Returns a value that indicates the match score for an AddressLocation object. with a score of 0 indicating no match at all. a CommandButton named Command1. Syntax object. Press F5. To try this example paste the code into the Declarations section of a form that contains a Map named Map1.Point Dim stan As New MapObjects2. 10:00 AM . you may have to change the properties of the Geocoder and Standardizer for your data.pmd 350 10/28/2004. candidates with a MatchScore above the MinimumMatchScore are drawn with a Red symbol. a TextBox named Text1. click the Load button. See Also Location Property. and select a dataset. There are many factors in the geocoding process.MatchScore [=variable] The MatchScore property syntax has these parts: Part Description variable An numeric expression that will hold the match score (data type is double). For example. Try entering a different address in the TextBox. Now press the Match button or move the slider. due to the complexities of the match process. However. object An object expression that evaluates to an object in the Applies To list.Geocoder Dim addLoc As MapObjects2. pmd 351 10/28/2004.GeoDataset Dim ml As New MapLayer Set theGeocoder = Nothing dcx.Connect Then MsgBox “Could not connect to “ & dcx.MinimumMatchScore = Slider1.GenerateCandidates Select Case s Case 1 Label3.Caption = “No candidates found” End Select Map1. MapObjects Programmer’s Reference 351 Private Sub Command1_Click() Dim strs As MapObjects2. standardize the address entered in the textbox stan.Text) theGeocoder.Caption = “Mulitple best candidates found” Case 3 Label3.Caption = “No candidates found above minimum match score” Case 0 Label3.Value If Not theGeocoder.Database Else ProgrammersReference. 10:00 AM .Caption = “Single best candidate found” Case 2 Label3.StandardizeAddress (Text1.Database = “C:\Program Files\ESRI\MapObjects2 _ Samples\Data\Redlands” If Not dcx.Valid Then MsgBox “Geocoder is not valid” Exit Sub End If s = theGeocoder.DataConnection Dim gds As MapObjects2.Refresh End Sub Private Sub Form_Load() Dim dcx As New MapObjects2.Strings Dim s As Variant Call setupGeocoder ‘First. Color = moRed sym2.StreetTable = gds Text1.Min = 0 Slider1.LastError Exit Sub End If ‘Assign the match variables to street table fields theGeocoder.Add ml Map1.mat theGeocoder. 10:00 AM .Max = 100 Slider1.Text = “60 Alta st” Command1.Color = moBlue theGeocoder. 352 MapObjects Programmer’s Reference ‘Add the Redlands dataset to the Map as a MapLayer Set gds = dcx.GeoDataset = gds Map1.Caption = “Match” Slider1.Layers(0).MatchVariableField(“PreDir”) = “prefix” ProgrammersReference.MatchVariableField(“FromLeft”) = “L_f_add” theGeocoder.Standardizer = stan Else MsgBox “The standardizer is not valid” & Chr(13) & _ “Please check the standardizer properties” MsgBox stan.pmd 352 10/28/2004.MatchVariableField(“ToRight”) = “R_t_add” theGeocoder.Caption = “100” Label3.StandardizingRules = “C:\Program Files\ESRI\ _ MapObjects2\GeoRules\us_addr.Caption = “0” Label2.MatchVariableField(“FromRight”) = “R_f_add” theGeocoder.MatchRules = “C:\Program Files\ESRI\ _ MapObjects2\GeoRules\us_addr2.Symbol.Caption = “ “ sym.stn” If stan.FindGeoDataset(“redlands”) Set ml.Value = 35 Label1.Valid Then theGeocoder.MatchVariableField(“ToLeft”) = “L_t_add” theGeocoder.Layers.Color = moYellow End If End Sub Private Sub setupGeocoder() ‘Set up the standardizer stan. sym Else Map1. “”.Strings queries.DrawShape theGeocoder.OLE_HANDLE) If theGeocoder.AddIndex(“Type”.BuildIndices(True) Then MsgBox “Indices not built” End If End If ‘Specify search queries Dim queries As New MapObjects2. mgIndexTypeSoundex) Then MsgBox “Cannot build geocoding index.AddIndex(“Name”.MatchVariableField(“StreetType”) = “type” theGeocoder. vbCritical Exit Sub End If If Not theGeocoder.EraseIndices ‘ Specify the fields and types for the indices If Not theGeocoder.LocateCandidate(i).”. 10:00 AM . ByVal hDC As stdole.DrawShape theGeocoder.pmd 353 10/28/2004.CandidateCount . mgIndexTypeSoundex) Then MsgBox “Cannot build geocoding index.MatchVariableField(“SufDir”) = “suffix” ‘Check and build indices If Not theGeocoder.SearchQueries = queries End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer.Add “SN? & HN” queries. “”.”. MapObjects Programmer’s Reference 353 theGeocoder.location.LocateCandidate(i).CandidateCount > 0 Then Dim cand As MapObjects2.MinimumMatchScore Then Map1.MatchScore >= _ theGeocoder.IndexStatus = 3 Then theGeocoder.Add “SN” Set theGeocoder.1 If theGeocoder.Point Dim i As Integer For i = 0 To theGeocoder.LocateCandidate(i).location.MatchVariableField(“StreetName”) = “name” theGeocoder. ByVal _ canceled As Boolean. sym2 End If Next i End If End Sub ProgrammersReference. vbCritical Exit Sub End If If Not theGeocoder. 354 MapObjects Programmer’s Reference 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. MatchVariableField Property. Syntax object. See Also MatchRules Property. Syntax object. MatchVariableField Property. See Also MatchRules Property. Index must be a number from 0 to a number that is one less than the value of the Geocoder object’s MatchVariableCount property.MatchVariableCount [= count] The MatchVariableCount property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. index A numeric expression that specifies the relative position of a member of the group of MatchVariable names associated with the Geocoder object.MatchVariable ( index) [= name] The MatchVariable property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. MatchVariable Property ProgrammersReference.pmd 354 10/28/2004. MatchVariableCount Property Example See MatchRules Property MatchVariableCount Property Applies To Geocoder Object Description Returns the number of MatchVariables defined in the MatchRules property associated the Geocoder object. 10:00 AM . count A variable declared to be of integer data type. name A variable declared to be of the string data type. Remarks The MatchVariableField property is used to link fields in the StreetTable with variables defined in the . Syntax object.MatchVariableIntersectionLink ( variable. 10:00 AM . the Records property of the MapLayer can be used to access the field names.mat file can be accessed using the MatchVariable property of the Geocoder. fieldName A string expression that specifies the name of the field in the StreetTable. MapObjects Programmer’s Reference 355 Example See MatchRules Property MatchVariableField Property Applies To Geocoder Object Description Returns or sets the field name in the StreetTable for the MatchVariable associated with the Geocoder object.pmd 355 10/28/2004. If a MapLayer object contains the street network you wish to geocode against. MatchVariableCount Property. See Also MatchRules Property.MatchVariableField (variable) [ = fieldName] The MatchVariableField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. LinkGroup ) [ = fieldName] The MatchVariableIntersectionLink property syntax has these parts: ProgrammersReference. Syntax object. The variables defined in the . MatchVariable Property Example See MatchRules Property 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. variable A string expression that specifies the variable name that is returned from the Geocoder object’s MatchVariable property.mat file. MatchVariableCount Property. 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 object’s MinimumMatchScore property. 10:00 AM . value A boolean expression that indicates whether to match an address if multiple candidates with the same score are found. A False value will force MapObjects to skip matching the address that generates multiple candidates with the same score even ProgrammersReference. Settings The settings of the LinkGroup variable are LinkGroupConstants: Remarks The variable part of the syntax is defined in the us_intsc1.pmd 356 10/28/2004. LinkGroup A value or constant that specifies the type of link group as defined in the LinkGroupConstants.MatchWhenAmbiguous [ = value ] The MatchWhenAmbiguous property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.mat and us_intsc2. Many MatchVariableIntersectionLink variables may be defined.mat files. MatchVariable Property Example See MatchRules Property 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. using the Geocoder object’s BatchMatch method. 356 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list. variable A string expression that specifies the variable name that is returned from the Geocoder object’s IntersectionMatchVariable property. This property only applies to the batch matching process. fieldName A string expression that specifies the name of the field in the StreetTable’s GeoDataset. Syntax object. See Also MatchRules Property. Statistics properties Example See CalculateStatistics Method MaxFileBuffer Property Applies To Map Object Description This property sets or returns the amount of memory to be used to file reading. 10:00 AM . Remarks To create a Statistics object whose statistical properties you can return.CalculateStatistics(“tot_vote”) See Also CalculateStatistics Method.pmd 357 10/28/2004. for example: Set stats = Map1.Records. MapObjects Programmer’s Reference 357 though the score is higher or equal to the MinimumMatchScore property.Max [= value] The Max property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Syntax object. BatchMatch Method Example See Geocoder Object Max Property Applies To Statistics Object Description Returns a value that indicates the maximum value calculated by a Statistics object. See Also MinimumMatchScore Property. Syntax object. The default value for the MatchWhenAmbiguous property is False.MaxFileBuffer [= value] The MaxFileBuffer property syntax has these parts: ProgrammersReference.Layers(0). in bytes. value A double data type specifying the maximum value calculated by the Statis- tics object. use the Recordset object’s CalculateStatistics method. The default MaxFileBuffer size is 1 megabyte. 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. i. the GeoDataset object’s AllowSharing property is set to false.e. if the GeoDataset of it’s MapLayer does not currently allow sharing. Dim dc As New MapObjects2. If the MaxFileBuffer property is set to Zero.AllowSharing Then Label1. less resources are used but the drawing of the MapLayers may take longer.Caption = “MaxFileBuffer = “ & Map1.DataConnection Dim geo As New MapObjects2.Caption = “File allows sharing” End If End Sub Private Sub Form_Load() dc. in bytes. To try this example.Database = “C:\Program Files\ESRI\MapObjects2\Samples\Data\World” ProgrammersReference. MapObjects will only use memory mapping when it has exclusive access to a file. you will not need to change the MaxFileBuffer property.GeoDataset Dim layer As New MapObjects2. paste the code into the Declarations section of a form containing a Map named Map1 and a Label named Label1. value A numeric that determines the maximum file buffer size. memory mapping will not be used at all. The amount of memory used for this operation is defined in the MaxFileBuffer property. If using this property. 358 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list. you may wish to change the MaxFileBuffer size. In the majority of cases.pmd 358 10/28/2004. and then press F5. 10:00 AM . but a smaller size means that smaller sections of memory are used while reading each file. Remarks In order to read large shapefiles.MapLayer Option Explicit Private Sub setLabel() If geo. Alter the Database and FindGeoDataset properties as appropriate. Example This example returns the current size of the MaxFileBuffer property. MapObjects maps the shapefile into memory in sections.MaxFileBuffer & “ _ bytes” Else Label1. A larger MaxFileBuffer size will mean that each MapLayer is read faster. If you are using particularly large files and have large amounts of memory. 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. Syntax object.MaxPieSize [= value] The MaxPieSize property syntax has these parts: ProgrammersReference. 10:00 AM . (Data is Integer). See Also TextSymbol Object Example See LevelField Property MaxPieSize Property Applies To ChartRenderer Object Description Returns or sets the maximum pie chart size of the ChartRenderer object.pmd 359 10/28/2004.MaxLevel [= value] The MaxLevel property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. If you set a LevelField and its value for the feature is outside the range of MinLevel and MaxLevel.GeoDataset = geo Map1. Syntax object.Layers.FindGeoDataset(“Country”) layer. value A numeric expression that indicates the maximum value stored in its LevelField at which a LabelRenderer draws text.Add layer 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. MapObjects Programmer’s Reference 359 Set geo = dc. the label for the feature will not draw. See Also MinPieSize Property. value A double data type specifying the mean value calculated by the Statistics object. The ChartRenderer will reverse values if MaxPieSize is less than MinPieSize. 10:00 AM . 360 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list.Layers(0). for example: Set stats = Map1. Remarks All pie charts will be scaled into the range between MinPieSize and MaxPieSize. value An integer that represents the radius in points that corresponds to the largest pie chart in the collection.pmd 360 10/28/2004. use the Recordset object’s CalculateStatistics method. If no SizeField is specified then the size of the pie chart will be determined by the sum of the values in the chart. Syntax object. SizeField Property Example See ChartRenderer Object Mean Property Applies To Statistics Object Description Returns a value that indicates the mean value calculated by a Statistics object.CalculateStatistics(“tot_vote”) See Also CalculateStatistics Method.Records. ProgrammersReference. Statistics properties Measure Property Applies To Point Object Description Return or set a measure on a Point object.Mean [=value] The Mean property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Remarks To create a Statistics object whose statistical properties you can return. Count . and a Map named Map1 which contains one shapefile MapLayer with Measured Lines. 10:00 AM .1 Step 1 ‘No of vertices in total ProgrammersReference.1 Set line = recs(“Shape”).line Dim recs As New MapObjects2.Clear Set recs = Map1.pmd 361 10/28/2004.Count For i = 0 To recCount . To try this example. ReturnMeasure Method Example This example uses the Measure property of a Point object to create a list of Measures of Points in a Line. paste the code into the Declarations section of a form contain- ing a ListBox named List1. and then press F5.Records recCount = recs.Parts pCount = pCount + 1 For i = 0 To partLine.Layers(0). value A double data type specifying a measure value.Value outputMeasures line Next i End Sub Private Sub outputMeasures(aLine As MapObjects2. Option Explicit Private Sub Form_Load() Dim line As New MapObjects2. See Also Line Object.Measure [= value ] The Measure property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Points Dim i As Integer For Each partLine In aLine.line) ‘count the no of vertices Dim pCount As Integer Dim itemCount As Integer Dim partLine As MapObjects2.Recordset Dim recCount As Integer Dim i As Integer List1. MapObjects Programmer’s Reference 361 Syntax object. AddItem “Item:” & i & “.pmd 362 10/28/2004. moMethod_Geocentric 9603 The simplest datum transformation method is a geocentric.X & Chr(9) & “Y:” & . The differences between the spheroids are automatically ProgrammersReference.” & itemCount & Chr(9) & “X:” _ & .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. 10:00 AM . 362 MapObjects Programmer’s Reference itemCount = itemCount + 1 With partLine. The geocentric transformation models the differences between two datums in the XYZ coordinate system. Usually the transforma- tion parameters are defined as going ‘from’ a local datum ‘to’ WGS84. Constant Value Description moMethod_LongitudeRotation 9601 Transformation that converts coordinates between any two prime meridians. moMethod_Molodensky 9604 Conversion directly between two geo- graphic coordinate systems without converting to an XYZ system as an intermediate step. or three parameter. usually from a non-Greenwich-based prime meridian to a Greenwich-based primemeridian.Item(i) List1. The Molodensky method requires the three linear shifts (delta XYZ) and the difference between the semimajor axes and the flattenings of the two spheroids.Y & Chr(9) & “M:” & . The linear shifts between the two datums (delta XYZ) are defined in meters. moMethod_NADCON 9613 This method coverts NAD27 datum based data to NAD83.los.las and <state abbrev>hpgn. moMethod_MolodenskyAbridged 9605 Simplified. MapObjects Programmer’s Reference 363 calculated according to the datums involved. 10:00 AM . moMethod_CoordinateFrame 9607 Similar to the PositionVector method. This method is mainly used in Europe. less accurate version of the Molodensky method.pmd 363 10/28/2004. taking additional parameters of angular rotation (in decimal seconds) and a scale factor (in parts per million) as well as the linear shifts (delta XYZ). moMethod_HARN 109613 This method converts NAD83 based data to HARN (High Accuracy Reference Network). Remarks See online help See Also GeoTransformation Object ProgrammersReference. If you want to overlay NAD27 based data onto HARN based data you will need to use this method to go via NAD83. moMethod_PositionVector 9606 A more complex method than the Geocen- tric. MapObjects automati- cally selects the correct files depending on the pre-defined geotransformation Type that was selected. moMethod_BursaWolf 42607 This method is identical to CoordinateFrame and is supported for historical reasons. This method uses grid files <state abbrev>hpgn. Mainly used in the United States and Australia. but by convention defines rotation parameters in the opposite direction. This method uses grid files that MapObjects automatically selects depending on the pre-defined geotransformation Type that was selected. Remarks To create a Statistics object whose statistical properties you can return. value A double data type specifying the minimum value calculated by the Statis- tics object. 10:00 AM . Syntax object. Syntax object. as described in Settings Settings The settings for methConstant are DirectionConstants. use the Recordset object’s CalculateStatistics method. methConstant A numeric expression that specifies the Method to be used in the GeoTransformation. 364 MapObjects Programmer’s Reference 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.pmd 364 10/28/2004.Min The Min property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. See Also GetParameter Method. for example: ProgrammersReference. Method [= methConstant ] The Method property syntax has these parts: Part Description object An object expression that evaluates to a GeoTransformation object. SetParameter Method Example See GeographicTransformation Property Min Property Applies To Statistics Object Description Returns a value that indicates the minimum value calculated by a Statistics object. Layers(0). value A numeric expression that specifies the minimum match score. Therefore setting a higher MinimumMatchScore restricts the results of the BatchMatch to those which have a higher confidence of address match.MinimumMatchScore [ = value] The MinimumMatchScore property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. The value must be in the range of 0 to 100. Statistics properties Example See CalculateStatistics Method MinimumMatchScore Property Applies To Geocoder Object Description Returns or sets the minimum match score associated the Geocoder object. The default MinimumMatchScore value is 70. This score deter- mines if each candidate is considered to be successfully matched by the BatchMatch method. See Also BatchMatch Method Example See Geocoder Object MinLevel Property Applies To LabelRenderer Object ProgrammersReference. Syntax object. The value determines whether an address will be matched against the found candidate in the batch matching process. MapObjects Programmer’s Reference 365 Set stats = Map1. 10:00 AM . A MatchScore between 75 and 100 can generally be considered a good match.CalculateStatistics(“tot_vote”) See Also CalculateStatistics Method.Records. Remarks The batch matching process will not consider each candidate a successful match unless it’s MatchScore is above that of the MinimumMatchScore. in the range of 0 to 100.pmd 365 10/28/2004. based on the candidate’s MatchScore. value An integer that represents the radius in points that corresponds to the smallest pie chart in the collection.pmd 366 10/28/2004. 10:00 AM . the label for the feature will not draw. See Also TextSymbol Object Example See LevelField Property MinPieSize Property Applies To ChartRenderer Object Description Returns or sets the minimum pie chart size of the ChartRenderer object. If no SizeField is specified then the size of the pie chart will be determined by the sum of the values in the chart. Syntax object. (Data type is Integer). Levels are stored in the LevelField associated with a LabelRenderer. Syntax object. SizeFIeld Property ProgrammersReference.MinPieSize [= value] The MinPieSize property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. value A numeric expression that indicates the minimum value stored in its LevelField at which a LabelRenderer draws text. Remarks You can use levels to control whether a label for a feature draws on a Map. See Also MaxPieSize Property. Remarks All pie charts will be scaled into the range between MinPieSize and MaxPieSize. The ChartRenderer will reverse values if MaxPieSize is less than MinPieSize. If you set a LevelField and its value for the feature is outside the range of MinLevel and MaxLevel.MinLevel [= value] The MinLevel property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 366 MapObjects Programmer’s Reference Description Returns or sets the minimum LevelField value at which a LabelRenderer object will draw labels. Extent. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer.pmd 367 10/28/2004.) Remarks Use the MinWidth property to control the extent to which the user may zoom in on the Map. Syntax object. Once the Map displays. Y As Single) If Map1. Shift As Integer.Extent. See Also Extent Property Example This example uses the MinWidth property to control the extent to which you may zoom in on a Map. click-drag a Rectangle to zoom in on the Map.Extent = Map1. (Data type is Double.Width * 0.TrackRectangle End If End Sub ProgrammersReference. 10:00 AM .MinWidth = Map1. To try this example.MinWidth Then Map1. X _ As Single. MapObjects Programmer’s Reference 367 Example See ChartRenderer Object MinWidth Property Applies To Map Object Description Returns or sets the minimum width in map units that may be displayed on the Map. The default value is 0.125 End Sub Private Sub Map1_MouseDown(Button As Integer. 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. and then press F5. Once you’ve reached the MinWidth threshold. value A numeric expression that represents the minimum width in map units that may be displayed on the Map. Option Explicit Private Sub Form_Load() Map1.MinWidth [= value] The MinWidth property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Width >= Map1. you won’t be able to zoom in any farther. 368 MapObjects Programmer’s Reference MouseDown. as described in Values. shift An integer specifying the status of the Shift key. specifying the Y coordinate of the mouse click. Syntax Private Sub object_MouseDown(Button As Integer. The MouseUp event occurs when the user releases the mouse button again. button An integer specifying with which mouse button the user clicked on the Map. in control units. as described in Values. in control units. specifying the X coordinate of the mouse click. and may have the following values Constant Value Description vbLeftButton 1 The left mouse button is pressed vbRightButton 2 The right mouse button is pressed vbMiddleButton 4 The middle mouse button is pressed The value of shift evaluates to a Visual Basic constant. which occurs when the user clicks on the map. Mouse Up Events Applies To Map Object Description The MouseDown event is a standard ActiveX control event. X As Single. 10:00 AM . Values The value of button evaluates to a Visual Basic constant. Shift As Integer.pmd 368 10/28/2004. Y As Single) The MouseDown event syntax has these parts: Part Description object An object expression that evaluates to a Map control. X A value of single data type. Y A value of single data type. and may have the following values Constant Value Description vbShiftMask 1 The SHIFT key is pressed ProgrammersReference. and may have the following values. X As Single. and a right-click may invoke a Pan. specifying the X coordinate of the current mouse position. specifying the Y coordinate of the current mouse position. Y A value of single data type. which occurs when the user moves the mouse pointers over the Map control. Y As Single) The MouseMove event syntax has these parts: Part Description object An object expression that evaluates to a Map control. DblClick Event. ProgrammersReference. KeyPress Event. For example. KeyDown Event. LostFocus Event. 10:00 AM . mouse button is currently pressed. as described in Values. in control units. Values The value of button evaluates to a Visual Basic constant. MouseMove Event MouseMove Event Applies To Map Object Description The MouseMove event is a standard ActiveX control event. Syntax Private Sub object_MouseMove(Button As Integer. double-click or click-drag on the Map control. shift An integer specifying the status of the Shift key. Shift As Integer. in control units. By using the MouseDown or MouseUp event in conjunction with the ToMapPoint method. MapObjects Programmer’s Reference 369 vbCtrlMask 2 The CTRL key is pressed vbAltMask 4 The ALT key is pressed Remarks The MouseDown event can be used for intercepting every click. a Point can be created at the location where the user clicked on the Map.pmd 369 10/28/2004. See Also Click Event. X A value of single data type. if any. in map units. button An integer specifying with which. a left-click may invoke a TrackRectangle and which sets a new Map Extent. as described in Values. See Also Click Event. KeyDown Event. moCross 2 Cross hair. or flash information about the location in the application. moIbeam 3 I beam. (Available on Windows NT only) moSizePointer 5 Size. DblClick Event. By using the MouseMove event in conjunction with the ToMapPoint method. and may have the following values.pmd 370 10/28/2004. in Map units. 10:00 AM . 370 MapObjects Programmer’s Reference Constant Value Description vbLeftButton 1 The left mouse button is pressed vbRightButton 2 The right mouse button is pressed vbMiddleButton 4 The middle mouse button is pressed The value of shift evaluates to a Visual Basic constant. Constant Value Description moDefault 0 Default cursor. For example. ProgrammersReference. a Point object can store the current location of the mouse pointer. Constant Value Description vbShiftMask 1 The SHIFT key is pressed vbCtrlMask 2 The CTRL key is pressed vbAltMask 4 The ALT key is pressed Remarks The MouseMove event can be used for tracking the current location of the mousepointer. moIconPointer 4 Icon. moving the pointer over a particular country may highlight that country. KeyPress Event. MouseDown Event MousePointer Constants MapObjects defines the following color constants for use with the Map object’s MousePointer property. moArrow 1 Arrow. LostFocus Event. SW.pmd 371 10/28/2004. ProgrammersReference. moHourglass 11 Hourglass. moArrowQuestion 14 Arrow and question mark. moSizeAll 15 Size all. 10:00 AM . moSizeNWSE 8 Size NW. S. SE. moNoDrop 12 No drop. moZoom 50 Zoom moZoomIn 51 Zoom in moZoomOut 52 Zoom out moPan 53 Pan moPanning 54 Panning moIdentify 55 Identify moLabel 56 Label moHotLink 57 Hot Link moPencil 58 Pencil See Also MousePointer Property 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. moSizeNS 7 Size N. MapObjects Programmer’s Reference 371 moSizeNESW 6 Size NE. moSizeWE 9 Size W. E. moArrowHourglass 13 Arrow and hourglass. moUpArrow 10 Up arrow. 10:00 AM . Y As Single) If Button = vbRightButton Then Map1. value An integer specifying the type of mouse pointer displayed.MousePointer = moZoom End Sub Private Sub Map1_MouseDown(Button As Integer. X _ As Single. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer.pmd 372 10/28/2004.MousePointer [= value] The MousePointer property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Option Explicit Private Sub Form_Load() Map1. Hold down the left mouse button and drag a rectangle to zoom in on the Map. depending on whether you’re zooming in on the map or panning.Pan Map1. Shift As Integer.MousePointer = moPan Map1. 372 MapObjects Programmer’s Reference Syntax object.Extent = Map1. To try this example. ProgrammersReference. as described in Settings. Hold down the right mouse button to pan the map. Settings The settings for value are MousePointerConstants: See Also MousePointerConstants Example This example uses the MousePointer property to set the cursor that appears on the map.MousePointer = moZoom Else Map1. and then press F5.TrackRectangle End If End Sub Move Method Applies To GeoEvent Object Description Moves a GeoEvent object relative to its current location on the TrackingLayer. Outline = True . 10:00 AM .1). deltaX The horizontal distance in map units to move the GeoEvent relative to its original location.Width * 0.Event(.Extent.Move Map1.Color = moRed . 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.Move deltaX. MapObjects Programmer’s Reference 373 Syntax object.pmd 373 10/28/2004.SymbolType = moPointSymbol .EventCount > 0 Then . _ Map1.OutlineColor = moMaroon ProgrammersReference. deltaY The vertical distance in map units to move the GeoEvent relative to its original location.1.EventCount .Extent. To try this example.Style = moTriangleMarker .TrackingLayer If . See Also FindEvent Method.1 End If End With End Sub Private Sub Form_Load() Command1.Caption = “Move” With Map1. Option Explicit Private Sub Command1_Click() With Map1.TrackingLayer. Add one or more GeoEvent objects to the Map’s TrackingLayer by clicking on the Map and then click Command1 repeatedly. Remarks When you apply the Move method to a GeoEvent.Height * 0.Symbol(0) . MoveTo Method 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. deltaY The Move method syntax has these parts: Part Description object An object expression that evaluates to a GeoEvent object. the TrackingLayer will redraw. EOF Map1. Shift As Integer. Press F5 and then click Command1.ToMapPoint(x.MoveFirst Do While Not recset.MoveFirst The MoveFirst method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object.pmd 374 10/28/2004. 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. y As Single) Dim oPoint As MapObjects2. To try this example.Records recset.Value.TrackingLayer. Syntax object.FlashShape recset. 0 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.Size = 10 End With End Sub Private Sub Map1_MouseDown(Button As Integer. 3 recset.Point Set oPoint = Map1.AddEvent oPoint. MovePrevious Method Example This example uses the MoveFirst method to return to the first record of a Recordset. Option Explicit Dim recset As MapObjects2.Layers(0). x _ As Single. y) Map1.MoveNext ProgrammersReference.Fields(“shape”). See Also MoveNext Method. 374 MapObjects Programmer’s Reference . 10:00 AM .Recordset Private Sub Command1_Click() Set recset = Map1. paste the code into the Declarations section of a form containing two ComboBox controls named Combo1 and Combo2.Fields(“shape”). To try this example.Value.FlashShape recset. 3 recset. Remarks Once the EOF property becomes True. MapObjects Programmer’s Reference 375 Loop recset. 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.Records.pmd 375 10/28/2004. Option Explicit Private Sub Form_Load() Dim f As MapObjects2.FlashShape recset.MovePrevious Map1.Fields(“shape”). successive calls to MoveNext may reference invalid records. See Also MoveFirst Method.Layers(0).Name ProgrammersReference.MoveNext The MoveNext method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object. a ListView control named ListView1.Field For Each f In Map1. and a Map named Map1 that has at least one MapLayer. MovePrevious Method Example This example uses the MoveNext Method to advance through all the records of a MapLayer’s Recordset in order to create a report in a ListView control.Fields If f. 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.AddItem f. The code also uses the EOF property to test whether the end of the Recordset has been reached. The ListView will display the results.MoveFirst Map1. Syntax object.Type = moString Then Combo1. Do not call the MoveNext method when EOF is True.Value. 10:00 AM . _ Add(.Name End If End If Next f End Sub Private Sub Combo2_Click() If Combo1.ListIndex <> -1 Then ‘initialize ListView1.pmd 376 10/28/2004. Combo1.SubItems(1) = .List(Combo2.Recordset Loop End With ProgrammersReference.Type < 21 Then ‘rule out shape fields Combo2. Dim itmX As ListItem ‘set the appearance of the ListItem objects ListView1.Clear ‘ Create an object variable for the ColumnHeader object.Records Do While Not .ListItems.Value) ‘second field’s set of values itmX.Fields(Combo1.ListIndex)) With Map1.ValueAsString .Layers(0). 10:00 AM .Clear ListView1.List(Combo1.ListIndex)).AddItem f.ColumnHeaders.Fields(Combo2. .List _ (Combo2. . _ Add(.EOF ‘first field’s set of values Set itmX = ListView1. .ListIndex)).List(Combo1. Dim clmX As ColumnHeader ‘ Create a variable to add ListItem objects.ColumnHeaders. . 376 MapObjects Programmer’s Reference Else If f. _ Add(.MoveNext ‘advance through the MapObjects2.ColumnHeaders. Combo2.ListIndex)) ‘this field contains values Set clmX = ListView1.ListItems.View = lvwReport ‘this string field’s values distinguish the features from each other Set clmX = ListView1. MoveFirst Method Example This example uses the MovePrevious Method to set the current record of a MapLayer object’s Recordset. rec1 As Variant. Press F5 and then choose a field name in Combo1.Recordset Dim fld As MapObjects2.Type = moString Then Combo1.Records. A MsgBox displays the field values of each of records. Remarks MovePrevious should only be used on a full base Recordset.Field For Each f In Map1. Option Explicit Private Sub Form_Load() Dim f As MapObjects2.AddItem f.Layers(0). MovePrevious is not supported by SDE layers.Name End If Next f End Sub Private Sub Combo1_Click() Dim recset As MapObjects2. _ ProgrammersReference. To try this example. VPF files or CAD files. ARC/INFO coverage. Syntax object.Field. the first and the last should match. one that references an unfiltered shapefile. See Also MoveNext Method.Fields If f. 10:00 AM . Three strings display. i.e. The code uses the MoveNext Method to move to the record after the first record and then goes back one record.pmd 377 10/28/2004. 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. rec As Variant.MovePrevious The MovePrevious method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object. MapObjects Programmer’s Reference 377 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. value2 The MoveTo method syntax has the following parts: Part Description object An object expression that evaluates to an object in the Applies To list. For a GeoEvent: The new horizontal location in map units of the GeoEvent. If you have changed the order of layers in the Map’s Layers collection you should refresh the Map to see the result of the change.MoveTo value1. Layers Collection Description Moves a member of a Layers collection from its current index position to a new index position. “ & rec2 & “.MoveNext rec2 = fld recset. the TrackingLayer will redraw.ListIndex)) rec1 = fld ‘Value is the default property recset. Syntax object. or moves a GeoEvent to a new location on the TrackingLayer. 378 MapObjects Programmer’s Reference rec2 As Variant Set recset = Map1. value1 For a Layers collection: A numeric expression that evaluates to the current index position in the collection.Records Set fld = recset(Combo1.MovePrevious ‘back up one record rec = fld MsgBox rec1 & “. Remarks When you apply the MoveTo method to a GeoEvent.Layers(0).pmd 378 10/28/2004. See Also Move Method ProgrammersReference. value2 For a Layers collection: A numeric expression that evaluates to the target index position in the collection.List(Combo1. “ & rec Set fld = Nothing ‘disassociate object variable End Sub MoveTo Method Applies To GeoEvent Object. 10:00 AM . For a GeoEvent: The new vertical location in map units of the GeoEvent. Event(.Center.y End If End With Command1.MoveTo Map1. _ Map1.AddEvent oPoint.Extent. To try this example.Caption = “Move to Center” End Sub Private Sub Map1_MouseDown(Button As Integer.ToMapPoint(x. Shift As Integer.x. 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.EventCount > 0 Then . x _ As Single.TrackingLayer If .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.Enabled = False End Sub Private Sub Form_Load() Command1.1).Extent.Enabled = False Command1. y As Single) Dim oPoint As MapObjects2. Add one or more GeoEvent objects to the Map’s TrackingLayer by clicking on the Map and then click Command1. 0 Command1. Syntax object.MoveToBottom index The MoveToBottom method syntax has the following object qualifier and parts: ProgrammersReference.Point Set oPoint = Map1. 10:00 AM . MapObjects Programmer’s Reference 379 Example This example uses the MoveTo method to perform an absolute move of the most recently added GeoEvent to the center of the map.TrackingLayer.Center. Option Explicit Private Sub Command1_Click() With Map1. y) Map1.pmd 379 10/28/2004.EventCount . 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.AddItem oLayer.MoveToBottom List1.Layers List1. MoveTo Method Example This example uses the MoveToBottom method to move a MapLayer or ImageLayer to the bottom-most position in the Layers collection. 380 MapObjects Programmer’s Reference Part Description object Required.ListIndex List1. 10:00 AM . A numeric expression that evaluates to the current Index position in the collection. An object expression that evaluates to an object in the Applies To list.Layers. Option Explicit Private Sub List1_Click() Map1.pmd 380 10/28/2004. To try this example.Clear ListLayers Map1.Refresh End Sub Private Sub Form_Load() ListLayers End Sub Private Sub ListLayers() Dim oLayer As Object ‘declared as Object to handle both ‘MapLayers and ImageLayers For Each oLayer In Map1. the layer at the bottom is the first layer to draw. index Required.Name Next End Sub MoveToTop Method Applies To Layers Collection ProgrammersReference. drawing the item first. See Also MoveToTop Method. Remarks The layer at the top is the last layer to draw. Clear ListLayers Map1. The code moves the item to the top of the list and redraws the Map. 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. A numeric expression that evaluates to the current index position in the collection.Name Next End Sub ProgrammersReference. MoveTo Method Example This example uses the MoveToTop method to move a MapLayer or ImageLayer to the topmost position in the Layers collection.MoveToTop index The MoveToTop method syntax has the following object qualifier and parts: Part Description object Required. MapObjects Programmer’s Reference 381 Description Moves a member of a Layers collection from its current Index position to the first Index position in the collection. the layer at the bottom is the first layer to draw. index Required. To try this example. See Also MoveToBottom Method.Layers. drawing the item last.AddItem oLayer. Syntax object.Layers List1.MoveToTop List1. Remarks The layer at the top is the last layer to draw.pmd 381 10/28/2004.Refresh End Sub Private Sub Form_Load() ListLayers End Sub Private Sub ListLayers() Dim oLayer As Object ‘declared as Object to handle both ‘MapLayers and ImageLayers For Each oLayer In Map1.ListIndex List1. 10:00 AM . Option Explicit Private Sub List1_Click() Map1. An object expression that evaluates to an object in the Applies To list. three ListBoxes named List1.pmd 382 10/28/2004. Label2 and Label3.ToMapPoint(X. See Also Point Object. Measure Property Example This example makes use of the SetMeasuresAsLength and MultiplyMeasures methods to set and multiply the measures on a user-selected line segment. Null measures are represented by ‘no data’ values. _ ToMapDistance(150). Remarks Null measure values will not be updated.Point Dim recs As New MapObjects2. Y As Single) ‘ convert x and y to a map point Dim pt As MapObjects2. Syntax object.MultiplyMeasures factor The MultiplyMeasures method syntax has these parts: Part Description object An object expression that evaluates to a Line object. and report on those measures. 10:00 AM . “”) ProgrammersReference. copy the code into the Declarations section of a Form that contains a Map named Map1 with a MapLayer containing line features. and three Labels above the lists named Label1. Option Explicit Private Sub Form_Load() Label1. X _ As Single. Press F5 and click on a line. Shift As Integer.Caption = “Measures Set As Length” Label3. factor A numeric expression that represents the amount by which each measure value is to be multiplied. List2 and List3.Layers(0).Caption = “Measures” Label2.Caption = “Measures Multiplied by 3” End Sub Private Sub Map1_MouseDown(Button As Integer. To try this example. Y) Set recs = Map1.SearchByDistance(pt. 382 MapObjects Programmer’s Reference MultiplyMeasures Method Applies To Line Object Description Multiplies the measure value of each vertex on a Line object by a factor.Recordset Set pt = Map1. Map1. GeoTransformation Object.Points Dim i As Integer For Each theParts In gLine.Measure Next i Next theParts gLine.AddItem theParts(i).AddItem theParts(i). 10:00 AM .Value List1.Clear List3.Count .Parts For i = 0 To theParts.Count .MultiplyMeasures 3 For Each theParts In gLine.1 List3. ProjCoordSys Object.AddItem theParts(i).SetMeasuresAsLength For Each theParts In gLine.Clear List2. Unit Object ProgrammersReference. MapLayer Object.Line Set gLine = recs(“Shape”). PrimeMeridian Object.1 List2.pmd 383 10/28/2004.1 List1. MapObjects Programmer’s Reference 383 ‘ if a line is found. set measures and populate listboxes with measures and ‘offset measures If Not recs. Table Object.Clear Dim theParts As New MapObjects2. Field Object. Spheroid Object. GeoDataset Object.Parts For i = 0 To theParts.EOF Then Dim gLine As New MapObjects2. Projection Object. GeoCoordSys Object.Measure Next i Next theParts gLine. extract the shape and store it in gLine ‘variable.Count . Map Object.Measure Next i Next theParts End If End Sub Name Property Applies To Datum Object.Parts For i = 0 To theParts. ImageLayer Object. Field.NoNullValue ProgrammersReference. Syntax object. Field.name Next End Sub NoNullValue Method Applies To ChartRenderer Object Description Cancels the Null value of the ChartRenderer object.Records. The Name property of GeoDataset. for example. The property is read-only for GeoDataset. (Data type is String. 10:00 AM .Fields List1.AddItem oField.Name [= value] The Name property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Type Property Example This example uses the Name property to populate a ListBox with the names of the fields of the Recordset associated with a MapLayer. See Also FieldName Property. GeoCoordSys. Press F5. GeoTransformation. a dBASE file on disk. and Table objects has restrictions that are dependent on the data base in which they reside.Layers(0).Field For Each oField In Map1. ProjCoordSys and Projection objects.pmd 384 10/28/2004. Syntax object. make sure that it does not have an extension. To try this example. value A string expression that specifies a name. 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. 384 MapObjects Programmer’s Reference Description Returns or sets a user-defined name for an object.) Remarks Note that if a Name of a Table object is file-based. Option Explicit Private Sub Form_Load() Dim oField As MapObjects2. No restrictions exist on the Name Property of a Layer or a Map. Caption = “Set a Null Value” .FieldCount = 2 ProgrammersReference. When it encounters data that has this value. See Also NullValue Property Example This example illustrates how to use the ChartRenderer property and method that handle null values.NullValue = 0 ‘arbitary null value: State FIPS code for New York ‘as well as County FIPS code for several counties Map1. 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. Remarks Use NoNullValue after you’ve set the NullValue property to signify that you no longer want the ChartRenderer to treat a specified value as the Null value. Some- times your feature data may have a value that represents that data was not available. MapObjects Programmer’s Reference 385 The object placeholder is an object expression that evaluates to an object in the Applies To list.NoNullValue Map1. Normally.Refresh End If End Sub Private Sub Form_Load() With Check1 .ChartType = moPie . This is for illustration purposes only.MinPieSize = 15 . Option Explicit Dim cr As New MapObjects2. in which case it may be more appropriate to specify a null data value.MaxPieSize = 30 .Refresh ElseIf Check1. 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.pmd 385 10/28/2004.Value = vbChecked Then cr.ChartRenderer Private Sub Check1_Click() If Check1. you’ll use the ChartRenderer to compare more meaningful numeric values associated with features.Value = vbChecked End With With cr . You can specify a value that the ChartRenderer should treat as a null value.Value = vbUnchecked Then cr. 10:00 AM . To try this example. NormalizationField [= value] The NormalizationField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Color(1) = moGreen End With Set Map1.Renderer = cr End Sub Private Sub Map1_MouseDown(Button As Integer. if profit and loss were recorded for different countries in local currency. the value in the NormalizationField will be divided into the value of each field before the chart is displayed.SizeField = “POP1990” . value A string expression that specifies a name of a field in a Recordset of the MapLayer associated with the ChartRenderer. y As Single) If Button = 1 Then Map1.Color(0) = moRed .Field(0) = “MALES” .Layers(0). 386 MapObjects Programmer’s Reference .Pan End If End Sub NormalizationField Property Applies To ChartRenderer Object Description Returns or sets the field which will be used to normalize bar charts.pmd 386 10/28/2004.Field(1) = “FEMALES” ‘“MALES” . x _ As Single. 10:00 AM . they could be converted into a common currency by the ChartRenderer by supply- ing an exchange rate in the NormalizationField for each country. Remarks If set. Syntax object. For example. Shift As Integer.TrackRectangle Else Map1.Extent = Map1. See Also SizeField Property ProgrammersReference. This property can be used to bring records in different units into a common unit. Offset deltaX. Points Object Description Moves an object by a specified Offset horizontally and vertically. 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. Line Object. Syntax object. MapObjects Programmer’s Reference 387 NullValue Property Applies To ChartRenderer Object Description Returns or sets the value which signifies a Null value in the features Field attribute.pmd 387 10/28/2004. If a Field contains an actual null value. then the individual slice of pie. you must use the NoNullValue method to signify that you no longer want the ChartRenderer to treat a specified value as the Null value. Syntax object.NullValue [= value] The NormalizationField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 10:00 AM . ProgrammersReference. will be rendered with a value of zero. deltaY The Offset method syntax has these parts: Part Description object An object expression evaluates to an object in the Applies To list. See Also NoNullValue Property Example See NoNullValue Property Offset Method Applies To Ellipse Object. Rectangle Object. Once you’ve set the NullValue property. or bar. Polygon Object. indicating that no Offset distance is added to the AddressLocation.1 fDeltaY = Map1. Remarks The Offset property sets the distance in map units.1 oRectangle.Rectangle Private Sub Command1_Click() Dim fDeltaX.Extent. 10:00 AM .pmd 388 10/28/2004. then click Command1. deltaY The distance in map units to move the object vertically. Union Method.Extent fDeltaX = Map1.Extent oRectangle.ScaleRectangle (0.75) Map1.Width * 0. 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. and the geocoded location will be placed on top of the centerline. Intersect Method. Negative values move the object down. Press F5.Extent. Difference Method. Option Explicit Dim oRectangle As MapObjects2. XOr Method Example This example uses the Offset method to shift a Map by moving its Extent property.Extent = oRectangle End Sub Private Sub Form_Load() Set oRectangle = Map1. The default Offset distance is 0. See Also Buffer Method. fDeltaY Map1.Extent = oRectangle End Sub Offset Property Applies To Geocoder Object ProgrammersReference. Negative values move the object to the left.Offset fDeltaX. therefore if you wish to offset based on device units. fDeltaY As Double Set oRectangle = Map1. 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. 388 MapObjects Programmer’s Reference deltaX The distance in map units to move the object horizontally.Height * 0. Syntax object. The left and right house number match variables in the StreetTable determine the direction of the offset. The default offset distance is 0.Offset [= distance] The Offset property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. A function called GetDegree is provided for converting the value in feet into decimal degrees. AddressLocation Object Example This example demonstrates the effects of setting the Offset and SqueezeFactor properties of a Geocoder on a geocoded point location. Option Explicit Private geo As New MapObjects2. 10:00 AM .Geocoder Private stan As New MapObjects2. Use the offset property when adding AddressLocations to a Map. Text2. MapObjects Programmer’s Reference 389 Description Returns or sets a value in map units that represents the perpendicular distance from the street centerline to offset a matched AddressLocation. a CommandButton named Com- mand1. (Data type is Double.Point Private Const DIST_ZoomRadius = 0. and see the differences of the geocoded point location. paste the code into the Declara- tions section of a form that contains a Map named Map1.Standardizer Private m_offset As Double Private m_squeeze As Double Private pntLoc As MapObjects2. See Also SqueezeFactor Property. To try this example. Try different values of offset distance and squeeze factor in Text3 and Text4. Note that this example assumes the map units of the reference StreetTable is in decmial degrees and the input offset distance is in feet. four TextBoxes named Text1. Text3 and Text4. set it with an empty string Private Const m_FromLeft = “L_f_add” ProgrammersReference.pmd 389 10/28/2004. so that the AddressLocations on either side of the street can be distinguished from each other. and two Labels named Label1 and Label2.) Remarks This property applies to a Geocoder only if the Geocoder’s StreetTable contains left and right house number match variables.001 ‘in decimal degrees ‘Set global variables with field names in the StreetTable ‘Modify if fields names in StreetTable are different ‘If a field is not available. Substitute appropriate values for the data paths and then press F5. distance A numeric expression that represents the perpendicular distance from the street centerline to offset the matched address location. 10:00 AM . 25. 65. 85. 50. 95.34. 60. 90) arrayFeet = Array(101. lat As Double) As Double ‘Converts the value in feet into degree Dim arrayLat Dim arrayFeet Dim i As Integer Dim lowLat As Double Dim highLat As Double Dim lowFeet As Double Dim highFeet As Double Dim FeetPerSecond As Double Dim outputDegree As Double arrayLat = Array(0. 87. _ 26. 77. 70. 10.85.1) highFeet = arrayFeet(i) FeetPerSecond = (highFeet . 80.86. 65. 75.1) highLat = arrayLat(i) lowFeet = arrayFeet(i . 58.8.32. _ 83. 101. 17. For i = 0 To 18 If arrayLat(i) > lat Then lowLat = arrayLat(i . 40. 34.02. 35.2. 390 MapObjects Programmer’s Reference Private Const m_FromRight = “R_f_add” Private Const m_ToLeft = “L_t_add” Private Const m_ToRight = “R_t_add” Private Const m_PreDir = “Prefix” Private Const m_PreType = “Pre_type” Private Const m_StreetName = “Name” Private Const m_StreetType = “Type” Private Const m_SufDir = “Suffix” Private Const m_LeftZone = “Zipl” Private Const m_RightZone = “ZipR” Private Function GetDegree(dist As Variant. 98.pmd 390 10/28/2004.92.07. 45. 0) ‘ Finding out the feet per second of longitude at the given ‘latitude. 8.lowFeet) * (lat .87.34.lowLat) _ / (highLat . 92.83.68. 5. 30.99. 99.45. 50. 42. 20. _ 55.37.lowLat) + lowFeet Exit For ElseIf arrayLat(i) = lat Then ProgrammersReference. 71. 15.93. MapObjects Programmer’s Reference 391 FeetPerSecond = arrayFeet(i) Exit For End If Next ‘ Get the degrees outputDegree = dist / FeetPerSecond / 3600 GetDegree = outputDegree End Function Private Sub Command1_Click() ‘Locate an address to its best candidate Dim foundLoc As MapObjects2.Offset = 0 geo.Top = pntLoc.pmd 391 10/28/2004.Offset = deg Set foundLoc = geo. latitude) of the point ‘ location ‘ Set the offset distance property of the geocoder and recalculate ‘ the point location deg = GetDegree(CDbl(m_offset).Bottom = pntLoc.Y .AddressLocation Dim deg As Double Dim r As New MapObjects2.Rectangle If stan.FieldValue(“ZN”) = Text2.Y) geo.StandardizeAddress(Text1.GenerateCandidates If geo.CandidateCount > 0 Then geo.Text geo.location If m_offset <> 0 Then ‘ Distance of a longitude unit differs given a latitude. 10:00 AM .SqueezeFactor = m_squeeze Set foundLoc = geo. ‘ Converts the offset value in feet to decimal degrees with the ‘ consideration of the y value (i.DIST_ZoomRadius r.e.Text) Then stan.location End If ‘ Set new extent for the map r.Y + DIST_ZoomRadius ProgrammersReference.LocateCandidate(0) Set pntLoc = foundLoc.LocateCandidate(0) Set pntLoc = foundLoc. pntLoc. X.Symbol. 10:00 AM .StreetTable = gd ‘Set up the match rules and variables geo.Add lyr geo.GeoDataset = gd lyr.connected error” End End If ‘Set up the StreetTable Set gd = dc.Y Map1.Color = moBlue Map1.Left = pntLoc.stn” geo.StandardizingRules = “C:\Program Files\ _ ESRI\MapObjects2\GeoRules\us_addr.mat” geo.FindGeoDataset(“redlands”) lyr.Standardizer = stan dc.Right = pntLoc.MatchRules = “C:\Program Files\ _ ESRI\MapObjects2\GeoRules\us_addr1.IntersectionStandardizingRules = “C:\ _ Program Files\ESRI\MapObjects2\GeoRules\us_intsc.Connect If Not dc.Extent = r Map1.X + DIST_ZoomRadius Map1. 392 MapObjects Programmer’s Reference r.pmd 392 10/28/2004. i As Integer Dim name As String ‘Set up Standardizer stan.DIST_ZoomRadius r. pntLoc.Connected Then MsgBox “dc.Layers.Database = “C:\Program Files\ _ ESRI\MapObjects2\Samples\Data\Redlands” dc.DataConnection Dim gd As Object Dim lyr As New MapLayer Dim f.Enabled = True End If End If End Sub Private Sub Form_Load() Dim dc As New MapObjects2.CenterAt pntLoc.stn” stan.X .IntersectionMatchRules = “C:\Program Files _ ProgrammersReference. mgLinkPrimary) _ = “SufDir1” geo.MatchVariableIntersectionLink(“StreetType”.MatchVariableField(“StreetType”) = m_StreetType geo.MatchVariableField(“SufDir”) = m_SufDir geo.MatchVariableIntersectionLink(“PreType”. mgLinkSecondary) _ = “SufDir2” geo.mat” ‘ Link the Match Variables to fields in the StreetTable geo.MatchVariableIntersectionLink(“PreDir”.MatchVariableIntersectionLink(“PreDir”. mgLinkPrimary) = “PreDir1” geo.MatchVariableIntersectionLink(“StreetName”.MatchVariableIntersectionLink(“LeftZone”. mgLinkSecondary) _ = “StreetName2” geo.MatchVariableIntersectionLink(“SufDir”.MatchVariableIntersectionLink(“StreetType”.MatchVariableField(“ToRight”) = m_ToRight geo.MatchVariableIntersectionLink(“RightZone”. mgLinkSecondary) _ = “StreetType2” geo.MatchVariableField(“RightZone”) = m_RightZone ‘ Link the intersection group 1 variables geo.MatchVariableField(“StreetName”) = m_StreetName geo. 10:00 AM . mgLinkSecondary) _ = “RightZone2” ProgrammersReference.MatchVariableIntersectionLink(“PreType”. mgLinkSecondary) _ = “PreType2” geo. mgLinkPrimary) _ = “StreetName1” geo.MatchVariableField(“LeftZone”) = m_LeftZone geo.MatchVariableField(“PreDir”) = m_PreDir geo. mgLinkSecondary) _ = “PreDir2” geo.MatchVariableField(“FromLeft”) = m_FromLeft geo. mgLinkPrimary) _ = “RightZone1” ‘ Link up intersection group 2 variables geo.MatchVariableField(“FromRight”) = m_FromRight geo. mgLinkPrimary) _ = “PreType1” geo. mgLinkPrimary) _ = “StreetType1” geo.MatchVariableField(“ToLeft”) = m_ToLeft geo.MatchVariableIntersectionLink(“StreetName”.MatchVariableField(“PreType”) = m_PreType geo.MatchVariableIntersectionLink(“RightZone”.pmd 393 10/28/2004. mgLinkPrimary) _ = “LeftZone1” geo. MapObjects Programmer’s Reference 393 \ESRI\MapObjects2\GeoRules\us_intsc1. mgLinkSecondary) _ = “LeftZone2” geo.MatchVariableIntersectionLink(“SufDir”.MatchVariableIntersectionLink(“LeftZone”. vbCritical End End If If Not geo. vbCritical End End If If Not geo.OLE_HANDLE) Dim addSym As New MapObjects2.mgIndexExists Then If Not geo.Text = “200 Cajon St” Text2. 10:00 AM .Caption = “Offset Distance in feet” Label2.Caption = “Squeeze Factor in %” Text3. m_RightZone.Add “SN?” Set geo. “”.0” End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.”.Add “SN? & ZN” queries.Style = moCircleMarker addSym.SearchQueries = queries Command1.IndexStatus = MapObjects2. mgIndexTypeNormal) Then MsgBox “Cannot build geocoding index.Text = “92373” Label1.pmd 394 10/28/2004.Caption = “Locate Address” Text1.BuildIndices(True) Then MsgBox “Cannot build geocoding index.”.Color = moGreen addSym. mgIndexTypeSoundex) Then MsgBox “Cannot build geocoding index. 394 MapObjects Programmer’s Reference ‘Build indices if haven’t If Not geo.Text = “50” Text4.SymbolType = moPointSymbol addSym.AddIndex(m_LeftZone.Strings queries.Size = 8 ProgrammersReference.Symbol addSym.IndexStatusConstants _ . vbCritical End Else MsgBox “Indices are built.” End If End If ‘Set search queries Dim queries As New MapObjects2.AddIndex(m_StreetName.”.Text = “5. Measure Property Example This example makes use of the SetMeasures and OffsetMeasures methods to report on. Remarks Null measure values will not be updated. and to set and offset measures on a user-selected line segment. To try this example. See Also Point Object. addSym End If End Sub Private Sub Text3_Change() If IsNumeric(Text3.OffsetMeasures value The OffsetMeasures method syntax has these parts: Part Description object An object expression that evaluates to a Line object.DrawShape pntLoc. List 2 and List3.Text) Then m_offset = CDbl(Text3. and three Labels above them named Label1. value A numeric expression that represents the amount by which the measures should be offset. Option Explicit ProgrammersReference. Syntax object. MapObjects Programmer’s Reference 395 If Not pntLoc Is Nothing Then Map1. Press F5 and click on a line. Null measures are represented by ‘no data’ values. Label2 and Label3.Text) End If End Sub Private Sub Text4_Change() If IsNumeric(Text4. three ListBoxes named List1. copy the code into the Declarations section of a Form that contains a Map named Map1 with a MapLayer containing line features.pmd 395 10/28/2004. 10:00 AM .Text) Then m_squeeze = CDbl(Text4.Text) End If 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. 1 List2. Map1.AddItem vertices(i).pmd 396 10/28/2004. “”) ‘ if a line is found.Points Dim i As Integer For Each vertices In oLine.Point Dim recs As New MapObjects2.Recordset Set pt = Map1. 396 MapObjects Programmer’s Reference Private Sub Form_Load() Label1.Measure Next i Next vertices oLine.SetMeasures 0.Parts For i = 0 To vertices.Caption = “Measures Set from 0 to 100” Label3. X As _ Single.Parts For i = 0 To vertices. Y) Set recs = Map1.SearchByDistance(pt.Line Set oLine = recs(“Shape”).Clear Dim vertices As New MapObjects2. 100 For Each vertices In oLine.Caption = “Measures Offset by 50” End Sub Private Sub Map1_MouseDown(Button As Integer.Count .1 List1.Clear List3. Y As Single) ‘convert x and y to a map point Dim pt As MapObjects2. set measures and populate listboxes with measures ‘ and offset measures If Not recs.Measure Next i Next vertices ProgrammersReference. Shift As Integer.Layers(0).Value List1.Caption = “Measures” Label2.Count .AddItem vertices(i).EOF Then Dim oLine As New MapObjects2. 10:00 AM .Clear List2. extract the shape and store it in oLine ‘ variable.ToMapPoint(X. _ ToMapDistance(150). PrintMap Method Example This example uses the OutputMap method to render the visible extent of a Map to the speci- fied device context.Parts For i = 0 To vertices. and then press F5. click Command1. 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. then these too will not be visible. ExportMap Method. Remarks OutputMap does not support VisibleRegion or Transparent properties.AddItem vertices(i).OffsetMeasures 50 For Each vertices In oLine.OutputMap Printer. OutputMap2 Method.Count . any ImageLayers in the Map control’s Layers collection will not be visible. See Also CopyMap Method. To try this example. If any ImageLayers in the Map control’s Layers collection have their Transparent property set to True. ExportMap2 Method. If RotationAngle is not zero.hDC Printer.OutputMap hDC The OutputMap method syntax has the following parts: Part Description object An object expression that evaluates to an object in the Applies To list.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. Syntax object. MapObjects Programmer’s Reference 397 oLine. Option Explicit Private Sub Command1_Click() Printer. hDC A numeric expression that evaluates to a device context. The code sends the Map to the Printer.EndDoc ProgrammersReference. 10:00 AM .pmd 397 10/28/2004.Print Map1.1 List3. you may specify that the background rectangle of the map not be drawn by setting the drawBackground parameter to False. A value or constant which determines how the map is drawn on the destination hDC. Syntax object. width The width of the destination rectangle in device coordinates. height. moClipToExtent 2 OutputMap2 clips the output so that the resultant rendering will not be larger than the actual map extent. Optionally. [drawFlags] The OutputMap2 method syntax has the following parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 398 10/28/2004.OutputMap2 hDC. Given an arbitrary height and width. Settings The settings for drawFlags are: Constant Value Description moNoBackground 1 OutputMap2 will not draw the background rectangle. These flags may be combined to produce a desired behavior. this ProgrammersReference. 10:00 AM . and will not distort the geometry of the Map to fit the requested rectangle. y. 398 MapObjects Programmer’s Reference End Sub OutputMap2 Method Applies To Map Object Description Renders the visible extent of the Map to the specified device context. drawFlags Optional. y The Y coordinate of the upper left corner of the destination rectangle in device coordinates. x. as described in Settings. Remarks Note that MapObjects uses the target rectangle as a bounding guide. height The height of the destination rectangle in device coordinates. hDC A numeric expression that evaluates to a device context. x The X coordinate of the upper left corner of the destination rectangle in device coordinates. width. given a destination rectangle in device coordinates (pixels). then these too will not be visible. Map1. An appropriate technique is to supply rectangles whose relative proportions in height and width match those of the map’s actual extent.TwipsPerPixelY PixWidth = Printer. centering itself within the larger dimension.OutputMap2 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. ExportMap Method. and then press F5. 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. 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. PixWidth / 2. If RotationAngle is not zero.TwipsPerPixelX ‘ Render map to lower right quadrant of printer page.hDC. 10:00 AM .Outline [= boolean] The Outline property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. If any ImageLayers in the Map control’s Layers collection have their Transparent property set to True. To try this example. pixHeight / 2 Printer.ScaleWidth / Printer. The code sends the Map to the Printer.pmd 399 10/28/2004. Syntax object. OutputMap Method. OutputMap2 does not support VisibleRegion or Transparent properties.ScaleHeight / Printer. See Also CopyMap Method. ExportMap2 Method. Option Explicit Private Sub Command1_Click() Dim pixHeight As Long Dim PixWidth As Long Printer. pixHeight = Printer. MapObjects Programmer’s Reference 399 method will scale the Map so that it will fit which ever dimension is smallest. pixHeight / 2. _ PixWidth / 2. any ImageLayers in the Map control’s Layers collection will not be visible. ProgrammersReference.Print ‘ Convert page dimensions to pixels. click Command1. TrackingLayer.OLE_HANDLE) If poly Is Nothing Then Exit Sub Dim sym As New MapObjects2. 400 MapObjects Programmer’s Reference boolean A boolean expression specifying whether the object has an outline or not as indicated in Settings.DrawShape poly. Option Explicit Dim poly As MapObjects2.Value = 1 End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole. y As Single) ProgrammersReference. 10:00 AM . To try this example.Caption = “Outline” Check1.OutlineColor = moDarkGreen If Check1. Track a polygon on the Map and then use the CheckBox to toggle the polygon’s outline. False Object does not have an outline.Color = moPaleYellow sym.Value = 1 Then sym. x _ As Single. Settings The settings for boolean are: Setting Description True (Default) Object has an outline. sym End Sub Private Sub Map1_MouseDown(Button As Integer.Symbol sym.Outline = True Else sym. paste the code into the Declarations seciton of a form that has a Map named Map1 and a CheckBox named Check1.Refresh True End Sub Private Sub Form_Load() Check1.Polygon Private Sub Check1_Click() Map1.pmd 400 10/28/2004.Outline = False End If Map1. Shift As Integer. See Also OutlineColor Property Example This example uses the Outline property to control whether the Symbol used to display a Polygon object has an outline or not. press F5. paste the code into the Declarations section of a form containing a CommonDialog control.” End Sub ProgrammersReference.TrackPolygon Map1.TrackingLayer. Press F5 and click the button.Layers(0). Settings For more information on color settings. color A value or constant that determines the color of the outline of a symbol. See Also Outline Property Example This example uses the OutlineColor property to control the color of the border of the symbol used to render a MapLayer.. Option Explicit Private Sub Command1_Click() CommonDialog1. a CommandButton named Command1 and a Map named Map1 that contains one MapLayer with polygon features.OutlineColor = CommonDialog1. Make a selection from the Color dialog and click OK..OutlineColor [= color] The OutlineColor property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. To try this example. MapObjects Programmer’s Reference 401 Set poly = Map1.Refresh End Sub Private Sub Form_Load() Command1.Caption = “Outline Color. see the Color settings topic in the online help. Syntax object.Color Map1.pmd 401 10/28/2004.ShowColor Map1.Symbol.Refresh True End Sub OutlineColor Property Applies To Symbol Object Description Returns or sets the outline color of a Polygon object’s Symbol. 10:00 AM . If the user holds down the shift key. See Also CenterAt Method. Note that if the user hits <Esc> when you invoke a TrackRectangle method. When the user clicks on the map and drags. the TrackRectangle event rubberbands a rectangle.Rectangle Set Rectangle = Map1. Y As Single) If Shift = 0 Then Dim Rectangle As MapObjects2. X _ As Single.TrackRectangle If Not Rectangle Is Nothing Then Map1. 402 MapObjects Programmer’s Reference Pan Method Applies To Map Object Description Tracks the mouse while panning the Map. Option Explicit Private Sub Map1_MouseDown(Button As Integer. when the user releases the mouse. Offset Method Example The following example illustrates how to create a simple Pan and Zoom interface. Syntax object. the map zooms to the specified area. a value of Nothing is returned. and then press F5 and click and drag the mouse on the map.Extent = Rectangle Else Map1. 10:00 AM . ProgrammersReference.Pan The object placeholder is an object expression that evaluates to an object in the Applies To list. the map will be panned instead. Shift As Integer.pmd 402 10/28/2004. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. To try this example.Pan End If End Sub ParameterType Constants MapObjects defines the following constants for use with the GetParameter and SetParameter methods of the ProjCoordSys object. Lambda2 MapObjects defines the following constants for use with the GetParameter and SetParameter methods of the GeoTransformation object. Phi2 moParm_ScaleFactor 3093 Scale Factor. Y0 moParm_CentralMeridian 3088 Central Meridian. Lambda0 moParm_StandardParallel1 3078 Standard Parallel 1. 10:00 AM . Phi1 moParm_StandardParallel2 3079 Standard Parallel 2. MapObjects Programmer’s Reference 403 Constant Value Description moParm_FalseEasting 3082 False Easting. K0 moParm_CentralParallel 3089 Central Parallel.pmd 403 10/28/2004. Phi0 moParm_Azimuth 3094 Azimuth (Alpha) moParm_FirstPointLatitude 36081 Latitude of first point. Phi0 moParm_OriginLongitude 3080 Longitude of Origin. Lambda0 moParm_OriginLatitude 3081 Latitude of Origin. Lambda1 moParm_SecondPointLongitude 36084 Longitude of second point. X0 moParm_FalseNorthing 3083 False Northing. Phi1 moParm_SecondPointLatitude 36082 Latitude of second point. Constant Value Description moParm_DeltaX 36071 X-axis translation moParm_DeltaY 36072 Y-axis translation moParm_DeltaZ 36073 Z-axis translation moParm_RotationX 36074 Rotation X moParm_RotationY 36075 Rotation Y moParm_RotationZ 36076 Rotation Z moParm_DeltaScale 36077 Scale Factor ProgrammersReference. Phi2 moParm_FirstPointLongitude 36083 Longitude of first point. Count. This represents the vertices of the shape. Item. The Points objects returned from the Parts collection are direct references to the vertices of each part of the Line or Polygon feature. 404 MapObjects Programmer’s Reference The Rotation values are in decimal seconds.Y = pt. This means that you can directly change a Point representing an individual vertex. a “doughnut” Polygon has two Items in its Parts collection. You can then update the Value of the “ Shape “ Field for that record with the altered feature. one that represents its outer boundary. However.Y * factor pts.X + pt. and have a Parts collection containing a single Points object.Parts For i = 0 to pts. a Line object. your program should call the Edit method on the Recordset that contains the feature.Points For Each pts In myLine.Set i. whilst the Scale Factor is in parts per million (ppm). multi-part shapes are useful for representing multi-part features as single entities. 10:00 AM . ProjCoordSys Object. pt Next i Next pts At the end of this code. Any changes will be lost when myLine passes out of scope. The following Visual Basic example shows the vertices of myLine. and Remove.X * factor pt. and another that repre- sents the “hole”.X = pt. the myLine object has been changed but the underlying GeoDataset has not.1 Set pt = pts.Item(i) pt. The Parts collection supports the standard collection properties and methods: Add. such as the islands of Hawaii or a lake and its island as a “doughnut” Polygon.Count . GetParameter Method. Most Polygons or Lines are single part shapes.Point Dim pts As MapObjects2. See Also GeoTransformation Object. For example. ProgrammersReference. Dim i As Long Dim pt As MapObjects2. SetParameter Method Parts Collection A Parts collection holds the set of Points objects that make up the parts of a Polygon or Line object. as well as the Insert and Set methods to reposition elements of the collection.pmd 404 10/28/2004. are offset by a factor value.Y + pt. To make the changes persist. you must create a new Points object.Add myLine.pmd 405 10/28/2004. 10:00 AM . MapObjects Programmer’s Reference 405 If you wish to use a part from a Line or Polygon object as a new shape. Line Object Description Returns a reference to the collection of Parts in an object. Syntax Set variable = object.Points For i = 0 To myLine. ProgrammersReference.1 new_pts. then click a polygon feature on the Map. Recordset Object Parts Property Applies To Polygon Object. for example as a search shape.Parts(0). 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. object An object expression that evaluates to an object in the Applies To list.: Dim i As Long Dim new_pts As New MapObjects2.Item(i) Next I Properties Count Methods Add Item Remove Set Insert See Also Points Object.Parts The Parts property syntax has these parts: Part Description variable A variable that has been declared as a collection of Parts. To try this example. See Also Point Object Example This example uses the Parts property to list the points that constitute a Polygon object. Press F5.Count .g.Parts(0). and add each Point contained in the Points object returned from the Parts collection to this new object. e. Polygon List1.Parts ‘Parts is a collection of Points For Each oShapePoint In oPoints List1. y) Set oMapRecords = Map1.AddItem Str(oShapePoint.FlashShape oShape.x) & “.Clear Set oPoint = Map1. Table Object Description Returns or sets the User password for an SDE DataConnection or ODBC Table.Layers(0). x _ As Single.pmd 406 10/28/2004.y) & “. 406 MapObjects Programmer’s Reference Option Explicit Private Sub Map1_MouseDown(Button As Integer. 4 ‘flash clicked shape For Each oPoints In oShape.Password [= password] The Password property syntax has these parts: ProgrammersReference.” & Str _ (oShapePoint.Points Dim oMapRecords As MapObjects2. 10:00 AM .IsPointIn(oPoint) Then Exit Do End If oMapRecords.ToMapPoint(x.” & Str(oShapePoint.Point Dim oPoints As MapObjects2. Shift As Integer.Recordset Dim oShape As MapObjects2. Syntax object.EOF Set oShape = oMapRecords(“shape”).Z) Next oShapePoint Next oPoints End Sub Password Property Applies To DataConnection Object.MoveNext Loop Map1. y As Single) Dim oPoint As MapObjects2.Value If oShape.Records Do While Not oMapRecords.Point Dim oShapePoint As MapObjects2. Password = “arcfm” ‘“passwd” .Server = “oracle_server” ‘“serverX” . In the input box that appears. Connection error: #” _ & . MapObjects Programmer’s Reference 407 Part Description object An object expression that evaluates to an object in the Applies To list. “SDE”) . and a CommandButton named Command1.AddItem oGeoDataset. See Also User Property. paste the code into the Declarations section of a form containing a Map named Map1.MousePointer = vbHourglass ‘ update the values for Server.User = InputBox$(“Enter your user name:”. and User properties in making an SDE connection. Server.GeoDatasets List1. and Password ‘ for your particular SDE connection With oConnection . a ListBox named List1. Press F5 and click Command1 to connect to your SDE connection. 10:00 AM .ConnectError End If End With Screen. specify the name of the User. To try this example. Option Explicit Dim oConnection As New DataConnection Dim oGeoDataset As MapObjects2. Database.name Next oGeoDataset Else MsgBox “SdeConnect: Failed to connect.Database = “arcfm” ‘“DatabaseX” If oConnection.pmd 407 10/28/2004.Connect Then ‘ put the names of the sde layers into ‘ the listbox List1. Server Property Example This example demonstrates the role of the Password.Clear For Each oGeoDataset In .MousePointer = vbDefault End Sub ProgrammersReference. password A string expression that evaluates to a valid password for the database user specified in the object’s User property.GeoDataset Private Sub Command1_Click() Screen. Syntax object.pmd 408 10/28/2004.Perimeter The Perimeter property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Settings The settings for value are: Setting Description True The LabelPlacer will position the labels above the features. See Also Area Property. 10:00 AM . value A boolean expression that determines whether the LabelPlacer should position each label above the feature to which it corresponds.PlaceAbove [= value] The PlaceAbove property syntax has these parts: Part Description object An object expression that evaluates to a LabelPlacer. 408 MapObjects Programmer’s Reference Perimeter Property Applies To Polygon Object Description Returns the length of the perimeter of an object in map units. ProgrammersReference. as described in Settings. Syntax object. Centroid Property Example See Area Property PlaceAbove Property Applies To LabelPlacer Object Description Returns or sets a value indicating whether the LabelPlacer should place a label above the associated feature. Item(1).DefaultSymbol.Height + 40 Option1(I). For I = 1 To 2 ‘ Create more instances of Option1. See Also PlaceBelow Property.Item(0).Bold = True Set Map1. Option1(I).LabelPlacer Private Sub Form_Load() Dim fnt As New StdFont fnt. 10:00 AM .Renderer = lp With lp Set .Height = Map1.Caption = “Below” Option1.Caption = “Above” Option1.Value = True ProgrammersReference.Name = “Arial” fnt. Option Explicit Dim lp As New MapObjects2.Item(2). PlaceOn. To try this example. You may want to set the DefaultSymbol’s Height value to a value in MapUnits appropriate to your data. PlaceOn Property Example This example uses the PlaceAbove. For the OptionButton.Height / 25 ‘arbitrary map units .DefaultSymbol.Font = fnt . and then press F5. set its Index property to 0 in the Control Properties dialog box to create a control array of one element.UseDefault = True .pmd 409 10/28/2004. 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. You can click-drag a rectangle to zoom in to an area.FullExtent.Top = Option1(I .1).Item(0). Note that in some cases. Click each OptionButton to see the results.Caption = “On” Option1. Load Option1(I) ‘ Set the location of the new option button.DrawBackground = True ‘draws the line features End With ‘Create and position the option buttons Dim I ‘ Declare variable.Visible = True Next I Option1. choosing one option will result in different features receiving labels. MapObjects Programmer’s Reference 409 False The LabelPlacer will not position the labels above the features.Top + Option1(0). and PlaceBelow properties of the LabelPlacer to demonstrate the options available for placing labels.Field = “NAME” .Layers(0). 410 MapObjects Programmer’s Reference End Sub Private Sub Map1_MouseDown(Button As Integer. y As Single) Map1.PlaceBelow [= value] The PlaceBelow property syntax has these parts: Part Description object An object expression that evaluates to a LabelPlacer.Refresh 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.pmd 410 10/28/2004.PlaceBelow = False Case 2 ‘below .PlaceAbove = False . Shift As Integer. 10:00 AM .TrackRectangle End Sub Private Sub Option1_Click(Index As Integer) With lp Select Case Index Case 0 ‘above .PlaceAbove = True .PlaceOn = True .PlaceOn = False . ProgrammersReference.Extent = Map1.PlaceBelow = True End Select End With Map1.PlaceAbove = False .PlaceOn = False .PlaceBelow = False Case 1 ‘on . Syntax object. x _ As Single. Once you’ve set the PlaceNameTable property. PlaceOn Property Example See PlaceAbove Property PlaceLocator Object A PlaceLocator object lets you match place names to a GeoDataset that you specify with the PlaceNameTable property. the index file will be located in the same directory as the PlaceNameTable. See Also PlaceAbove Property. Using the Locate method on an SDE layer is not supported.PlaceLocator Properties Indexed PlaceNameTable Methods ProgrammersReference. You can create PlaceLocator objects in Visual Basic like this: Dim plc as New MapObjects2. the index must be specifically re-built.pmd 411 10/28/2004. The index you build is static. In addition you can use the FindApproximateMatches method to find approximate matches for a given place name. Both of these methods return their results as a Strings collection. If the PlaceNameTable is based on a shapefile. To match place names to geographical locations. You can determine whether an index exists for the GeoDataset with the Indexed property. False The LabelPlacer will not position the labels below the features. with an extension of . you can use the Locate method to return a Points collection of geographic locations of all place names that match your criteria. ARC/INFO coverage or VPF file. or the FindAllPlaceNames method to find all place names that begin with the specified characters. if the PlaceNameTable is changed.gcx. The PlaceNameTable index file has the same filename as the PlaceNameTable. Settings The settings for value are: Setting Description True The LabelPlacer will position the labels below the features. as described in Settings. 10:00 AM . you can use the BuildIndex method to index the fields in that table against which you can search. MapObjects Programmer’s Reference 411 value A boolean expression that determines whether the LabelPlacer should position each label below the feature to which it corresponds. geodataset An object expression that evaluates to a GeoDataset that contains place names. 412 MapObjects Programmer’s Reference BuildIndex FindApproximateMatches Locate FindAllPlaceNames See Also Geocoder Object. ProgrammersReference. 10:00 AM .PlaceNameTable = geodataset The PlaceNameTable property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. See Also Locate Method Example See FindAllPlaceNames Property 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.pmd 412 10/28/2004. This property is write-only.PlaceOn [= value] The PlaceOn property syntax has these parts: Part Description object An object expression that evaluates to a LabelPlacer. SearchExpression Method Example See FindAllPlaceNames Property PlaceNameTable Property Applies To PlaceLocator Object Description Sets the PlaceNameTable property of a PlaceLocator object to a GeoDataset that contains place names. Syntax object. Syntax object. where each Point in that collection represents one vertex of the shape. Example See PlaceAbove Property Point Object A Point object represents a geometric shape that consists of a single point in space. Intersect. You can get or set the location of a Point through its X. Line. Each Item in the Parts collection is a Points object. You can create Point objects in Visual Basic with code like this: Dim pt as New MapObjects2. PlaceBelow Property. The MultiPoint shape type is synonymous with a MapObjects Points Collection. Settings The settings for value are: Setting Description True The LabelPlacer will position the labels directly on the features. MapObjects Programmer’s Reference 413 value A boolean expression that determines whether the LabelPlacer should position each label directly on the feature to which it corresponds. ExclusiveOr. Difference and Buffer on the Point object. Polygon or Rect- angle object using the DistanceTo method. Points. each Item in that collection representing one part of a multi-part shape. 10:00 AM . See Also PlaceAbove Property. You can return the distance in map units between one Point object and another Point. False The LabelPlacer will not position the labels directly on the features. You also can perform other geometric operations such as Union.Point Properties Measure X Y Z ShapeType Methods Buffer DistanceTo GetCrossings Union Difference DistanceToSegment Intersect XOr ProgrammersReference. Polygon and Line objects have a Parts collection. as described in Settings. Y and Z properties.pmd 413 10/28/2004. each Point in that collection represents one vertex of the shape.Polygon Dim pts As New MapObjects2.Y = 400 pts. 10:00 AM . You can also perform other geometric operations such as Union.X = 400 pt.Y = 100 pts. Each Item in the Parts collection is a Points object. Points objects may be used in the DrawShape method.X = 250 pt.Y = 100 pts. and can be used for storing related Point shapes in a single geometric object. with only one member.X = 100 pt.Add pt ProgrammersReference. Difference and Buffer. You can create a Points collection in Visual Basic with code like this: Dim pts as New MapObjects2. You can get the location of each Point in the collection through its X. each Item in that collection representing one part of a multi-part shape.X = 100 pt.Points Polygon and Line objects have a Parts collection. use the GetCrossings method.Add pt pt.Add pt pt.Add pt pt. Intersect.pmd 414 10/28/2004. 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. A Points object is a collec- tion of Point objects. 414 MapObjects Programmer’s Reference See Also Points Collection Points Collection A Points object is a shape that represents a set of points in space. ExclusiveOr. This can be done in Visual Basic with code like this: Dim poly as New MapObjects2.Point pt. To return a new Points object at which another shape object crosses an existing Points object.Points Dim pt As New MapObjects2. Y and Z proper- ties.Y = 100 pts. add the Points object to the Parts collection. and as GeoEvent shapes. Once you have built up the part. Polygon and Line objects with a single part also have a Parts collection. Properties Count Extent Methods Add Insert Remove XOr Buffer Intersect Reverse Difference Item Set GetCrossings Offset Union See Also Point Object Polygon Object A Polygon object represents a geometric shape that has three or more vertices and forms a closed ring. You can return the bounding rectangle of a Polygon through its Extent property. In addition.Add pts The Points object is equivalent to the MultiPoint shape type in ESRI’s ArcView GIS. Intersect. A multi-part Polygon is treated as a single shape for methods such as SearchShape. i.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. Points. 10:00 AM . 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. use the GetCrossings method. To return the set of Points at which another object crosses the Polygon. You can create Polygon objects in Visual Basic with code like this: Dim poly as New MapObjects2. A Polygon may consist of one or more discontinuous Parts.e. You can use the DistanceTo method to return the distance in map units to another Point. Polygon. or Rectangle object. a GeoDataset created in MapObjects and populated with Points objects will be read as a MultiPoint Shapefile in ArcView. Difference. MapObjects Programmer’s Reference 415 poly. 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 Polygon with two or more Parts is a multi-part Polygon. Each vertex of ProgrammersReference.Parts. Line. If a shapefile is created in ArcView. The geometric methods Buffer.pmd 415 10/28/2004. with the MultiPoint shape type. ExclusiveOr and Union are supported for Polygons. The converse is also true. each feature from this file will be returned in MapObjects as a Points object. it is coincident with the first vertex. 416 MapObjects Programmer’s Reference the part should be added using a Point object.e.Polygon Dim pts As New MapObjects2.Y = 100 pts.Point pt.X = 250 pt.X = 100 pt. This can be done in Visual Basic with code like this: Dim poly as New MapObjects2.Add pt pt.Add pt pt.Points Dim pt As New MapObjects2. You should ensure that the last vertex of each part closes the ring.Add pts Properties Count Extent Methods Add Insert Remove XOr Buffer Intersect Reverse Difference Item Set GetCrossings Offset Union See Also TrackPolygon Method ProgrammersReference.Y = 100 pts.Y = 400 pts.Add pt pt. i. Once you have built up the part.Parts.pmd 416 10/28/2004.X = 100 pt.X = 400 pt.Add pt poly. add the Points object to the Parts collection of the Polygon. 10:00 AM .Y = 100 pts. The resultant Strings collection can be used to display a list of all pre-defined Datum types. A user may then select a required Datum from the list.pmd 417 10/28/2004. Syntax object. and the pre-defined GeoCoordSys type can be parsed from the selected string. See Also Datum Object. See Also GeogCoordSys Object. MapObjects Programmer’s Reference 417 PopulateWithDatums Method Applies To Strings Collection Description Populates a Strings collection with the names and integer values of all Datum constants. Datum Constants PopulateWithGeographicCoordSys Method Applies To Strings Collection Description Populates a Strings collection with the names of all Geographic coordinate system constants. A user may then select a required GeoCoordSys from the list.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. Remarks The values added to the Strings collection by this method include a name and integer value for each GeographicCoordSysConstant. and the pre-defined Datum type can be parsed from the selected string. 10:00 AM . GeographicCoordSys Constants ProgrammersReference. Syntax object. The resultant Strings collection can be used to display a list of all pre-defined GeoCoordSys types.PopulateWithGeographicCoordSys The object placeholder represents an object expression that evaluates to the name of a String collection. for example in a combo box. for example in a combo box. See Also PrimeMeridian Object.PopulateWithGeoTransformations The object placeholder represents an object expression that evaluates to the name of a String collection. The resultant Strings collection can be used to display a list of all pre-defined GeoTransformation types. and the pre-defined GeoTransformation type can be parsed from the selected string. Syntax object. Syntax object.PopulateWithMeridians The object placeholder represents an object expression that evaluates to the name of a String collection. for example in a combo box. GeographicTransformation Constants PopulateWithMeridians Method Applies To Strings Collection Description Populates a Strings collection with the names of all PrimeMeridian constants. A user may then select a required GeoTransformation from the list. The resultant Strings collection can be used to display a list of all pre-defined PrimeMeridian types. Remarks The values added to the Strings collection by this method include a name and integer value for each GeographicTransformationConstant. Remarks The values added to the Strings collection by this method include a name and integer value for each DatumConstant.pmd 418 10/28/2004. 10:00 AM . PrimeMeridian Constants ProgrammersReference. 418 MapObjects Programmer’s Reference PopulateWithGeoTransformations Method Applies To Strings Collection Description Populates a Strings collection with the names of all Geographic transformation constants. for example in a combo box. See Also GeoTransformation Object. and the pre-defined PrimeMeridian type can be parsed from the selected string. A user may then select a required PrimeMeridian from the list. ProgrammersReference. Remarks The values added to the Strings collection by this method include a name and integer value for each ParameterTypeConstant for that ProjectionConstant. for example in a combo box. A user may then select a required Parameter from the list.PopulateWithProjectedCoordSys The object placeholder represents an object expression that evaluates to the name of a String collection. projection A variable declared as an Integer that evaluates to a Projection constant. See Also Projection Object. Syntax object. The resultant Strings collection can be used to display a list of all pre-defined ProjCoordSys types.pmd 419 10/28/2004. MapObjects Programmer’s Reference 419 PopulateWithParameters Method Applies To Strings Collection Description Populates a Strings collection with all of the parameters that describe the components of a given Projection. Syntax object. and the pre-defined ProjCoordSys type can be parsed from the selected string. for example in a combo box. and the pre-defined Parameter type can be parsed from the selected string. Projection Constants PopulateWithProjectedCoordSys Method Applies To Strings Collection Description Populates a Strings collection with the names of all ProjCoordSys constants. A user may then select a required ProjCoordSys from the list. 10:00 AM .PopulateWithParameters projection The PopulateWithParameters method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. The resultant Strings collection can be used to display a list of all pre-defined Parameter types. Remarks The values added to the Strings collection by this method include a name and integer value for each ProjectedCoordSys Constant. and the pre-defined Projection type can be parsed from the selected string. for example in a combo box.PopulateWithSpheroids The object placeholder represents an object expression that evaluates to the name of a String collection. The resultant Strings collection can be used to display a list of all pre-defined Spheroid types. Remarks The values added to the Strings collection by this method include a name and integer value for each ProjectionConstant. Projection Constants PopulateWithSpheroids Method Applies To Strings Collection Description Populates a Strings collection with the names of all Spheroid constants. and the pre-defined Spheroid type can be parsed from the selected string. 10:00 AM . The resultant Strings collection can be used to display a list of all pre-defined Projection types. A user may then select a required Spheroid from the list.PopulateWithProjections The object placeholder represents an object expression that evaluates to the name of a String collection. Syntax object. Syntax object. Remarks The values added to the Strings collection by this method include a name and integer value for each SpheroidConstant. Spheriod Constants ProgrammersReference. 420 MapObjects Programmer’s Reference See Also ProjCoordSys Object. See Also Spheroid Object. for example in a combo box. A user may then select a required Projection from the list.pmd 420 10/28/2004. See Also Projection Object. ProjectedCoordSys PopulateWithProjections Method Applies To Strings Collection Description Populates a Strings collection with the names of all Projection constants. 79 E) ProgrammersReference. 41’16".5 E) moPrimeM_Jakarta 8908 Jakarta (106. 27’08". 48’27".3 W) moPrimeM_Madrid 8905 Madrid (3. 10:00 AM . 00. 04’51".58 W) moPrimeM_Rome 8906 Rome (12. for example in a combo box. The resultant Strings collection can be used to display a list of all pre-defined Unit types.PopulateWithUnits The object placeholder represents an object expression that evaluates to the name of a String collection. A user may then select a required Unit from the list. Remarks The values added to the Strings collection by this method include a name and integer value for each UnitConstant. 07’54". value 8901. 00" E) moPrimeM_Lisbon 8902 Lisbon (9. The default PrimeMeridian is moPrimeM_Greenwich.025 E) moPrimeM_Bogota 8904 Bogota (74. and the pre- defined Unit type can be parsed from the selected string.4 E) moPrimeM_Bern 8907 Bern (7.862 W) moPrimeM_Paris 8903 Paris (2. 26’22". MapObjects Programmer’s Reference 421 PopulateWithUnits Method Applies To Strings Collection Description Populates a Strings collection with the names of all Unit constants. Syntax object. 20’14". Unit Constants PrimeMeridian Constants MapObjects defines the following constants for use with the Type property of a PrimeMeridian object.pmd 421 10/28/2004. Constant Value Description moPrimeM_Greenwich 8901 Greenwich (0. See Also Unit Object. 10:00 AM . Properties Longitude Name Type See Also Projection Object. The PrimeMeridianContants provided define a range of common prime meridians. 42’58". 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. Type Property PrimeMeridian Object The PrimeMeridian object defines the prime meridian. PrimeMeridian [= primeMeridian ] The PrimeMeridian property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 422 10/28/2004. 22’04".815 E) See Also PrimeMeridian Object. Datum Object. Syntax object. Spheroid Object. 422 MapObjects Programmer’s Reference moPrimeM_Ferro 8909 Ferro (17. GeoCoordsys Object. the line of zero longitude for coordi- nates in a geographic coordinate system (GeoCoordSys object). or alternatively the longitude can be specified directly using the Longitude property of a new PrimeMeridian object.8 E) moPrimeM_Athens 8912 Athens (23. primeMeridian An object expression that evaluates to a PrimeMeridian object See Also PrimeMeridian Object ProgrammersReference.71 E) moPrimeM_Stockholm 8911 Stockholm (18. 40’00" W) moPrimeM_Brussels 8910 Brussels (4. 03’29". PrimeMeridian.Longitude > 32) Then curLayer.PrimeMeridian.Caption = “Show only layers with Prime Meridians passing _ through Western Europe” ProgrammersReference. remain visible. having two ‘different datums. For Each curLayer In Map1.Value = 1 Then ‘If any layer in the map has a prime meridian > 32 or <-10. To try this example.CoordinateSystem. Option Explicit Private Sub Check1_Click() Dim curLayer As MapObjects2. MapLayers should have thier CoordinateSystems property set.Longitude < -10) _ Or (curLayer. Maplayers having a geo- graphic coordinate system with the same datum as that chosen in the ComboBox are made invisible. 10:00 AM . and choose a datum from the ComboBox. to two MapLayers. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer.Layers If Not curLayer.Refresh End Sub ‘This code can be used to apply two GeoCoordSys objects. ‘make it invisible.Visible = False End If End If Next curLayer Else For Each curLayer In Map1. and a ComboBox named Combo1. Private Sub Form_Load() Check1. Press F5.CoordinateSystem.CoordinateSystem. MapObjects Programmer’s Reference 423 Example This example uses the PrimeMeridian property to check the PrimeMeridian property of maplayers with geographic coordinate systems.Layers curLayer.IsProjected Then If (curLayer. Maplayers which are not projected. or have the same datum as that chosen in the ComboBox.MapLayer If Check1. You may wish to use your own ‘projection objects which are appropriate for your datasets.pmd 423 10/28/2004.Visible = True Next curLayer End If Map1. pmd 424 10/28/2004.PrintMap docName. 424 MapObjects Programmer’s Reference Dim gcs1 As New MapObjects2.GeoCoordSys Dim pm1 As New MapObjects2. outputFile A string expression that evaluates to a file name specification or Null. 10:00 AM .Longitude = 15# pm2.PrimeMeridian = pm1 gcs2.CoordinateSystem = gcs1 Set Map1.Longitude = 40# gcs1.PrimeMeridian = pm2 Set Map1. landscape The PrintMap method syntax has the following object qualifier and arguments: Part Description object An object expression that evaluates to an object in the Applies To list. any ImageLayers in the Map control’s Layers collection will not be visible.CoordinateSystem = gcs2 End Sub PrintMap Method Applies To Map Object Description Prints the visible extent of the Map. Settings The settings for orientation are: Setting Description True The orientation of the Map is Landscape. Remarks PrintMap does not support VisibleRegion or Transparent properties.GeoCoordSys Dim gcs2 As New MapObjects2. If any ProgrammersReference.Layers(0). landscape A boolean expression that determines the orientation of the Map as specified in Settings. Syntax object. False The orientation of the Map is Portrait. outputFile. docName A string expression that evaluates to the name of an item in the printer queue. If RotationAngle is not zero.PrimeMeridian Dim pm2 As New MapObjects2.Layers(1).PrimeMeridian pm1. then these too will not be visible. defining the coordinate system in which the vector data is displayed.pmd 425 10/28/2004. a user-defined projected coordinate system can be defined by setting the GeoCoordSys. PrintMap Method Example This example uses the PrintMap method to print the visible extent of a Map in a form to the default printer. See Also CopyMap Method. 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. Properties GeoCoordSys Name Type Unit IsProjected Projection ProgrammersReference. True End Sub ProjCoordSys Object A projected coordinate system describes positions on the earth using a coordinate system based on X and Y coordinate values. OutputMap Method. Coordinate system metadata can be stored on disk for later retrieval using the Export method. A ProjCoordSys can be applied to a MapLayer and Map Control via the CoordinateSystem property of these objects. 10:00 AM . ExportMap Method. The coordinate system is projected from a spheroidal approximation of the earth. OutputMap2 Method. MapObjects Programmer’s Reference 425 ImageLayers in the Map control’s Layers collection have their Transparent property set to True. based on a geographical coordinate system. “”.PrintMap “MyMap”. Projection and Unit properties of a ProjCoordSys object to specific objects. Option Explicit Private Sub Command1_Click() Map1. The GeoCoordSys property of a ProjCoordSys object defines which geographical coordinate system the ProjCoordSys is projected from. Alternatively. The units of the coordinate system are defined in the Unit property. To try this example. and then press F5 and click the button. An individual shape can be projected to another ProjCoordSys or GeoCoordSys. The way in which the projection is calculated is defined in the Projection property. using the ProjCoordSys object’s Transform method. A standard projected coordinate system can be created by setting the Type property with ProjectedCoordSysConstants which include nearly one thousand pre-defined coordinate systems. ExportMap2 Method. The default Projection is moProjection_PlateCarree. The default ProjCoordSys is moProjCS_World_PlateCarree. Type Property Projection Constants MapObjects defines the following constants for use with the Type property of a Projection object. 10:00 AM . Constant Value Description moProjection_PlateCarree 43001 Plate Carree moProjection_EquidistantCylindrical 43002 Equidistant Cylindrical moProjection_MillerCylindrical 43003 Miller Cylindrical moProjection_Mercator 43004 Mercator moProjection_GaussKruger 43005 Gauss-Kruger moProjection_TransverseMercator 43006 Transverse Mercator moProjection_Albers 43007 Albers moProjection_Sinusoidal 43008 Sinusoidal moProjection_Mollweide 43009 Mollweide ProgrammersReference.pmd 426 10/28/2004. See Also ProjCoordSys Object. MapLayer Object. Projection Object. 426 MapObjects Programmer’s Reference Methods Export ReturnDescription SetParameter Transform GetParameter See Also Map Object. value 43001. GeoCoordsys Object ProjectedCoordSys Constants MapObjects defines over nine hunderd and fifty constants for use with the Type property of a ProjCoordSys object. value 54001. 10:00 AM . Type Property ProgrammersReference. MapObjects Programmer’s Reference 427 moProjection_EckertVI 43010 Eckert VI moProjection_EckertV 43011 Eckert V moProjection_EckertIV 43012 Eckert IV moProjection_EckertIII 43013 Eckert III moProjection_EckertII 43014 Eckert II moProjection_EckertI 43015 Eckert I moProjection_GallStereographic 43016 Gall Stereographic moProjection_Behrmann 43017 Behrmann moProjection_WinkelI 43018 Winkel I moProjection_WinkelII 43019 Winkel II moProjection_LambertConformalConic 43020 Lambert Conformal Conic moProjection_Polyconic 43021 Polyconic moProjection_QuarticAuthalic 43022 Quartic Authalic moProjection_Loximuthal 43023 Loximuthal moProjection_Bonne 43024 Bonne moProjection_Hotine 43025 Hotine moProjection_Stereographic 43026 Stereographic moProjection_EquidistantConic 43027 Equidistant Conic moProjection_Cassini 43028 Cassini moProjection_VanDerGrintenI 43029 Van der Grinten I moProjection_Robinson 43030 Robinson moProjection_TwoPointEquidistant 43031 Two-Point Equidistant moProjection_AzimuthalEquidistant 43032 Azimuthal Equidistant See Also Projection Object.pmd 427 10/28/2004. Alternatively. 10:00 AM . a custom Projection may be created. Custom projections require that the transformation parameters are specified in a COM (Common Object Model) component that is interfaced to MapObjects. Properties Custom IsCustom Name Type See Also ProjCoordsys Object Projection Property Applies To ProjCoordSys Object Description Sets or returns a value that identifies the Projection upon which a ProjCoordSys object is based. projection An object expression that evaluates to a Projection object. A Projection object may be defined by of one of over thirty pre-defined ProjectionConstants. See Also Projection Object Example See IsCustom Property ProgrammersReference. Syntax object. This is specified using the Custom property. A user defined Projection object is identified using the IsCustom property. Projection [= projection ] The Projection property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Remarks The Projection property contains a Projection object specifying the mathematical method used to project locations from a geographical to a projected coordinate system.pmd 428 10/28/2004. which provide a suitable projection for the majority of users. 428 MapObjects Programmer’s Reference 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. object An object expression that evaluates to an object in the Applies To list. Syntax Set variable =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.Records The Records property syntax has these parts: Part Description variable A variable that has been declared to be of MapObjects Recordset type. MapObjects Programmer’s Reference 429 RampColors Method Applies To ClassBreaksRenderer Object. 10:00 AM . Syntax object.pmd 429 10/28/2004. SizeSymbols Method Example See Break Property Records Property Applies To MapLayer Object. Table Object Description Returns the Recordset associated with a MapLayer or a Table. endColor The RampColors method syntax has these parts: Part Description object An object expression that evaluates to a object in the Applies To list startColor A value or constant that evaluates to an OLE_COLOR to assign to the Symbol associated with the features whose Field values are in the category delimited by Break(0). See Also Color Constants. endColor A value or constant that evaluates to an OLE_COLOR to assign to the Symbol associated with the features whose Field values are greater than the category delimited by Break(BreakCount).RampColors startColor. ProgrammersReference. Print “Reached EOF.Recordset The Recordset returned by the Records property is a new object.pmd 430 10/28/2004. 430 MapObjects Programmer’s Reference Remarks Visual Basic has its own Recordset class.Records. so when using a MapObjects Recordset.Records ProgrammersReference.Records recs. the following Visual Basic code will enter an infinite loop: new_layer.MoveNext Wend Debug.EOF recs. See Also Recordset Object Example This example uses the Records property to access the Recordset of a MapLayer. 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. Option Explicit Private Sub Command1_Click() Dim recset As MapObjects2. be sure to explicitly declare the class.Print “Reached EOF. recs. The code iterates through all the records of the recordset and flashes the shape of each feature of the MapLayer. for example: Dim recs as New MapObjects2. new_layer. Press F5 and click Command1.” This happens because the EOF property being tested belongs to a different Recordset object to the one for which the MoveNext method is being called.MoveFirst While Not recs. The following Visual Basic example demonstrates this by using a local Recordset object. you should make sure that it references the same object throughout the sequence.Recordset Set recs = new_layer.MoveNext Wend Debug.MoveFirst While Not new_layer.Records. To try this example.Records. to reference the records of the MapLayer object. If your program needs to carry out a set of operations on a Recordset.” By contrast.EOF new_layer. 10:00 AM .Layers(0).Recordset Dim shp As Object Set recset = Map1. Dim recs As MapObjects2. If the Recordset is Updateable. you can return some basic statistical values for the Field. To delete a record in the Recordset. When you have ProgrammersReference. If the Recordset supports transactions. you can use the Edit method to allow updates on the current record. 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.MoveNext Loop End Sub Recordset Object A Recordset object represents the records associated with a GeoDataset or the records that result from running a query. If you are creating a new Recordset. The Count property returns the number of records in the Recordset. use the Delete method. You can navigate through the Recordset with the MoveNext method. You can simplify your code by taking advantage of these defaults. use the AddNew method. you position the current record position at its first record. Once you have created the Statistics object. back up one record with the MovePrevious method. To create a new record in the Recordset. and then carry out your edits. You should first call the StartTransaction method on your Recordset.EOF Set shp = recset. This greatly enhances performance when writing shapefiles. The default property of a Recordset is its Fields collection. 2 recset.FlashShape shp. If you want to discard a change to a record before updating. you can use the CancelUpdate method to cancel any pending updates. and the default property of a Field object is the Value property. or move to the first record of the Recordset with the MoveFirst method.Fields(“shape”).Value Map1. The Update method saves the current record and any changes you have made to it. MapObjects Programmer’s Reference 431 Do While Not recset. The EditMode property indicates the state of editing for the current record.Value x = myRecordSet(“POPULATION”) You can use the CalculateStatistics method to create a Statistics object based on a Field name in the Recordset. 10:00 AM . The EOF property returns True as soon as you have moved past the last record of the Recordset. use the StopEditing method. When you create a Recordset.Fields(“POPULATION”). then you can use the Edit method in a similar way to carry out transactional editing on an external database table. To re-open the underlying table as read-only after performing edits. The Fields property returns a collection of Field objects that comprise the Recordset. For example. the following lines of code each return the value of the Population field in the current record of a Recordset: x = myRecordSet.pmd 431 10/28/2004. Set the AutoFlush property to False to prevent changes from being automatically flushed on a write action. In addition. fully qualify the class name in declarations. Left. Value Property. ScaleRectangle. Bottom and Right properties. A Rectangle object can also represent a cuboid. You can manipulate the size or dimension of Rectangle objects with the Inset. To set its Depth. you can set and return its position and dimensions with its Top. SearchExpression Method Rectangle Object A Rectangle object represents a geometric shape with four edges and four right angles. or Union methods. a Rectangle has a Depth of zero. Use the IsPointIn method to test if a point ProgrammersReference. You can use a three-dimensional Rectangle as an argument to the SearchShape method for MapLayers that contain features with Z values. For example: Dim MyRecordset as MapObjects2. Remarks To distinguish a MapObjects Recordset from a Visual Basic Recordset. or RollbackTransaction to leave the data set the way it was before you started your transaction. By default. You can return the dimensions of a Rectangle object with the Height and Width parameters and return its Center as a Point object. 432 MapObjects Programmer’s Reference finished your editing. use the Floor and Ceiling properties. 10:00 AM .Recordset Properties AutoFlush EOF TableDesc Count Fields Updatable EditMode SupportsTransactions Methods AddNew Edit RollbackTransaction CalculateStatistics Export StartTransaction CancelUpdate MoveFirst StopEditing CommitTransaction MoveNext Update Delete MovePrevious See Also Field Object. you can call either the CommitTransaction method if you wish to save your changes to the data set. Intersect.pmd 432 10/28/2004. as explained in settings.pmd 433 10/28/2004. [ rect ] The Refresh property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Polygon.Refresh [ erase ]. Points. Line. You can use the DistanceTo method to return the distance in map units to another Point. ProgrammersReference. erase Optional boolean expression. SearchShape Method Refresh Method Applies To Map Object. Syntax object. Applies to a TrackingLayer object only. To return the set of Points at which another object crosses the Rectangle. You can create Rectangle objects in Visual Basic with code like this: Dim rect as New MapObjects2. and Intersects to test whether two Rectangle objects intersect one another. TrackingLayer Object Description Forces a complete repaint of a Map or a TrackingLayer object. MapObjects Programmer’s Reference 433 falls within a Rectangle. use the GetCrossings method. 10:00 AM . or Rectangle object.Rectangle Properties Bottom Depth Left Top Ceiling Floor Right Width Center Height ShapeType Methods Buffer GetCrossings Intersects ScaleRectangle Difference Inset IsPointIn Union DistanceTo Intersect Offset XOr See Also TrackRectangle Method. Option Explicit Private Sub Command1_Click() Dim fRed As Double. BeforeLayerDraw Event. fGreen. fGreen As Double. 10:00 AM . 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. Use the RefreshRect method on the Map control instead. See Also AfterLayerDraw Event. Settings The settings for erase are: Setting Description True MapObjects erases and redraws the entire TrackingLayer False MapObjects only redraws the areas of the TrackingLayer that have been made invalid by moving GeoEvent objects prior to the last redraw.Symbol. Remarks Any change you make to a GeoEvent will redraw the TrackingLayer of the map. Press F5. fBlue) . If you want to make the change immediately visible.pmd 434 10/28/2004. 434 MapObjects Programmer’s Reference rect A Rectangle object representing an area within the map extent. then click Command1. BeforeTrackingLayerDraw Event Example This example uses the Refresh method to draw the Map again with a randomly assigned new color for the topmost MapLayer. If given then only this area within the TrackingLayer will be refreshed. Applies to a TrackingLayer object only. 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. To try this example. AfterTrackingLayerDraw Event.Layers(0). you won’t need to use the Refresh method for this purpose. The rectangle argument cannot be applied to this method on Map objects. Normally. you can use the Refresh method.Refresh End With End Sub ProgrammersReference.Color = RGB(fRed. fBlue As Double fRed = 255 * Rnd fGreen = 255 * Rnd fBlue = 255 * Rnd With Map1 . BeforeLayerDraw Event. If MapObjects has 1000 vertexes to draw and the Map object’s RefreshCount is 500. See Also AfterLayerDraw Event. but a smoother appearance. Remarks MapObjects draws features of a Map offscreen and throughout the drawing process it updates the screen. BeforeTrackingLayerDraw Event Example This example uses the RefreshCount property to control the rate at which the features of a Map draw.TickStyle = sldTopLeft . Drag the slider to control the setting.Orientation = ccOrientationVertical ProgrammersReference. AfterTrackingLayerDraw Event. then the application will refresh the screen twice. The RefreshCount specifies how often MapObjects updates the screen during the drawing process. and then press F5. To try this example. Label2. and a Map named Map1 that contains at least one MapLayer. Syntax object.RefreshCount [= value] The RefreshCount property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. paste the code into the Declarations section of a form contain- ing three Label controls named Label1. 10:00 AM . The default value is 10.Refresh End Sub Private Sub Form_Load() With Slider1 . and Label3. value A numeric expression that represents the number of vertexes in each MapLayer that draw at one time. a Slider named Slider1.000.pmd 435 10/28/2004. MapObjects Programmer’s Reference 435 RefreshCount Property Applies To Map Object Description Returns or sets a value that determines the rate at which the features of a Map draw. The Form_Load code will position all the controls with the exception of the Map. Option Explicit Private Sub Slider1_Click() Map1.Value Map1. A higher RefreshCount results in faster draw times because there is less updating.RefreshCount = Slider1. A lower RefreshCount results in slower draw times.TickFrequency = 2500 . Width End Sub Private Sub Slider1_Change() Label3.Top = Slider1. Syntax object.Width + Label1.Width .Max = 20000 . 436 MapObjects Programmer’s Reference .Height .Slider1.Caption = Slider1.Caption = Slider1.Left = Slider1.Top = Slider1.Width .Caption = Slider1.Left .Height End With Width = (Map1.[rect] The RefreshLayer method syntax has the following object qualifier and parts: ProgrammersReference.Top = Map1.Left .Label2.Left + Map1.SmallChange = 1000 .Value End Sub RefreshLayer Method Applies To Map Object Description Forces a repaint of the features in a specified MapLayer and the layers above it.Left = Slider1.LargeChange = 2500 .Value = 10000 End With With Label1 .Left = Map1.Left .Caption = Slider1.Top = Slider1.Min ..AutoSize = True . 10:00 AM .Height End With With Label3 .RefreshLayer index .Width .AutoSize = True .Max Slider1.Left = Slider1.pmd 436 10/28/2004.Width + Slider1.Value .Label1.Height + Label3.Top + Slider1.Left * 2) + Map1.Top + Slider1.Width + .Top End With With Label2 .Top .Max .AutoSize = True . Similarly. Option Explicit Private Sub Form_Load() Dim lyr As MapObjects2. index Required. See Also Layers methods Example This example uses the RefreshLayer method to repaint the specified layers and all those above it. This method should be used with care. RefreshLayer will repaint the features currently in the specified layer.AddItem lyr. An object expression that evaluates to an object in the Applies To list. 10:00 AM . The programmer may however use the RefreshRect method to force a re-paint of these areas of the Map. To try this example.pmd 437 10/28/2004. MapObjects Programmer’s Reference 437 Part Description object Required. 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. This method can be used where a feature has been added to a MapLayer. paste the code into the Declarations section of a form containing a ListBox named List1 and a Map named Map1 that contains several MapLayers. to update the information contained on the Map without the need to perform a full Refresh. rect Optional. without the need for a Refresh of the entire Layers collection. A numeric expression that evaluates to the current index position of the MapLayer in the Layers collection.RefreshLayer List1.Name Next lyr End Sub Private Sub List1_DblClick() Map1. and then press F5 and double-click the MapLayer in the ListBox. the layer at the bottom is the first layer to draw. the movement or editing of features within a MapLayer may result in artifacts on the Map control until the Map is fully refreshed. 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.Layers List1. A Rectangle Object representing an area within the layer extent.ListIndex End Sub ProgrammersReference.MapLayer For Each lyr In Map1. Symbol.Layers(0). paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer.Color = moRed Map1.TrackRectangle Map1. rect A Rectangle object representing an area within the map extent. Shift As Integer. X _ As Single.Rectangle Private Sub Form_Load() Map1.Layers(0). To try this example.Color = moBlue End Sub Private Sub Map1_MouseDown(Button As Integer. Only this area within each layer will be refreshed Remarks The layer at the top is the last layer to draw. 10:00 AM . Y As Single) Set rect = Map1.Symbol. 438 MapObjects Programmer’s Reference RefreshRect Method Applies To Map Object Description Forces a repaint of the region of the specified Rectangle for all layers in the Map. Example This example uses the RefreshRect property to refresh only the new extent of the map control. Option Explicit Dim rect As New MapObjects2.RefreshRect rect End Sub ProgrammersReference.RefreshRect [rect] The RefreshRect method syntax has the following object qualifier and parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 438 10/28/2004. See Also Rectangle Object Syntax object. and then press F5. the layer at the bottom is the first layer to draw. Layers. An object expression that evaluates to an object in the Applies To list. MapObjects Programmer’s Reference 439 Remove Method Applies To GroupRenderer Object. Syntax object.Remove 0 ‘ Remove the first layer each time ‘ through the loop until there are ‘ no objects left in the collection. To try this example.Remove index The Remove method syntax has the following object qualifier and part: Part Description object Required. 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. an error occurs. A numeric expression that specifies the position of a member of the collection.1 Map1. Remarks If index does not match any existing member of the collection.pmd 439 10/28/2004. Index must be a number from 0 to the one less than the value of the collection’s Count property. Option Explicit Private Sub Command1_Click() Dim lNum As Long For lNum = 0 To Map1. Insert Method. Next End Sub RemoveEvent Method Applies To TrackingLayer Object Description Deletes the specified GeoEvent object from the TrackingLayer. Points Collection Description Removes a member from a collection.Layers. index Required. Set Method Example This example illustrates the use of the Remove method to remove objects from a Collection object. in this case.Count . 10:00 AM . the Layers collection. Parts Collection. Layers Object. See Also Add Method. ProgrammersReference. Symbol Object Example This example uses the RemoveEvent method to remove a GeoEvent from the TrackingLayer. and then press F5 and click the button.RemoveEvent index The RemoveEvent method syntax has these parts: Part Description object An object expression that evaluates to a TrackingLayer object. Remarks The first item in the group of GeoEvent objects has index = 0. 10:00 AM .TrackingLayer. Option Explicit Private Sub Command1_Click() If Map1. ProgrammersReference. This code removes the GeoEvent whose index is 0. To try this example. 440 MapObjects Programmer’s Reference Syntax object.pmd 440 10/28/2004. 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. Index must be a number from 0 to one less than the value of the EventCount property. See Also GeoEvent Object.RemoveRelates The RemoveRelates method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.TrackingLayer. You may want to add GeoEvents using the code in the AddEvent method example.RemoveEvent 0 End If End Sub 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. provided there are events left on the TrackingLayer. Syntax object.EventCount > 0 Then Map1. therefore EventCount is always one more than the largest index value. index An integer index that indicates which GeoEvent to delete. Renderer ( index ) [= value] The Renderer method syntax has the following object qualifier and part: Part Description object Required. Remarks Renderers are creatable objects in MapObjects. An object expression that evaluates to an object in the Applies To list. A numeric expression that specifies the position of a member of the group. Index must be a number from 0 to the one less than the value of the object’s Count property. 10:00 AM . a DotDensityRenderer. MapObjects Programmer’s Reference 441 See Also Table Object Example See AddRelate Method Renderer Property Applies To MapLayer Object.Renderer = New MapObjects2. In Visual Basic. Syntax For a GroupRenderer Object object. GroupRenderer Object Description Returns or sets a reference to the Renderer of a MapLayer. index Required. or the Renderer at the specified index of a GroupRenderer.GroupRenderer ProgrammersReference. renderer An object expression that evaluates to a ClassBreaksRenderer.Layers(0). a LabelRenderer. value An object expression that evaluates to a MapObjects renderer. Syntax For a MapLayer Object object. here’s one way to create one of the kinds of renderers: Set Map1.Renderer [= renderer] The Renderer property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 441 10/28/2004. or a ValueMapRenderer. set the Renderer property to Nothing. See Also ChartRenderer Object. ValueMapRenderer Object Example This example uses the Renderer property to specify what technique to use to draw a MapLayer. You may have to modify the example to change the “region” field to reflect the name of a field in your GeoDataset.Add recs(“Region”).Records ‘ iterate through the records and accumulate values Do While Not recs. Then the code specifies the properties of the Renderer.Count ‘ set the values for the renderer i = 0 For Each s In strs .ValueCount = strs. Press F5 and click the button to redraw the map based on the value of a field.EOF strs. To try this example. Option Explicit Private Sub Command1_Click() Dim recs As MapObjects2. DotDensityRenderer Object.field = “Region” . LabelPlacer Object. 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. ClassBreaksRenderer Object. 442 MapObjects Programmer’s Reference To draw with a single symbol.Refresh End Sub ProgrammersReference.Strings Dim i As Integer Dim s As Variant Set recs = Map1.Layers(0).ValueMapRenderer Set Map1.Layers(0).MoveNext Loop ‘ set up a ValueMap renderer Dim r As New MapObjects2.Value recs.Recordset Dim strs As New MapObjects2.pmd 442 10/28/2004.Value(i) = s i = i + 1 Next s End With Map1. LabelRenderer Object. In this case. the code creates a ValueMapRenderer object and associates it with the MapLayer. 10:00 AM .Renderer = r With r . MapObjects Programmer’s Reference 443 ReturnDescription Method Applies To GeoCoordSys Object. “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. To try this example.CoordinateSystem. paste the code into the Declara- tions section of a form containing a CommandButton named Command1.ReturnDescription [= coordSys] The ReturnDescription property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 10:00 AM . and a Map named Map1. either a ProjCoordSys or a GeoCoordSys. Press F5 and then click Command1.ReturnDescription. Remarks The ReturnDescription property may be used to return metadata about a ProjCoordSys or GeoCoordSys object. containing one MapLayer which has a coordinate system set. Option Explicit Private Sub Command1_Click() MsgBox Map1.Layers(0).ReturnLineEvent startMeasure. The ReturnDescription property is similar to the Export method on the ProjCoordSys and GeoCoordSys objects. See Also CoordinateSystem Property Example This example uses the ReturnDescription method of the ProjCoordSys or GeoCoordSys objects to display projection information. coordSys A string expression that evaluates to a description of the coordinate system held in the object. endMeasure ProgrammersReference. but can be used by the developer to access the projection metadata directly. Syntax object. ProjCoordSys Object Description Returns a string description of a projected or geographic coordinate system. Syntax Set variable = object.pmd 443 10/28/2004. _ vbInformation. The line you selected is drawn in blue. Measure Property.ReturnLineEvent(100.Print “No event found.Line Set line_event = measured_line. Remarks This method will return a null value where no events are found between the specified mea- sures. Option Explicit Dim gLine As New MapObjects2. and a Map named Map1 with a MapLayer containing line features which have line events. This can also happen if the Line object itself is a multi-part Line. Parts Collection Example This example makes use of the ReturnLineEvent property to return line events occuring on a user-selected line segment. measured_line. the Line object returned could have more than one Part. object An object expression that evaluates to a Line object.e. i. To try this example.” End If As MapObjects allows for the measure of each vertex to be independent. with line events in red. 10:00 AM . Points Collection. copy the code into the Declarations section of a Form that contains a Label named Label1. See Also Point Object.pmd 444 10/28/2004. Dim line_event as MapObjects2. measure values do not have to monotonically increase. This can happen when measure values on the Line are outside of the range of the startMeasure and endMeasure specified but occur between positions on the Line that corre- spond to them. endMeasure A numeric expression that indicates from which measure the end of the returned Line should be taken.Line Dim endM As Double Dim startM As Double Dim selLine As MapObjects2. the following Visual Basic code will determine that line_event has not been set with a new event. Press F5 and click on a line. startMeasure A numeric expression that indicates from which measure the start of the returned Line should be taken.GeoEvent ProgrammersReference. For example. and the startMeasure and endMeasure specified occur on different parts of the Line. Remember that line events on the same Line map overlap. 444 MapObjects Programmer’s Reference The ReturnLineEvent method syntax has these parts: Part Description variable An object expression that evaluates to a Line object. given a Line with measure values between 0 and 50. Right click to zoom in. 200) If line_event Is Nothing Then Debug. Shift As Integer.Value Set selLine = Map1.TrackRectangle ProgrammersReference. endM) If events Is Nothing Then Label1. 10:00 AM .Layers(0).and the last vertex.Parts ‘For each part of the line.Item(0).ReturnLineEvent(startM.Measure endM = partLine. “”) ‘ if a line is found. 1) End If Next partLine End If Else Map1.Caption = “No events” Else Set lineEvents = Map1.ToMapPoint(X. _ Map1.GeoEvent Set events = gLine. X _ As Single.Extent = Map1. Y) ‘ search for a line Dim recs As MapObjects2.Recordset Set recs = Map1.TrackingLayer.1). get the Measure value for the ‘first vertex. MapObjects Programmer’s Reference 445 Private Sub Map1_MouseDown(Button As Integer.TrackingLayer.Measure ‘Return line events between the start and end measure Dim events As MapObjects2.Count .AddEvent(events.Item(partLine.ClearEvents Set gLine = recs(“Shape”).ToMapDistance(150). Y As Single) If Button = 1 Then ‘ convert the point to map coordinates Dim pt As MapObjects2.EOF Then Map1.Points For Each partLine In gLine.Point Set pt = Map1. extract the shape and store it in gLine ‘ variable If Not recs. startM = partLine. this is repeated for each ‘part seperately Dim itemCount As Integer Dim partLine As MapObjects2.AddEvent(gLine.Line Dim lineEvents As New MapObjects2. 0) ‘Get the measure values at the start and end of the line ‘NB: If the line is a multipart.SearchByDistance(pt.pmd 445 10/28/2004.TrackingLayer. Size = 4 . Syntax Set variable = object.Symbol(0) . See Also Point Object. Measure Property Example This example makes use of the ReturnPointEvents property and the ReturnMeasure methods to draw point events occuring on a user-selected line segment.ReturnMeasure point The ReturnMeasure method syntax has these parts: Part Description variable A numeric expression that evaluates to a Double.Style = moSolidLine .SymbolCount = 4 With Map1. object An object expression that evaluates to a Line object. point An object expression that evaluates to a Point object.TrackingLayer.Color = moRed End With 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.SymbolType = moLineSymbol .TrackingLayer. To try this example.Symbol(1) . 446 MapObjects Programmer’s Reference End If End Sub Private Sub Form_Load() Label1. closest to the point the user clicked on.pmd 446 10/28/2004.Size = 2 .Style = moSolidLine . copy the code into the Declarations section of a Form that ProgrammersReference.Caption = “Line Events” Map1.Color = moBlue End With With Map1. 10:00 AM .SymbolType = moLineSymbol .TrackingLayer. TrackingLayer. _ ToMapDistance(150).Size = 6 .GeoEvent Set theSelected = Map1. Y) Set recs = Map1. 10:00 AM .Layers(0).EOF Then Map1. X _ As Single.Points nearMeasure = gLine. Option Explicit Private Sub Form_Load() Map1. “”) ‘ if a line is found.Point Dim recs As New MapObjects2.SymbolType = moPointSymbol . Press F5 and click on a line.Style = moCircleMarker End With End Sub Private Sub Map1_MouseDown(Button As Integer. Y As Single) ‘ convert x and y to a map point Dim pt As MapObjects2.TrackingLayer.Value ‘Get closest measure.TrackingLayer. and return point events Dim nearMeasure As Double Dim events As MapObjects2.ReturnPointEvents(nearMeasure) ‘Show events on Map If Not events Is Nothing Then Map1. extract the shape and store it in gLine ‘variable If Not recs.SymbolCount = 1 With Map1.FlashShape events.Recordset Set pt = Map1.ReturnMeasure(pt) Set events = gLine. events.ClearEvents Dim gLine As New MapObjects2. 0) End If End If End Sub ProgrammersReference.Line Set gLine = recs(“Shape”).Symbol(0) . Shift As Integer. MapObjects Programmer’s Reference 447 contains a Map named Map1 with a MapLayer containing line features which have point events and are measured.pmd 447 10/28/2004.TrackingLayer.SearchByDistance(pt. Map1.Color = moRed .Count Dim theSelected As MapObjects2.ToMapPoint(X.AddEvent(events. measure values do not have to monotonically increase.pmd 448 10/28/2004.e. See Also Point Object.Print “No event found. Measure Property Example See ReturnMeasure Method ProgrammersReference. measured_line. Dim pt_events as MapObjects2. the following Visual Basic code will determine that pt_events has not been set with any new events. 448 MapObjects Programmer’s Reference 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.ReturnPointEvents measure The ReturnPointEvents method syntax has these parts: Part Description variable An object expression that evaluates to a Points collection. Points Collection. Remarks This method will return a null value where no events are found for the specified measure.ReturnLineEvent(100) If pt_events Is Nothing Then Debug. object An object expression that evaluates to a Line object. given a Line with measure values between 0 and 50. Syntax Set variable = object.Points Set pt_events = measured_line. measure A numeric expression that indicates from which measure the events should be returned. a single measure can represent more than one location on a Line.” End If As MapObjects allows for the measure of each vertex to be independent. For example. You can check the Count property of the Points object returned to determine whether this is the case. 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. i. 10:00 AM . In the TextBox.TextSymbol Dim oFnt As New StdFont If Not moLine Is Nothing Then oFnt. useful for controlling the direction of splined text. Syntax object. and a Map named Map1. a TextBox named Text1. and then press F5.Parts(0).Font = oFnt oTsym.Name = “Arial” oFnt. 10:00 AM .pmd 449 10/28/2004. Polygon Object Example This example uses the Reverse method to change the order of all the members of a collection of Points. then track a line to serve as the path for the spline.OLE_HANDLE) Dim oTsym As New MapObjects2.Size = 16 Set oTsym. specify the text to display. MapObjects Programmer’s Reference 449 Reverse Method Applies To Points Collection Description Reverses the order of all members of a Points collection. Option Explicit Dim moLine As MapObjects2.line Private Sub Check1_Click() If Not moLine Is Nothing Then moLine. moLine. paste the code into the Declarations section of a form containing a CheckBox named Check1. See Also Line Object.Text = “” Then Text1.Text. oTsym End If End Sub ProgrammersReference.DrawText Text1.Refresh True End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole. Toggle Check1 to see the effect of Reverse.Reverse The object placeholder represents an object expression that evaluates to an object in the Applies To list.TrackingLayer.Color = moRed If Text1.Text = “MapObjects2” Map1. Remarks The Reverse method is useful for altering the direction of splined text. To try this example.Reverse Map1. To try this example. Top Property Example This example uses the Right property to draw a line that intersects an ellipse at its rightmost point. X _ As Single.pmd 450 10/28/2004.SymbolType = moFillSymbol ProgrammersReference. The circle draws in red and the line will draw in blue.Right [= value] The Right property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Drag a circle on the map.line Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.Symbol If Not oEllipse Is Nothing Then With oSymbol .Caption = “Reverse” Text1. Y As Single) Set moLine = Map1. Syntax object.Refresh True End Sub Private Sub Form_Load() Check1. 450 MapObjects Programmer’s Reference Private Sub Map1_MouseDown(Button As Integer.OLE_HANDLE) Dim oSymbol As New MapObjects2. paste the code into the Declarations section of a form containing a Map named Map1 and press F5. 10:00 AM .TrackLine Map1. Rectangle Object Description Returns or sets the distance between the internal right edge of an object and the left edge of its container. Option Explicit Dim oEllipse As Ellipse Dim oPoints As New MapObjects2.Points Dim oLine As New MapObjects2. Shift As Integer. value A numeric expression specifying distance.Text = “” End Sub Right Property Applies To Ellipse Object. See Also Left Property.TrackingLayer. oSymbol ‘draw the line ‘clear out the points oPoints. Shift As Integer.line oPoint.Parts.Size = 2 Map1. MapObjects Programmer’s Reference 451 .Remove 1 oPoints. oSymbol ‘draw the ellipse .Style = moSolidFill .Top oPoints.x = oEllipse. y As Single) Dim oPoint As New MapObjects2.Add oPoint Set oPoint = Nothing oPoint.Right oPoint.Right oPoint.Bottom oPoints. 10:00 AM .Color = moRed .Add oPoint oLine.DrawShape oEllipse.Remove 0 End With End If End Sub Private Sub Map1_MouseDown(Button As Integer.DrawShape oLine.TrackingLayer.SymbolType = moLineSymbol .TrackCircle Set oLine = New MapObjects2.y = oEllipse.x = oEllipse.Point Set oEllipse = Map1.y = oEllipse. ProgrammersReference.Color = moBlue .Size = 0 Map1. x _ As Single.Refresh True End Sub RollbackTransaction Method Applies To Recordset Object Description Disregards all of the operations that have taken place within the transaction.Style = moSolidLine .pmd 451 10/28/2004.Add oPoints Set oPoint = Nothing Map1. 452 MapObjects Programmer’s Reference Syntax object. and Label3. Syntax object. SplinedText Property Example This example uses the Rotation property to set the rotation angle of some text on a map. CommitTransaction Method Example See online help for an example of transactions. then the Rotation property of the TextSymbol object associated with the LabelRenderer will be used. Position the Slider so that adequate space for the labels remains below it. any settings for the Rotation property will be ignored. Move the Slider to control the angle of rotation. If you specify SplinedText. 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.pmd 452 10/28/2004.RollbackTransaction The RollbackTransaction method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object that has an open transaction. 10:00 AM . a Slider control named Slider1.Rotation [= angle] The Rotation property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. See Also RotationField Property. Label2. Remarks If you provide a RotationField for a LabelRenderer object. Symbol Object Description Returns or sets the rotation angle of an object. the rotation of labels will be driven by the attribute values. To try this example. Press F5. Rotation Property Applies To TextSymbol Object. See Also GeoDataset Object. If you do not. and a Map named Map1 that contains at least one MapLayer. angle A numeric expression specifying the counter-clockwise rotation angle associated with the object in degrees. ProgrammersReference. paste the code into the Declarations section of a form containing three Label controls named Label1. Caption = Slider1.Size = 16 End With With oTextSym .Center. MapObjects Programmer’s Reference 453 Option Explicit Dim oTextSym As New MapObjects2.Max = 360 .Value End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer. oTextSym End If bTextAlreadyDrawn = True End Sub Private Sub Form_Initialize() Dim oFont As New StdFont With oFont .Height = 0 ‘use font size in points.Caption = Slider1. 10:00 AM .Height End With With Label2 ProgrammersReference.Font = oFont End With With Slider1 .Left .Value Map1. not map units Set .Extent. ByVal _ canceled As Boolean.Color = moBlack .Top + Slider1.TickFrequency = 45 End With With Label1 .pmd 453 10/28/2004. Map1.OLE_HANDLE) Static bTextAlreadyDrawn As Boolean If bTextAlreadyDrawn Then Map1.Min ‘default is 0 .TextSymbol Private Sub Slider1_Change() oTextSym.Top = Slider1.Refresh Label3.name = “Arial” .DrawText “MapObjects2”.Rotation = Slider1.Left = Slider1.AutoSize = True . ByVal hDC As Stdole.LargeChange = 15 . If the CopyMap.Left = Slider1.Max . ExportMap2. ExportMap. ProgrammersReference. 454 MapObjects Programmer’s Reference . If you wish to preserve the exact dimensions of a rectangle before rotating a Map.Top . value A numeric expression that represents the clockwise angle of rotation in degrees.pmd 454 10/28/2004.AutoSize = True .Width .Label1. any ImageLayers contained within the Map will not be visible. Remarks If the RotationAngle property is set to a non-zero angle. as a rotated Rectangle will no longer be rectangular in shape.RotationAngle [= value] The RotationAngle property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. any rectangles which have been added to the map may change dimensions. you should first convert that Rectangle to a Polygon. However.Caption = Int((Slider1. OutputMap.Top = Label1.Width * 0. therefore any shapes which were drawn on the Map will also be drawn at that rotated angle. OutputMap2 or PrintMap methods are called.Left + Slider1.Min) / 2) . If the map is rotated.Width .Top = Label1.Slider1. Syntax object. The rotation is measured about the center of the Map’s Extent.Left = Slider1.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.Max .Top End With With Label3 .Left + (Slider1. the TrackingLayer is also rotated. 10:00 AM .AutoSize = True . The RotationAngle property is not supported for ImageLayers for map output.Caption = Slider1. you will see the contents of all MapLayers and ImageLayers rotated. MapObjects Programmer’s Reference 455 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. Setting the RotationAngle will cause a Refresh of the Map control. See Also MapLayer Object 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 Private Sub Command1_Click() Map1.RotationAngle = Map1.RotationAngle + 30 End Sub Private Sub Command2_Click() Map1.RotationAngle = Map1.RotationAngle - 30 End Sub RotationField Property Applies To LabelRenderer Object, ValueMapRenderer Object Description Returns or sets the field that contains rotation information for an object Syntax object.RotationField [= value] The RotationField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. value A string expression that specifies a name of a field in a Recordset. If specified, the LabelRenderer makes use of the value of the specified field to set the counter-clockwise rotation angle of the label. The ValueMapRenderer makes use of the value of the specified field to set the counter-clockwise rotation angle of the Symbol associated with a Point feature. ProgrammersReference.pmd 455 10/28/2004, 10:00 AM 456 MapObjects Programmer’s Reference 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. See Also TextSymbol Object 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 Private Sub Command1_Click() Dim oRenderer As New MapObjects2.LabelRenderer Dim oFont As New StdFont ‘ Set up a label renderer and associate it with the map layer If Combo1.ListIndex <> -1 And Combo2.ListIndex <> -1 Then With oFont .name = “Arial” .Size = 8 End With With oRenderer .RotationField = Combo1.List(Combo1.ListIndex) .Field = Combo2.List(Combo2.ListIndex) .SymbolCount = 1 Set .Symbol(0).Font = oFont End With With Map1 .Layers(0).Renderer = oRenderer .Refresh End With End If End Sub Private Sub Form_Load() ProgrammersReference.pmd 456 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 457 Dim oField As MapObjects2.Field Set oMapRecords = Map1.Layers(0).Records ‘ Add field names to the combo boxes For Each oField In oMapRecords.Fields If oField.Type < moString Then Combo1.AddItem oField.name End If Combo2.AddItem oField.name Next ‘ Set up and position the controls With Label1 .Caption = “Rotation Field” .AutoSize = True .Left = Map1.Left .Top = Map1.Top + Map1.Height + (Label1.Height * 2) End With With Label2 .Caption = “Text Field” .AutoSize = True .Left = Map1.Left .Top = Label1.Top + (Label2.Height * 2) End With 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 ProgrammersReference.pmd 457 10/28/2004, 10:00 AM 458 MapObjects Programmer’s Reference ScaleRectangle Method Applies To Rectangle Object Description Scales a Rectangle object by a specified factor. Syntax object.ScaleRectangle factor The ScaleRectangle method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 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. See Also Intersects Method, Extent Property 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 Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x _ As Single, y As Single) Dim Rect As MapObjects2.Rectangle Set Rect = Map1.Extent If Button = 1 Then ‘zoom in Rect.ScaleRectangle (0.5) Map1.Extent = Rect Else ‘zoom out Rect.ScaleRectangle (2#) Map1.Extent = Rect End If End Sub ScalingField Property Applies To ValueMapRenderer Object ProgrammersReference.pmd 458 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 459 Description Returns or sets the Field whose values determine the factor by which to scale the Symbol associated with the features. Syntax object.ScalingField [= value] The ScalingField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. value A string expression that specifies a name of a field in a Recordset of a MapLayer that contains Point features. If specified, the ValueMapRenderer makes use of the value of the specified field to scale the Symbol associated with the point features. The field stores a factor; therefore if the field contains the value 2, the size of the symbol for the feature as specified by the Size property will be doubled. If the field contains the value 1, the size will remain as specified by the Size property. See Also TextSymbol Object 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 Private Sub Form_Load() Dim oRecset As MapObjects2.Recordset Dim oField As MapObjects2.Field Set oRecset = Map1.Layers(0).Records For Each oField In oRecset.Fields List1.AddItem oField.Name Next End Sub Private Sub List1_DblClick() Dim oRenderer As New MapObjects2.ValueMapRenderer Dim l As Long ProgrammersReference.pmd 459 10/28/2004, 10:00 AM 460 MapObjects Programmer’s Reference Set Map1.Layers(0).Renderer = oRenderer 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. Syntax object.ScrollBars [= value] The ScrollBars property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. value A boolean expression that determines whether the object has scrollbars, as described in Settings. Settings For a Map object, the ScrollBars property settings are: Setting Description True (Default) The Map can have a horizontal and a vertical scroll bar. See Remarks. False Scrollbars will not display next to the Map. ProgrammersReference.pmd 460 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 461 Remarks If ScrollBars is True and the Map control’s 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 map’s right border. If the Map control’s 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. See Also Appearance Property, BackColor Property, BorderStyle Property 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 Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X _ As Single, Y As Single) Dim Rectangle As MapObjects2.Rectangle If Shift = 0 Then Set Rectangle = Map1.TrackRectangle If Not Rectangle Is Nothing Then Map1.Extent = Rectangle Else Map1.Pan End If End Sub SearchExpression Method Applies To MapLayer Object, Table Object Description Creates a Recordset object from an expression. Syntax Set variable = object.SearchExpression( expression) The SearchExpression method syntax has these parts: ProgrammersReference.pmd 461 10/28/2004, 10:00 AM 462 MapObjects Programmer’s Reference Part Description variable A variable that has been declared as a Recordset. object An object expression that evaluates to an object in the Applies To list. 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 Enclose field criteria by single quotes, e.g. States = ‘California’. 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 Recordset’s EOF property will be True. The SearchExpression method is not supported for INFO tables. A SearchExpression operating on a field in a related SDE table may be time-consuming, therefore limit the expression to core SQL grammar. 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. ProgrammersReference.pmd 462 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 463 See Also SearchShape Method 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 Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal _ canceled As Boolean, ByVal hDC As Stdole.OLE_HANDLE) Dim sel As MapObjects2.Recordset If Text1.Text <> “” Then Set sel = Map1.Layers(0).SearchExpression(Text1.Text) If Not sel.EOF Then Dim sym As New MapObjects2.Symbol sym.SymbolType = moFillSymbol sym.Style = moSolidFill sym.color = moYellow Map1.DrawShape sel, sym End If End If End Sub Private Sub Command1_Click() Map1.Refresh End Sub 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. Constant Value Description moExtentOverlap 0 Returns features whose extents overlap the extent of the search feature. (Can be used with a 3D Rectangle for searching on 3D features). ProgrammersReference.pmd 463 10/28/2004, 10:00 AM 464 MapObjects Programmer’s Reference moCommonPoint 1 Returns features that share at least one identi- cal common point with the search feature. moLineCross 2 Returns features that intersect the search feature. moCommonLine 3 Returned features must share at least one identical common line segment with the search feature. moCommonPointOrLineCross 4 Returns features that share a common point with the search feature or intersect it. moEdgeTouchOrAreaIntersect 5 Returns features that touch the search feature, are wholly or partially within the search feature, or wholly or partially contain the search feature(s). moAreaIntersect 6 If the search feature is a polygon feature, returns features that are wholly or partially contained within it, but not adjacent to it. Otherwise, the features themselves must be polygon features, and the method returns features that wholly or partially contain the search feature. This method is similar to the moContainedBy search method, with the difference that the feature may contain the shape, OR the shape contain the feature. moAreaIntersectNoEdgeTouch 7 Same as moAreaIntersect, but the boundaries of the search feature and the feature may not intersect or touch. moContainedBy 8 Returns features that wholly contain the search feature. If the feature is a polygon feature, the search feature must be wholly inside it, inclusive of the feature’s boundary. If the feature is a line feature, the search feature must lie along the feature’s path. If the feature is a point feature, the search feature must be on one of its vertexes. moContaining 9 Returns features that are wholly contained within the search feature. ProgrammersReference.pmd 464 10/28/2004, 10:00 AM MapObjects Programmer’s Reference 465 moContainedByNoEdgeTouch 10 Returns features that wholly contain the search feature, not inclusive of the search feature’s boundary. The feature must be a polygon feature, the search feature must be wholly inside it, and their boundaries may not intersect or touch. moContainingNoEdgeTouch 11 Returns features that are wholly within the search feature, not inclusive of the search feature’s boundary. The search feature must be a polygon feature, the feature must be wholly inside it, and their boundaries may not inter- sect or touch. moPointInPolygon 12 Returns polygon features that contain the first coordinate of the search feature. moCentroidInPolygon 13 Returns polygon features whose centroids are contained by the shape moIdentical 14 Returns features that are identical to the search feature. Considers feature type and coordinate description. Typically used to find duplicate data. See Also MapLayer Object, SearchShape Method 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. Syntax Set variable = object.SearchByDistance( shape, tolerance, expression) The SearchByDistance method syntax has these parts: Part Description variable A object expression that has been declared as a Recordset. ProgrammersReference.pmd 465 10/28/2004, 10:00 AM TrackRectangle End If End Sub ProgrammersReference. expression A string expression that forms the ‘where’ clause portion of an SQL state- ment. SearchByDistance will position the Recordset at the first record and then position the Recordset back at the first record after the method completes. x _ As Single. Note that MapObjects follows ANSI SQL. shape An object expression that evaluates to a Point object. VPF file or CAD file (you cannot pass a Recordset derived from an SDE layer). a Polygon object. then click drag a circle to indicate the selection.Extent = Map1. tolerance A numeric expression that evaluates to the distance from the point that the method uses to determine which features to select. ARC/INFO coverage.TrackCircle Map1. you can specify a Recordset object that represents all or some of the features of an ESRI shapefile. SearchExpression Method 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. Also. Option Explicit Dim MyEllipse As New MapObjects2.Ellipse Private Sub Map1_MouseDown(Button As Integer. y As Single) If Button = 1 Then Set MyEllipse = Map1. a Rectangle object or a Points collection. see Visual Basic Help’s ‘Comparison of Microsoft Jet Database Engine SQL and ANSI SQL’ topic. Note that the AfterLayerDraw Event code contains the SearchByDistance method. 466 MapObjects Programmer’s Reference object An object expression that evaluates to an object in the Applies To list. 10:00 AM . not Jet Database Engine SQL. 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. For more information. In addition to shape objects.pmd 466 10/28/2004. a Line object. Remarks If you pass a Recordset object as the shape parameter.Refresh Else Map1. See Also SearchShape Method. Shift As Integer. Press F5. if you want to zoom in on the Map. you can use the right mouse to drag a new Extent. SearchByDistance _ (MyEllipse.Style = moLightGrayFill Map1. and the logical search criteria in an expression.Width * 0.Symbol sym.color = moLightYellow If Not recset.Center. shape An object expression that evaluates to a Point object. MapObjects Programmer’s Reference 467 Private Sub Map1_AfterLayerDraw(ByVal index As Integer. In addition to ProgrammersReference. If you omit the expression. 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. ByVal hDC As Stdole. 10:00 AM .pmd 467 10/28/2004. “”) Dim sym As New MapObjects2. The expression is an SQL ‘where’ clause.Style = moSolidFill sym. object An object expression that evaluates to an object in the Applies To list. Syntax Set variable = object.EOF Then Map1.5 Set recset = Map1.DrawShape recset. expression ) The SearchShape method syntax has these parts: Part Description variable A variable that has been declared as a Recordset.color = moRed sym.DrawShape MyEllipse. ByVal _ canceled As Boolean. sym End If sym. radius. a Rectangle object or a Points collection.OLE_HANDLE) Dim radius As Double If Not MyEllipse Is Nothing Then Dim recset As MapObjects2. the method returns a Recordset of all features that meet the spatial search criteria. a Polygon object. searchMethod.SearchShape( shape.Recordset radius = MyEllipse.SymbolType = moFillSymbol sym. a Line object. by passing an empty string (“”).Layers(0). 10:00 AM . To try this example. See Also Recordset Object. ARC/INFO coverage. 468 MapObjects Programmer’s Reference shape objects. use the Intersects method to test if the Extent of the shape may lie outside the Extent of the MapLayer. the shape must lie within the bounds of the MapLayer object’s Extent. coverage. the search method will default to moExtentOverlaps.pmd 468 10/28/2004. not Jet Database Engine SQL. VPF file or CAD file (you cannot pass a Recordset derived from an SDE layer). you can specify a Recordset object that represents all or some of the features of an ESRI shapefile. If your MapLayer contains features with Z values. VPF or CAD file. or a Points object. SearchExpression Method Example This example uses the SearchShape method to highlight the features that are adjacent to a feature on a MapLayer you click. If you form the query so that it works on a field in a related SDE table. Note that MapObjects follows ANSI SQL. If you pass an invalid SearchMethodConstant. When using SearchShape on a MapLayer derived from an SDE layer. see Visual Basic Help’s ‘Comparison of Microsoft Jet Database Engine SQL and ANSI SQL’. Note that moExtentOverlap is the only SearchMethodConstant that allows three-dimensional searches. in addition to their X and Y coordinates. you can use the Intersect method to clip the search shape to the extent of the MapLayer. If it does. performing a moContainedBy with a multipart Polygon. limit the expression to core SQL grammar for a WHERE clause. 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 use a three-dimensional Rect- angle as your search shape. expression A string expression that forms the ‘where’ clause portion of a SQL statement. Features are selected based on their Z coordinates. Settings The settings for opType are SearchMethodConstants Remarks For more information. When performing a search with a multipart Line or Polygon. paste the code into the Declarations ProgrammersReference. For example. SearchByDistance Method. features will only be returned which fully contain all parts of the Polygon. 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. To ensure your search shape is valid. before performing the SearchShape method. the parts of the shape act as a single shape. If you pass a Recordset object as the shape parameter. You can only pass a Recordset as a shape when searching on a MapLayer based on a shapefile. y) Set recset1 = Map1. “”) Set recset2 = Map1. 10:00 AM .OLE_HANDLE) Call DrawSelection(recset2. MapObjects Programmer’s Reference 469 section of a form containing a Map named Map1 that has a MapLayer with polygon features.DrawShape recs. ByVal hDC As Stdole. moMagenta) Set recset1 = Nothing Set recset2 = Nothing End Sub Private Sub Map1_MouseDown(Button As Integer.Symbol sym.pmd 469 10/28/2004.SearchShape(pt.Style = moSolidFill sym.color = color If Not recs Is Nothing Then Map1. “”) Map1.Layers(0). x _ As Single. moDarkGreen) Call DrawSelection(recset1.ToMapPoint(x. Option Explicit Dim recset1 As MapObjects2.Layers(0). y As Single) Dim pt As MapObjects2. Shift As Integer.Refresh End Sub Sub DrawSelection(recs As MapObjects2. Press F5. Note that the example highlights the original feature in addition to those features adjacent to it.Recordset. sym End If End Sub SecondDirection Property Applies To GeoTransformation Object ProgrammersReference.SymbolType = moFillSymbol sym.color = moPaleYellow End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer.Recordset ‘original polygon Dim recset2 As MapObjects2.Symbol. then click a feature. color) ‘ draw the features of a RecordSet Dim sym As New MapObjects2. moCommonPoint.Recordset ‘neighbors Private Sub Form_Load() Map1.SearchShape(recset1. ByVal _ canceled As Boolean.Point Set pt = Map1.Layers(0). moPointInPolygon. See Also GeoCoordSys Object. dirConstant A numeric expression that specifies the SecondDirection of the GeoTransformation. 10:00 AM . 470 MapObjects Programmer’s Reference 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.e. you have set both Type and SecondType) you should set both the Direction and SecondDirection properties appro- priately. Remarks If you are using two different Types on the GeoTransformation. (i. as described in Settings.SecondName [=geoTConstant] The SecondName property syntax has these parts: Part Description object An object expression that evaluates to a GeoTransformation object. Settings The settings for dirConstant are DirectionConstants. Syntax object. ProjCoordSys Object Example See GeographicTransformation Property SecondName Property Applies To GeoTransformation Object Description Returns a value that identifies the SecondName of a pre-defined GeoTransformation (i.e. geoTConstant A string expression that specifies the SecondName of the GeoTransformation.pmd 470 10/28/2004.SecondDirection [=dirConstant] The SecondDirection property syntax has these parts: Part Description object An object expression that evaluates to a GeoTransformation object. the name of the second-stage transformation set using the SecondType method) Syntax object. ProgrammersReference. 10:00 AM . this system. MapObjects Programmer’s Reference 471 Remarks When using one of the pre-defined GeographicTransformationConstants. the SecondName property can be read after the SecondType property has been set. if your data has a projected coordinate system of moProjCS_BritishNationalGrid and you wish to transform your data to the moProjCS_IrishNationalGrid coordinate system. For example. Syntax object. neither of which is a WGS 1984 coordinate system. as described in Settings. Remarks The SecondType property is used when a geographic transformation is required between two coordinate systems. you need to transform not only between the two projected coordinate systems (ProjCoordSys). geoTConstant A numeric expression that specifies the SecondType of the GeoTransformation. SecondType [=geoTConstant] The SecondType property syntax has these parts: Part Description object An object expression that evaluates to a GeoTransformation object. The majority of the pre-defined Geographic Transformation Constants are either from. For the example above. When the above GeoTransformation object is used in a Transform method (or by a MapLayer object) the SecondType transformation will be reversed.GeoCoordSys) that each projected coordinate system is based upon. See Also GeoCoordSys Object. or to. but between the Datum of the geographic coordinate system (ProjCoordSys. Settings The settings for geoTConstant are GeographicTransformationConstants. to return the name for the transformation which is set. ProjCoordSys Object Example See GeographicTransformation Property SecondType Property Applies To GeoTransformation Object Description Sets or returns a value that identifies the SecondType of the GeoTransformation object.pmd 471 10/28/2004. set the GeoTransformation Type property to be moGeoTransformation_OSGB1936_To_WGS1984_1 and the SecondType property to be moGeoTransformation_TM65_To_WGS1984. You need to define a two-stage geographic transformation. resulting in a two-stage ProgrammersReference. 472 MapObjects Programmer’s Reference transformation allowing for the different datum that the two coordinate systems are based upon.pmd 472 10/28/2004. 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. See Also GeoCoordSys Object. See Also User Property. Table Object Description Returns or sets the name of a Server for an SDE DataConnection.Set( index. ProjCoordSys Object Example See GeographicTransformation Property Server Property Applies To DataConnection Object. servername A string expression that evaluates to a valid server name for the specified DataConnection. Syntax object. or Table. 10:00 AM . Point) The Set method syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Password Property Example See Password Property Set Method Applies To Points Object.Server [= servername] The Server property syntax has these parts: Part Description object An object expression that evaluates to a DataConnection object. Syntax object. ProgrammersReference. X = oPoly.Parts(0) For i = 0 To oPoints.Parts(0).Width / 20 oPoint.Item(iVertex). Track a polygon on the Map and then use the right mouse button to select a vertex to move. Remove Method Example This example uses the Set method to change the position of a Point in a collection of Points.Extent. 10:00 AM .1 ‘2 If oPoints(i). MapObjects Programmer’s Reference 473 index An integer that represents the position of the member in the Parts collection or Points collection.Count .Points Dim i As Integer fTol = Map1.pmd 473 10/28/2004. See Also Insert Method. Option Explicit Dim moPoly As MapObjects2.Polygon Sub MoveVertex(iVertex As Integer.Y + fOffset Set oPoints = oPoly.Parts(0) If oPoints. To try this example. Point An object expression that evaluates to a Points collection or Point object.Item(iVertex). and then press F5.Point Dim oPoints As MapObjects2. paste the code into the Declarations section of a form containing a Map named Map1.Count >= 3 Then oPoints.DistanceTo(oPoint) < fTol Then SelectVertex = i Exit Function End If Next ProgrammersReference.X + fOffset oPoint.Points Dim fOffset As Double If iVertex >= 0 Then fOffset = oPoly. oPoly As _ Polygon) As Integer Dim fTol As Double Dim oPoints As MapObjects2.Set iVertex. oPoint End If End If End Sub Function SelectVertex(oPoint As MapObjects2.Point.Parts(0).Y = oPoly.ToMapDistance(100) Set oPoints = oPoly. oPoly As Polygon) Dim oPoint As New MapObjects2. SymbolType = moPointSymbol oPtSym.TrackingLayer. 10:00 AM . Y As Single) Dim iVertex As Integer If Button = 1 Then Set moPoly = Map1.Left = 0: oRect.Symbol Dim oPtSym As New MapObjects2.Color = moRed Map1.OLE_HANDLE) Dim oPoint As MapObjects2.Top = 100 Map1.Parts(0) Map1. oSym For Each oPoint In moPoly.DrawShape oPoint.Refresh True End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.Point Dim oSym As New MapObjects2. Shift As Integer. X _ As Single.DrawShape moPoly. 474 MapObjects Programmer’s Reference SelectVertex = -1 End Function Private Sub Map1_MouseDown(Button As Integer. moPoly) If iVertex <> -1 Then MoveVertex iVertex.Extent = oRect End Sub ProgrammersReference.ToMapPoint(X.TrackPolygon ElseIf Not moPoly Is Nothing Then iVertex = SelectVertex(Map1.Bottom = 0: oRect. moPoly End If End If Map1. Y).Color = moPaleYellow oPtSym.pmd 474 10/28/2004.Symbol If Not moPoly Is Nothing Then oSym. oPtSym Next End If End Sub Private Sub Form_Load() Dim oRect As New Rectangle oRect.Right = 100: oRect. Measure Property Example See OffsetMeasures Method 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. Remarks This method takes the value startMeasure and applies it to the first vertex of the Line.SetMeasures startMeasure. startMeasure A numeric expression that indicates from which measure the start value should be taken. endMeasure The SetMeasures method syntax has these parts: Part Description object An object expression that evaluates to a Line object. ProgrammersReference. MapObjects Programmer’s Reference 475 SetMeasures Method Applies To Line Object Description Calculates a new measure value for every vertex of a Line object. Similarly.pmd 475 10/28/2004. endMeasure A numeric expression that indicates from which measure the end value should be taken. the endMeasure value is applied to the last vertex of the Line. Syntax object.SetMeasuresAsLength The SetMeasuresAsLength method syntax has these parts: Part Description object An object expression that evaluates to a Line object. 10:00 AM . See Also Point Object. Syntax object. Points Collection. Each intermediate vertex is then assigned a measure value by linear interpolation between the startMeasure and endMeasure values. Points Collection. 476 MapObjects Programmer’s Reference Remarks The value of the measure on each vertex is calculated using the cumulative distance of the vertex. read the ParameterTypeConstants page to check if a certain parameter is used. ParameterType Constants Example See GetParameter method ShapeType Constants MapObjects defines the following type constants to define the different types of shape that are supported.SetParameter paramType. See Also Point Object. See Also GetParameter Method. as specified in Settings paramValue A numeric expression specifying the value to be set for the parameter specified. from the start point of the Line. This constant is for use with MapLayer objects to identify what type of shape is ProgrammersReference. If the specified parameter is unset for the object. A value of zero is also a valid value for certain objects. 10:00 AM . GeoTransformation Object Description Sets a specific coordinate transformation parameter for a ProjCoordSys object or a GeoTransformation object.pmd 476 10/28/2004. GetParameter will return a value of zero. Measure Property Example See MultiplyMeasures Method SetParameter Method Applies To ProjCoordSys Object. Settings The settings for paramType are ParameterTypeConstants Remarks Not all ParameterTypeConstants are used by every GeoTransformation or ProjCoordSys object. If in doubt. paramValue The SetParameter method syntax has the following object qualifier and arguments: Part Description object An object expression that evaluates to an object in the Applies To list. Syntax object. along the Line . paramType A value or constant that identifies which parameter’s value is to be set. ShapeType The ShapeType property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Return Values The return values for ShapeType are ShapeTypeConstants See Also LayerType Property Example This example uses the ShapeType property to report on the kind of features stored in each MapLayer of a Map. Polygon Object. Ellipse Object ShapeType Property Applies To MapLayer Object. Rectangle Object. and a Map named Map1 that has at least one MapLayer. 10:00 AM .pmd 477 10/28/2004. Option Explicit ProgrammersReference. Point Object. Ellipse Object Description Returns a value that indicates the type of geometric shape associated with a MapLayer or an individual shape object. Line Object. Line Object. To try this example. a CommandButton named Command1. Point Object. Polygon Object. Rectangle Object. paste the code into the Declarations section of a form containing a ListBox named List1. MapObjects Programmer’s Reference 477 stored in the layer. Syntax object. Using the read-only ShapeType property on any of these objects returns one of these values: Constant Value Description moShapeTypePoint 21 Point features moShapeTypeLine 22 Line features moShapeTypePolygon 23 Polygon features moShapeTypeMultipoint 24 Multipoint features (Points collection) moShapeTypeRectangle 25 Rectangle features moShapeTypeEllipse 26 Ellipse features See Also MapLayer Object. or similarly with any unknown shape object to identify what type it is. Press F5 and click Command1. 478 MapObjects Programmer’s Reference Private Sub Command1_Click() Dim shptype As Variant Dim l As MapObjects2.ShowOutline [= boolean] The ShowOutline property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.pmd 478 10/28/2004. Syntax object.Layers Select Case l.AddItem l.shapeType Case moPoint ’21 shptype = “point” Case moLine ’22 shptype = “line” Case moPolygon ’23 shptype = “polygon” End Select List1.MapLayer For Each l In Map1. False Chart element does not have an outline. See Also ChartRenderer properties Example See ChartRenderer Object ProgrammersReference. Settings The settings for boolean are: Setting Description True (Default) Chart element has an outline. 10:00 AM . boolean A boolean expression specifying whether the slices or bars will have an outline or not as indicated in Settings.Name & “: “ & shptype Next l End Sub ShowOutline Property Applies To ChartRenderer Object Description Determines whether or not the ChartRenderer will outline the slices or bars that form its charts. Syntax object.Min = 4 Slider1.Top ProgrammersReference. paste the code into the Declarations section of a form containing two Label controls named Label1 and Label2. Move the Slider to control the size of the Symbol.Max = 12 Slider1. See Also Style Property Example This example uses the Size property to control the size in points of the Symbol representing features of a MapLayer.Left = Slider1.AutoSize = True Label2.Top + Slider1.Max Label1.AutoSize = True Label1.Left = Slider1.Label1.Size [= number] The Size property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. and a Map named Map1 whose topmost MapLayer represents point features.Layers(0). MapObjects Programmer’s Reference 479 Size Property Applies To Symbol Object Description Returns or sets the size of a Symbol object.TickFrequency = 2 Label1. 10:00 AM .Caption = Slider1.Top = Label1. Position the Slider so that adequate space for the labels remains below it. To try this example.Height Label2. a Slider control named Slider1.Symbol.Refresh End Sub Private Sub Form_Initialize() Slider1.Left Label1.pmd 479 10/28/2004.Min Label2. Option Explicit Private Sub Slider1_Change() Map1. Press F5.Left + Slider1.Width . number A numeric expression specifying the size of the font in points.Width Label2.Top = Slider1.LargeChange = 4 Slider1.Caption = Slider1.Value Map1.Size = Slider1. If you want a constant size for the radius of all pie charts. and Precinct 3 will have a pie chart whose radius is 10 points. then the chart is not drawn. 480 MapObjects Programmer’s Reference 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). If the SizeField value is zero. Remarks You must set a value for MinPieSize and MaxPieSize to enable the SizeField functionality.pmd 480 10/28/2004. the ChartRenderer sets the constant size of the radius of all pie charts to 20 points. Syntax object. the ChartRenderer makes use of the values of the specified fields to set the size of the pie chart associated with the features. value A string expression that specifies a name of a field in a Recordset of the MapLayer associated with the ChartRenderer. 10:00 AM .SizeField [= value] The SizeField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 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. then Precinct 1 will have a pie chart whose radius is 15 points. MaxPieSize Property Example See ChartRenderer Object ProgrammersReference. Given a Recordset that has the following values: Precinct Democrat Republican Independent TurnoutPct 1 30 40 10 60 2 50 20 15 75 3 55 45 30 45 If you set MinPieSize of 10 and MaxPieSize of 20 and SizeField is TurnOutPct. The values in the SizeField are scaled between the minimum and maximum size values. By default. See Also MinPieSize Property. Precinct 2 will have a pie chart whose radius is 20 points. If specified. Layers(“Counties”). those features whose Field values are greater than category delimited by Break(BreakCount). using the NorthEast sample data. Option Explicit Private Sub Command1_Click() Dim i As Integer Dim oMapLayer As MapObjects2. Syntax object.SizeSymbols startSize.Symbol. 10:00 AM . endSize The SizeSymbols method syntax has these parts: Part Description object An object expression that evaluates to a ClassBreaksRenderer object.Visible = True ‘ show Centers Map1.Color = moPaleYellow ProgrammersReference. startSize A numeric expression specifying the size of the symbol in points to assign to the first category. endSize A numeric expression specifying the size of the Symbol in points to assign to the last category. You will have to change the example to MapLayer and Field names for your data.Layers(“necenter”). “P_OTHER” is a numeric field that you should change to the name of a numeric field appropriate to your data. The data named “Centers” represents place points that fall at the center of the data named “Coun- ties”.pmd 481 10/28/2004. To try this example.MapLayer Dim oStats As MapObjects2. Press F5 and click Command1. MapObjects Programmer’s Reference 481 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. RampColors Method 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.Statistics Dim oClassRend As New MapObjects2. 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. See Also Color Constants. The example makes use of data that is specifically named.ClassBreaksRenderer Dim fBreakVal As Double Map1. delimited by the value held in the Break(0) property. Records.Field = “P_OTHER” Set oStats = oMapLayer.CalculateStatistics(“P_OTHER”) ‘ calculate breaks away from the mean in both directions.BreakCount = . 10:00 AM .Break(.Color = moRed Next End With Map1.pmd 482 10/28/2004.BreakCount .1) = fBreakVal End If fBreakVal = fBreakVal + oStats.BreakCount + 1 .SizeSymbols 3. 8 ‘size in pixels For i = 0 To .Layers(“necenter”) Set oMapLayer.Mean .SymbolType = moPointSymbol .Max Then .StdDev Next ‘ create graduated symbols of the same color . Syntax object. 482 MapObjects Programmer’s Reference Set oMapLayer = Map1.(oStats.StdDev * 3) For i = 0 To 6 If fBreakVal >= oStats.Renderer = oClassRend With oClassRend .BreakCount .Refresh End Sub SpellingSensitivity Property Applies To Geocoder Object Description Returns or sets the value for spelling sensitivity that associates with a Geocoder object. ‘ only add those breaks that are within the range of values fBreakVal = oStats.Min And fBreakVal <= _ oStats.Symbol(i).SpellingSensitivity [ = value] ProgrammersReference. A low value will allow “Mane”. “Main” to be treated as match candidates for “Main”. For a complete listing. those less than 1:5. it accepts values between 0 and 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. the Spheroid used to approximate the earth is often treated as a true sphere. This property only applies to match key fields in SearchQueries which are prefixed with a question mark. 10:00 AM . Type Property Spheroid Object A geographical coordinate system is based upon a spheroidal approximation of the shape of the earth. The lower the value. MapObjects Programmer’s Reference 483 The SpellingSensitivity property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. value 7035. AddIndex Method. SearchQueries Property Example See Geocoder Object Spheroid Constants MapObjects defines over forty constants for use with the Type property of a Spheroid object. The spelling sensitivity does not affect the MatchScore of each candidate. “Maine”. It only controls how many candidates to be considered.pmd 483 10/28/2004. See Also Spheroid Object. To make mathematical calculations easier. The value must be in the range of 0 to 100. The default Spheroid is moSpheroid_Sphere. A higher value will restrict candidates to exact matches. and vice versa. At this scale. The default is 70. See Also Candidate Property. the more likely additional candidates will be retrieved. see the online help.000. GenerateCandidates Method. The default SpellingSensitivity value is 70. This assumption can be used for small-scale maps. the difference between a sphere and a Spheroid cannot be detected on a map. value A numeric expression that represents the value of the spelling sensitivity. ProgrammersReference.000. See Also Datum Object. 484 MapObjects Programmer’s Reference The earth cannot be accurately represented by a true sphere however. Alternatively. PrimeMeridian Object. there you should add a Map named Map1. Spheroid Object Example This example demonstrates how the Spheroid property of the Datum object may be used to filter MapLayers. Datum Object. GeoCoordsys Object. Properties Axis Flattening Name Type See Also Projection Object. the Earth must be treated as a Spher- oid. Option Explicit Dim theSphere As String Dim spheres As New MapObjects2.000. Then press F5. which has semimajor and semiminor axes of different lengths. paste the code into the Declarations section of a new Form which has a combobox named Combo1 and a checkbox named Check1. Also. value An object expression that evaluates to a Spheroid object. Syntax object. so to maintain accuracy for larger-scale maps (scales of 1:1. each having a coordinate system set.Spheroid [= value ] The Spheroid property syntax has these parts: Part Description object An object expression that evaluates to a Datum object.000 or larger). try selecting and deselecting the Checkbox. and selecting different spheroids form the combobox.pmd 484 10/28/2004.Strings Dim userSphere As String ProgrammersReference. which has at least one MapLayer. To try this example. 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. A Spheroid object may be defined by of one of over forty pre-defined SpheroidConstants. a user-defined Spheroid may be created by setting the Axis and Flattening properties to explicitly specify the dimensions of the Spheroid. 10:00 AM . Text _ & “ spheroid” Check1_Click End Sub Private Sub Form_Load() spheres.Visible = False End If Else If layer.ListIndex)) For Each layer In Map1.IsProjected Then If layer.pmd 485 10/28/2004.Visible = True Else layer.Spheroid.Caption = “Show only layers having “ & Combo1.Value = 1 Then userSphere = stripProj(Combo1.Type = _ userSphere Then layer.CoordinateSystem.Layers If layer.List(Combo1.PopulateWithSpheroids Combo1.GeoCoordSys.Type _ = userSphere Then layer.CoordinateSystem.Spheroid. 10:00 AM .CoordinateSystem.Visible = False End If End If Next layer Else For Each layer In Map1.Visible = True Else layer.Clear Dim i As Integer For i = 1 To spheres.Visible = True Next layer End If Map1.Datum.Count ProgrammersReference. MapObjects Programmer’s Reference 485 Private Sub Check1_Click() Dim layer As MapObjects2.MapLayer If Check1.Layers layer.Datum.Refresh End Sub Private Sub Combo1_Click() Check1. boolean A boolean expression specifying whether text will be splined as described in Settings.ListIndex = 0 Check1.1) Next i Combo1. 486 MapObjects Programmer’s Reference Combo1. False The LabelRenderer object will draw the label at the center point of the bounding box of each feature.pmd 486 10/28/2004.1) End Function 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.Caption = “Show only layers having “ & Combo1. Settings The settings for boolean are: Setting Description True (Default) The LabelRenderer object will spline the label associated with each line feature. ProgrammersReference.AddItem spheres(i .Text _ & “ spheroid” End Sub Function stripProj(theProjection As String) As Variant ‘Get position of open bracket Dim openB As Integer openB = InStr(theProjection. _ Len(theProjection) . “[“) stripProj = Left(Right(theProjection. Remarks The LabelRenderer object can spline TrueType fonts only.openB . 10:00 AM .openB). Len(theProjection) .SplinedText [= boolean] The SplinedText property syntax has these parts: Part Description object An object expression that evaluates to a LabelRenderer object. Syntax object. SqueezeFactor [= value] The SqueezeFactor property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. MapObjects Programmer’s Reference 487 If SplinedText is True.pmd 487 10/28/2004. As a general rule. (Data type is Double. the LabelRenderer object ignores the value of SplinedText and displays the label at the center point of the feature’s bounding box. If SplinedText is True. if the MapLayer feature is a point or polygon. however. See Also TextSymbol Object Example See AllowDuplicates Property 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. the LabelRenderer object uses the shape of the line feature as a guide for splining the text. value A numeric expression that represents the percentage of street length that a point is shifted inward from the line segment’s two end points. Syntax object. 10:00 AM . The default SqueezeFactor is 0 indicating that AddressLocations are found along the full length of each line segment representing a road. a SqueezeFactor of 5 percent is suitable to prevent AddressLocations from appearing on intersections. any settings for the Rotation property will be ignored. See Also Candidate Property Example See Offset Property ProgrammersReference.) Remarks SqueezeFactor values may range from 0 to less than 100. and place them all in the same directory as the . If no intersection is considered. ProgrammersReference. the address string must undergo two processes of standardization. 10:00 AM . However.tbl). an address standardization will also require files with . You can create a Standardizer object and set the rule command files in Visual Basic with code like this: Dim stan as New MapObjects2. Select the one that is suitable for the type of address you want to standardize. .stn file you specify in the StandardizingRules property.pmd 488 10/28/2004. you must specify the appropriate standardization rules using the StandardizingRules property.dct. and secondly those fields need to be converted into appropriate standard values such as ‘N’ for ‘North’ or ‘Nrth’.mat . you can test the value of the Valid property. if you want to geocode a street intersection. These fields will then be compared to fields in the specified street table in order to determine the corresponding geographic location. this property can be left empty. contained in .IntersectionStandardizingRules = “ C:\Program Files _ \ESRI\MapObjects2\Georules\us_intsc. you must also set the IntersectionStandardizingRules property. To create a valid Standardizer. So it is important that you know all the files for the set of standardization rules you are using.cls extensions. Before matching an address. 488 MapObjects Programmer’s Reference Standardizer Object An Standardizer object allows you to standardize individual address strings or street intersec- tions. Some files also point to other tables (such as prefix. A Standardizer object normally uses one standardization rule set to parse and standardize an address. Use the LastError property to return an error code.stn” stan.Standardizer stan. The .StandardizingRules = “C:\Program Files\ _ ESRI\MapObjects2\Georules\us_addr. MapObjects provides a set of standardization rules.stn” To verify that the Standardizer is set up properly. Firstly the address string needs to be broken into a standard set of fields (called match keys). Generally. The standardization rule command file can be set to the object’s StandardizingRules property.stn file looks for other files with its same base name.pat and .stn files. 10:00 AM .LastError.Standardizer Dim f. i As Integer Dim name. paste the code into the Declarations section of a form that contains two ListBoxes named List1 and List2 respectively. address1. Error “ & _ stan.stn” If Not stan.Valid Then If Not stan. To try this example. Then press F5 and see the result of standardization.StandardizingRules = “C:\Program Files _ \ESRI\MapObjects2\GeoRules\us_addr.pmd 489 10/28/2004. _ “Standardizer Error End If End End If address1 = “270 North Main Avenue” address2 = “North Main Street & First Ave SW” ProgrammersReference.IntersectionStandardizingRules = “C:\Program Files _ \ESRI\MapObjects2\GeoRules\us_intsc. to point to your GeoRules directory. Option Explicit Private Sub Form_Load() Dim stan As New MapObjects2. address2 As String ‘Change the paths below to ones appropriate for your data stan. Substitute the path strings. if necessary.stn” stan. MapObjects Programmer’s Reference 489 Properties FieldCount IntersectionStandardizingRules Valid FieldName LastError FieldValue StandardizingRules Methods StandardizeAddress See Also Geocoder Object. vbCritical + vbMsgBoxHelpButton.LastError = mgErrorNone Then MsgBox “The standardizer is not valid. AddressLocation Object Example This example demonstrates the use of the Standardizer object and its properties and methods. AddItem (“Match Key Field Name” & vbTab & “Field Value”) List1.AddItem “” f = stan.AddItem “Standardization of an Address String” List1.AddItem “” List2.StandardizeAddress(address2)) Then ‘The ZN field for Zone has to be set every time after an address ‘is standardized stan.FieldValue(“ZN”) = “53702” List1.AddItem “Standardization of an Intersection String” List2.AddItem (“Match Key Field Name” & vbTab & “Field Value”) List2.FieldValue(name) Next i End If If (stan.FieldName(i) List2.1 name = stan. Syntax object.FieldValue(“ZN”) = “53702” List2.AddItem “” List2.AddItem “” f = stan.1 name = stan.AddItem (“Address = “ & address1) List1.FieldName(i) List1.pmd 490 10/28/2004. 10:00 AM .Standardizer = standardizer ProgrammersReference.FieldCount For i = 0 To f .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.AddItem “” List1.AddItem vbTab & name & vbTab & vbTab & stan.AddItem “” List1.FieldCount For i = 0 To f . 490 MapObjects Programmer’s Reference If (stan.AddItem (“Address = “ & address2) List2.AddItem vbTab & name & vbTab & vbTab & stan. This property is write-only.StandardizeAddress(address1)) Then stan. Syntax object. Remarks The StartMeasureField property is used for rendering both Point and Line events. Remarks When using a Geocoder to perform address matching. value A string object evaluating to the Field property of the EventTable of an EventRenderer which defines the measure at which an event starts. standardizer An object expression that evaluates to a valid Standardizer object. If you have specified SymbolType to be moPointSymbol. EventRouteIDField Property.StartMeasureField [= fieldname] The StartMeasureField property syntax has these parts: Part Description object An object expression that evaluates to a EventRenderer. 10:00 AM . If you have specified SymbolType to be moLineSymbol. the StartMeasureField is taken as the Measure value of the event.pmd 491 10/28/2004. See Also Standardizer Oject Example See Geocoder Object StartMeasureField Property Applies To EventRenderer Object Description Returns or sets the field which specifies at which Measure value. MapObjects Programmer’s Reference 491 The Standardizer property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. FeatureRouteIDField Property Example See EventRenderer Object ProgrammersReference. along a line feature. the StartMeasureField is taken as the measure at which the line event begins. an event starts. See Also EndMeasureField Property. you must assign a valid Standardizer in order for the address matching to be successful. StdDev (standard deviation). Statistics Object ProgrammersReference. and Sum. When the edits have been made to the Recordset.StartTransaction The StartTransaction method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object. Syntax object. the SupportsTransactions method may be used to check if transactional editing is allowed on the Recordset. Once you’ve created a Statistics object. you can return the following statistical properties: Max (maximum). the transaction should be committed to the server by using the CommitTransaction method or discarded by using the RollbackTransaction method. In addition. the Count property returns the number of records in the Recordset. Remarks If you only require read access to an SDE layer. Recordset Object. Before starting a transaction. Min (minimum). 10:00 AM . you do not need to open a transaction. See Also GeoDataset Object Example See the online help Statistics Object A Statistics object represents the result of a calculation on a numeric Field of a Recordset using the Recordset object’s CalculateStatistics method. 492 MapObjects Programmer’s Reference StartTransaction Method Applies To Recordset Object Description Begins a transaction operation on an SDE connection.pmd 492 10/28/2004. Properties Count Max Min Sum Count Mean StDev See Also Field Object. Mean . Remarks If an application has a GeoDataset open for writing. once the writing application re-opens the underlying table as read-only again by invoking the StopEditing method on the Recordset. MapObjects Programmer’s Reference 493 StdDev Property Applies To Statistics Object Description Returns a value that indicates the standard deviation calculated by a Statistics object.Records.CalculateStatistics(“tot_vote”) See Also CalculateStatistics Method. for example: Set stats = Map1. ProgrammersReference. other applications may not be able to get its associated Recordset for spatial and logical queries. The Recordset may become avail- able.pmd 493 10/28/2004.Layers(0).StopEditing The StopEditing method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object.StdDev [= value] The StdDev property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Syntax object. Syntax object. 10:00 AM . value A double data type specifying the maximum value calculated by the Statis- tics object. Statistics properties Example See CalculateStatistics method StopEditing Method Applies To Recordset Object Description Re-opens the table underlying the Recordset object as read-only. Remarks To create a Statistics object whose statistical properties you can return. use the Recordset object’s CalculateStatistics method. EditMode Property Example See Delete Method StreetSide Constants MapObjects defines the following StreetSide constants for the AddressLocation object’s StreetSide property. Return Values The StreetSide property returns StreetSideConstants: Remarks The StreetSide property should only be used when the Geocoder has been set up to match individual street sides. 494 MapObjects Programmer’s Reference See Also GeoDataset Object. For example. Only if these MatchVariables are linked with appropriate fields in the StreetTable should the StreetSide property be used. the us_addr match rules set specifies match variables FromLeft. 10:00 AM .pmd 494 10/28/2004. Syntax object. StreetSide [=variable] The StreetSide property syntax has these parts: Part Description variable An numeric expression that will hold the street side constant (data type integer). 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. object An object expression that evaluates to an object in the Applies To list. See Also Location Property ProgrammersReference. Constant Value Description moLeftSide 0 Left side of the street moRightSide 1 Right side of the street See Also AddressLocation Object. FromRight. ToLeft and ToRight. geodataset An object expression that evaluates to a GeoDataset that contains a street network. and the numbers are divided into even numbers on one side of the street and odd numbers on the other. polygon. Syntax object. Remarks The StreetTable property references a GeoDataset containing information about street features. 1. ProgrammersReference. which can only be created on a shapefile or coverage. Linear features Urban StreetTables typically have four house number fields ranging from low to high for each side of a street segment. This property is write-only.pmd 495 10/28/2004. A StreetTable GeoDataset may be a shapefile containing Line features. as geocoding with MapObjects requires the addition of a geocoding index file. A zone is usually specified by the left zone’s zip code and the right zone’s zip code for a street segment. where each record represents a street.StreetTable = geodataset The StreetTable property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. In addition to these fields. Street name infor- mation may also be split over more than one field. The GeoDataset must represent a shapefile. Each type of GeoDataset feature (line. MapObjects Programmer’s Reference 495 Example See Location Property StreetTable Property Applies To Geocoder Object Description Sets the StreetTable property of the Geocoder object to a GeoDataset that contains a street network. and Street Name held in other fields. and point) has a typical format for addresses. The GeoDataset will have a Shape Field containing the Line features. City. The range indicates the possible numbers that could fall within a particular block. 10:00 AM . and also address attributes such as ZIP code. you may also wish to use information such as postal zip codes and city names to differentiate street addresses in different zones. A StreetTable with clearly defined fields will be more successful for geocoding against. 496 MapObjects Programmer’s Reference For example. Polygon features Land parcels represented by polygon features can be identified by. SUFFIX North Road suffix which lies after road type. Street. such as Avenue. Crescent. such as ‘North’ in ‘Greenspot Rd North’ CFCC A40 CFCC Code of the road ZIPL 92329 ZIP code for the left-hand-side of the road ZIPR 92373 ZIP code for the right-hand-side of the road 2. postal zip or zip+4 codes. The formats for these address types are: For example. Road. the feature attribute fields in the GeoDataset of the Redlands sample shapefile are: ProgrammersReference. the feature attribute fields in the GeoDataset of the Redlands sample shapefile are: Field Example Description Shape Line Line features in a GeoDataset representing each street L_F_ADD 29700 House numbers go from this value on the left-hand-side of the road L_T_ADD 29882 House numbers go to 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 R_T_ADD 29883 House numbers go to this value on the right-hand-side of the road PREFIX North Road name prefix such as ‘North’ in ‘North Greenspot Road’ NAME GREENSPOT Road name excluding any prefix or suffix TYPE RD Road type. for example..pmd 496 10/28/2004. 10:00 AM . ZIP 92329 ZIP code for the land parcel Name Smith Land owner’s name 3. The object’s Add method returns False if the string is a duplicate of an existing member of the collection. for example well ID.pmd 497 10/28/2004.Strings Properties Count Unique Methods ProgrammersReference. You can return the index of a string in the collection with Find. The address of a point feature usually contains one component: Field Example Description Shape Point Point features in a GeoDataset representing objects Well ID 376A Identification number for the well See Also GeoDataset Object Example See Geocoder Object Strings Collection Strings is a standard collection that includes a set of unique string data types. 10:00 AM . building name or light pole number. You can create Strings collections in Visual Basic with code like this: Dim s as New MapObjects2. 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. MapObjects Programmer’s Reference 497 Field Example Description Shape Polygon Polygon features in a GeoDataset representing land parcels / areas. The default property of a Strings collection is Item. Point features Point features may also have descriptive addresses or identifiers. The settings for value when the object is a fill symbol (SymbolTypeConstant is moFillSymbol) are FillStyleConstants. value A value or constant that determines the style as described in Settings. ValueMapRenderer Object. Settings The settings for value when the object is a marker symbol (SymbolTypeConstant is moPointSymbol) are MarkerStyleConstants. paste the code into the Declarations section of a form that contains a control array of 4 OptionButton controls. FindApproximateMatches Method. See Also Size Property.Style [= value] The Style property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 10:00 AM . SymbolType Property Example This example uses the Style property to control the FillStyle of the Symbol used to render polygon features of a MapLayer.pmd 498 10/28/2004. Syntax object. named Option1 ProgrammersReference. 498 MapObjects Programmer’s Reference Add PopulateWithMeridians Clear PopulateWithParameters Item PopulateWithProjectedCoordSys PopulateWithDatums PopulateWithProjections PopulateWithGeographicCoordSys PopulateWithSpheroids PopulateWithGeoTransformations PopulateWithUnits See Also LabelRenderer Object. To try this example. FindAllPlaceNames Method Style Property Applies To Symbol Object Description Returns or sets the style of a Symbol object. The settings for value when the object is a line symbol (SymbolTypeConstant is moLineSymbol) are LineStyleConstants. press CRTL+V. For the OptionButton.CalculateStatistics(“tot_vote”) See Also CalculateStatistics Method. MapObjects Programmer’s Reference 499 (add one option control.Style = Index Map1.Refresh End Sub Private Sub Form_Load() Dim I ‘ Declare variable.Caption = “Horizontal” Option1(3). set its Index property to 0 in the Control Properties dialog box to create a control array of one element.Sum The Sum property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Layers(0). Click each OptionButton to see each different style.pmd 499 10/28/2004. 10:00 AM .Caption = “Transparent” Option1(2). use the Recordset object’s CalculateStatistics method. value A double data type specifying the maximum value calculated by the Statis- tics object. Also. Syntax object. make sure it’s highlighted.Caption = “Solid Fill” Option1(1).Value = True End Sub Sum Property Applies To Statistics Object Description Returns a value that indicates the sum calculated by a Statistics object. press CTRL+C. Option1(0). Statistics properties ProgrammersReference.Layers(0). Option Explicit Private Sub Option1_Click(Index As Integer) Map1. add to the form a Map control named Map1 that contains a MapLayer with polygon features.Caption = “Vertical” Option1(0). repeat as required). click yes.Symbol. for example: Set stats = Map1. Remarks To create a Statistics object whose statistical properties you can return. and then press F5.Records. Text dc. paste the code into the Declarations section of a new Form which has five textboxes named Text1 to Text5.Text ProgrammersReference.Text dc. Option Explicit Private Sub Command1_Click() Dim dc As New MapObjects2. StartTranaction Method. False The object does not support transactions. To try this example. and click Command1.pmd 500 10/28/2004.Password = Text3. Syntax object. Remarks Only SDE layers support transactions from MapObjects.MousePointer = vbHourglass dc.DataConnection Screen. 10:00 AM . See Also RollbackTransaction Method. Return Values The SupportsTransactions property return values are: Value Description True The object supports transactions. enter appropriate values in the TextBoxes to connect to your SDE instance.SupportsTransactions The SupportsTransactions property syntax has these parts: Part Description object An object expression that evaluates to a Recordset object. therefore this property will identify the Recordset as belonging to an SDE layer. 500 MapObjects Programmer’s Reference Example See CalculateStatistics Method SupportsTransactions Property Applies To Recordset Object Description Returns a value that indicates whether a Recordset object supports transactions. EndTransaction Method Example This example demonstrates how you might connect to SDE and check if a particular dataset supports transactions. add a CommandButton named Command1 and a CheckBox named Check1. Also.User = Text2.Server = Text1. with five corresponding Labels named Label1 to Label5. Then press F5. Caption = “Server” Label2.MapLayer lyr.Records If recs. you can specify the particular SymbolType and Style of the Symbol.Caption = “Supports Transactions” Check1. Depending on the kind of feature or shape you’re working with. you can set the characteristics of the line to be solid or a dashed or dotted pattern. if the feature is a Line.ConnectError = moNoError Then Dim recs As MapObjects2. MapObjects Programmer’s Reference 501 dc.Value = 0 End If End If Screen.SupportsTransactions Then Check1.GeoDataset = dc.Recordset Set recs = lyr. for example. ProgrammersReference.Enabled = True End Sub Symbol Object A Symbol object consists of attributes that control how a features or graphic shape is dis- played.FindGeoDataset(Text5.Value = 0 Check1.pmd 501 10/28/2004. You can set the Size property of a Symbol object in points.Caption = “Dataset name” Check1.Value = 1 Else Check1.Caption = “Database” Label5.Connect Then End Dim lyr As New MapObjects2.Caption = “User” Label3.Database = Text4. 10:00 AM . Similarly you can set use the Color property to set the color of the Symbol using a variety of techniques.Text) If dc.Text If Not dc.MousePointer = vbDefault Set dc = Nothing Set lyr = Nothing Set recs = Nothing End Sub Private Sub Form_Load() Label1.Caption = “Password” Label4. TrackingLayer Object. you can set the CharacterIndex of the Font you’re using to specify a particular character. MapLayer Object.pmd 502 10/28/2004. EventRenderer Object. 502 MapObjects Programmer’s Reference When setting the properties of a new Symbol. When you use the Symbol object in association with a Point feature Symbol . you should set the SymbolType property first. ProgrammersReference. MapLayer Object Symbol Property Applies To ClassBreaksRenderer Object. If a symbol references a Font. When you change the SymbolType. Using the OutlineColor property. the Symbol is reset. A Symbol object is a creatable object. you can set the angle to rotate the Symbol with the Rotation property. LabelRenderer Object. ValueMapRenderer Object. ZRenderer Object Description Returns a reference to the Symbol or TextSymbol of an object Syntax object.Symbol[( index)] The Symbol property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 10:00 AM . you can set the color of the outline of a Symbol associated with Polygon objects. Properties CenterOnAscent Font Size CharacterIndex Outline Style Color OutlineColor SymbolType Custom Rotation See Also TextSymbol Object. and all the other Symbol properties will become the default for the specified SymbolType.Symbol To specify your own custom Symbol object use the Custom property. LabelPlacer Object. You can create a Symbol object in Visual Basic with code like this: Dim s As New MapObjects2. Index must be a number from 0 to a number that is one less than the total number of Symbol or TextSymbol objects associated with an object. When you apply the Symbol property to a TrackingLayer object. or Style. LabelRenderer Object Description Returns or sets the number of Symbol objects associated with an object. The first item in the group of symbols has index = 0. To try this example. MapObjects Programmer’s Reference 503 index Optional.pmd 503 10/28/2004.Symbol MsgBox oSymbol. Option Explicit Private Sub Command1_Click() Dim oSymbol As MapObjects2. A numeric expression that specifies the position of a member of a group of symbols. See Also Symbol Object Example This example uses the Symbol property to return the Symbol associated with a MapLayer and then report the value of the Symbol object’s Color property.Symbol Set oSymbol = Map1. you can associate a Symbol with one or more GeoEvent objects. 10:00 AM . Syntax object. 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.Color End Sub SymbolCount Property Applies To TrackingLayer Object. Click Command1 to return the value of the Color property. then press F5. you return a reference to a TextSymbol object.Layers(0). You can set or return a Symbol’s Color. When you apply the Symbol property to a LabelRenderer object. and SymbolCount is always one more than the largest index value.SymbolCount [= value] The SymbolCount property syntax has these parts: ProgrammersReference. Remarks Use the Symbol property to get the symbol associated with an object. Font (where applicable). Size. x _ As Single. value A numeric expression that evaluates to an integer that is always one more than the largest index value of the Symbol property. the GeoEvent draws with a green symbol.Caption = “Hide” ProgrammersReference.1 End If End Sub Private Sub Form_Load() DefineSymbols Command1. 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.Point If Button <> 4 Then Set oPoint = Map1. 10:00 AM . Shift As Integer. and then press F5 and click the map.TrackingLayer.ToMapPoint(x. y) Map1. 504 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to an object in the Applies To list. Option Explicit Private Sub Command1_Click() With Map1 .Refresh True End Sub Private Sub Map1_MouseDown(Button As Integer. See Also Symbol Property Example This example demonstrates the use of the SymbolCount property in the context of the TrackingLayer.pmd 504 10/28/2004. the GeoEvent draws with a red symbol and if you click the map with the right mouse button.SymbolCount = 0 . Note that if you click the map with the left mouse button. Once you’ve 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. Button .TrackingLayer. To try this example.AddEvent oPoint.Refresh True End With End Sub Private Sub Command2_Click() DefineSymbols Map1. You can disassociate the Symbol objects associated with the GeoEvent objects on the TrackingLayer by setting the SymbolCount property to 0.TrackingLayer. y As Single) Dim oPoint As MapObjects2.TrackingLayer. Size = 18 .TrackingLayer.Font = oFont .TrackingLayer.Style = moTrueTypeMarker .TrackingLayer. Syntax object.Color = moRed .Font = oFont . 10:00 AM .Caption = “Show” End Sub Private Sub DefineSymbols() ‘ defines two Symbols for the TrackingLayer Dim oFont As New StdFont With oFont .Bold = False End With Map1.Color = moDarkGreen . MapObjects Programmer’s Reference 505 Command2.SymbolCount = 2 ‘the following properties will display when you click the left ‘button With Map1.pmd 505 10/28/2004.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.Style = moTrueTypeMarker .SymbolHeight [= value] The SymbolHeight property syntax has these parts: ProgrammersReference.Symbol(1) .Symbol(0) .name = “Wingdings” .CharacterIndex = 139 End With ‘the following properties will display when you click the right ‘button With Map1. Remarks Commonly used when the LabelPlacer renders point features. you can specify a variety of TextSymbols to use to draw labels with a single LabelRenderer object. Remarks Using the values stored in the SymbolField. The values of this numeric field provide the index value of the Symbol property of the LabelRenderer. If it has been set. or PlaceOn have been set. 10:00 AM . a value of 72 indicates a distance of 36 points (one-half inch) above and below the feature. value A string expression that specifies a name of a field in a Recordset. 506 MapObjects Programmer’s Reference Part Description object An object expression that evaluates to a LabelPlacer. See Also SymbolWidth Property Example See SymbolWidth Property SymbolField Property Applies To LabelRenderer Object. value An integer in points that represents the space reserved for the feature’s symbol in the horizontal direction. The LabelPlacer will position the label for the feature so that it does not conflict with the specified SymbolHeight. EventRenderer Object Description Returns or sets the field that contains Symbol index information for a LabelRenderer object. the SymbolHeight value represents a diameter. SymbolHeight will be used before other settings to determine where a label may be placed. PlaceBelow. Syntax object. that is.pmd 506 10/28/2004. See Also TextSymbol Object ProgrammersReference. You’ll obtain different results depending on whether PlaceAbove.SymbolField [= value] The SymbolField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Recordset Private Sub Command1_Click() Dim oLayer As New MapObjects2.ListIndex <> -1 And Combo2.pmd 507 10/28/2004.ListIndex) .Size = 8 End With With oFnt2 .Size = 9 .Symbol(0).Field = Combo2. 10:00 AM . 1. The Form_Load event code will position all the controls except the Map. Press F5.Name = “Arial” .Name = “Arial” . Option Explicit Dim moRecset As MapObjects2. MapObjects Programmer’s Reference 507 Example This example uses the SymbolField property to set the symbol used to render the text dis- played by the LabelRenderer.Font = oFnt0 ProgrammersReference. two ComboBox controls named Combo1 and Combo2.ListIndex <> -1 Then With oFnt0 .List(Combo2.Italic = True End With With oFnt1 . and 2. Click Command1 to display the text.Size = 10 End With With oLayer .ListIndex) .List(Combo1. 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.Bold = True .LabelRenderer Dim oFnt0 As New StdFont Dim oFnt1 As New StdFont Dim oFnt2 As New StdFont If Combo1. This example assumes that the SymbolField contains values 0. and a CommandButton named Command1.SymbolCount = 3 Set . To try this example. The SymbolField property specifies the name of a field in the Recordset associated with the MapLayer. two Label controls named Label1 and Label2. paste the code into the Declarations section of a form containing a Map named Map1 that contains a MapLayer. The Field property names the field that will serve as the source for the text.Name = “Courier New” .SymbolField = Combo1. The field contains a value for each record that provides an index into the symbols established for the LabelRenderer. ListIndex = -1 Combo2.Top = Label1.25 Command1.Top = Label1.Type < moString Then Combo1.Field Set moRecset = Map1.Top = Map1.pmd 508 10/28/2004.Left + (Label1. 10:00 AM .5) Combo2.Top = Label2.Records For Each oField In moRecset.Left Label1.Top Combo1.Layers(0).Text = “” Combo2.Color = moRed Set .Font = oFnt1 .Left = Combo1.Left Combo1.Layers(0).ListIndex = -1 Command1.AutoSize = True Label2.Symbol(0).Width * 1.AutoSize = True Label1.Caption = “Label” End Sub ProgrammersReference.Left = Map1.AddItem oField.Height * 2) Combo1.Top Combo2.Text = “” Combo1.Left = Label1.Fields If oField.Color = moLimeGreen Set .Height * 2) Label2.Left Label2.Top = Label1.Caption = “Symbol Field” Label2.AddItem oField.Height + (Label1.Symbol(1).Left + Combo1.Font = oFnt2 End With Map1.Symbol(2).Width * 1.Left = Combo1.Symbol(1).Name End If Combo2.Left = Map1.Caption = “Text Field” Label1.Top + Map1.Top Command1.Refresh End If End Sub Private Sub Form_Load() Dim oField As MapObjects2. 508 MapObjects Programmer’s Reference .Top + (Label2.Renderer = oLayer Map1.Name Next Label1. Add one or more GeoEvent objects to the Map’s TrackingLayer by clicking on the Map and then click Command1. and a Map named Map1 that contains at least one MapLayer and then press F5. See Also Symbol Object Example This example uses the SymbolIndex property to set the symbol of the most recently added GeoEvent on a Map. The text from the TextBox is added as the Tag to the last GeoEvent if you choose “Yes” in hte second message box. a TextBox named Text1. Remarks The first item in the group of symbols has index = 0. you can immediately start adding events with a SymbolIndex of 0. Syntax object. index A numeric expression that specifies the index of an item in the group of symbols associated with the TrackingLayer.TrackingLayer If . iNewsym As Integer Dim iMsg As String Dim tMsg As String Dim iResponse As Integer Dim tResponse As Integer With Map1. MapObjects Programmer’s Reference 509 SymbolIndex Property Applies To GeoEvent Object Description Returns or sets the index of the Symbol on the TrackingLayer associated with the GeoEvent.SymbolIndex [= index] The SymbolIndex property syntax has these parts: Part Description object An object expression that evaluates to a GeoEvent object. 10:00 AM .pmd 509 10/28/2004. To try this example. paste the code into the Declarations section of a form containing a CommandButton named Command1. Option Explicit Private Sub Command1_Click() Dim iCursym. and the TrackingLayer object’s SymbolCount property is always one more than the largest index value. its SymbolCount is 1. When the TrackingLayer is created.EventCount > 0 Then iMsg = “Change most recently added GeoEvent’s symbolIndex from” tMsg = “Add a tag to GeoEvent “ ProgrammersReference. and also gives the option of adding a tag to that GeoEvent. vbYesNo + vbQuestion) If iResponse = vbYes Then .EventCount .Style = moTrueTypeMarker .Symbol(0) .TrackingLayer.Text End If End If End With End Sub Private Sub Map1_MouseDown(Button As Integer.AddEvent oPoint.1 End Sub Private Sub Form_Load() ‘ defines two Symbols for the TrackingLayer Dim oFont As New StdFont oFont. Shift As Integer.Bold = False Map1.CharacterIndex = 139 End With ‘the following properties will display when you click the right ‘button ProgrammersReference.Event(. Button . 510 MapObjects Programmer’s Reference iCursym = .Event(. y As Single) Dim oPoint As MapObjects2.TrackingLayer.EventCount .Event(iNewsym-1).Name = “Wingdings” oFont.Tag = Text1.TrackingLayer. 10:00 AM . vbYesNo + vbQuestion) If tResponse = vbYes Then .ToMapPoint(x.SymbolCount = 2 ‘the following properties will display when you click the left ‘button With Map1. x _ As Single.1) iMsg = iMsg & Str(iCursym) & “ to” & Str(iNewsym) & “?” iResponse = MsgBox(iMsg.1).pmd 510 10/28/2004.1). y) Map1.SymbolIndex = iNewsym Map1.Font = oFont .Refresh End If tMsg = tMsg & iNewsym & “ ?” tResponse = MsgBox(tMsg.Color = moRed .SymbolIndex iNewsym = Abs(iCursym .Point Set oPoint = Map1.Size = 18 . MapObjects Programmer’s Reference 511 With Map1.CharacterIndex = 140 End With Command1.Style = moTrueTypeMarker . ZRenderer Object Description Returns or sets a value that indicates the type of Symbol associated with an object. ValueMapRenderer Object. Symbol Object. ValueMapRenderer Object SymbolType Property Applies To ClassBreaksRenderer Object.Caption = “Change Index” Text1.TrackingLayer.Symbol(1) .Color = moDarkGreen .pmd 511 10/28/2004. ProgrammersReference. Constant Value Description moPointSymbol 0 Point symbols moLineSymbol 1 Line symbols moFillSymbol 2 Fill symbols See Also Symbol Object. The SymbolType property returns these values. ClassBreaksRenderer Object. 10:00 AM .Text = “<Enter GeoEvent Tag text here>” End Sub SymbolType Constants MapObjects defines the following type constants for use with Symbol objects. Syntax object.Size = 18 .SymbolType [= value] The SymbolType property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Font = oFont . LayerType = moMapLayer Then Select Case l. then click Command1.pmd 512 10/28/2004. Press F5. Note that the LayerType constant is used to determine whether the layer is a MapLayer rather than an ImageLayer. 10:00 AM . 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.SymbolWidth [= value] The SymbolWidth property syntax has these parts: ProgrammersReference. Syntax object.Name & “ contains “ & ftype & “ features” End If Next l End Sub SymbolWidth Property Applies To LabelPlacer Object Description Returns or sets the symbol width which the LabelPlacer will take into account when perform- ing placement.Layers If l. 512 MapObjects Programmer’s Reference value A value or constant that determines the SymbolType of an object. Option Explicit Private Sub Command1_Click() Dim l As Object Dim ftype As String For Each l In Map1. as described in Settings. Settings The settings for value are SymbolTypeConstants See Also Style Property Example This example uses the SymbolType Property and Constants to determine the type of features in each MapLayer of a Map.SymbolType Case moFillSymbol ‘2 ftype = “polygon” Case moLineSymbol ‘1 ftype = “line” Case moPointSymbol ‘0 ftype = “point” End Select MsgBox l.Symbol. To try this example. To try this example. and two TextBoxes named Text1. You’ll obtain different results depending on whether PlaceAbove. SymbolHeight will be used before other settings to determine where a label may be placed.Text <> “” Then LabelPlacer.Caption = “Full Extent” Command2.Text <> “” Then LabelPlacer.Caption = “Check Font” ProgrammersReference. 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. MapObjects Programmer’s Reference 513 Part Description object An object expression that evaluates to a LabelPlacer. See Also SymbolHeight Property Example This example uses the SymbolHeight and SymbolWidth properties of the LabelPlacer to control where to position relation to the symbols of point features. 10:00 AM .Text = “12” ‘points Command1. that is. paste the code into the Declarations section of a form that contains a Map control named Map1. a value of 72 indicates a distance of 36 points (one-half inch) to the left and to the right of the feature. Text2 and Text3. Click the Set SymbolHeight button. three CommandButtons named Command1.SymbolHeight = Text1. Option Explicit ‘ setup the LabelPlacer Dim LabelPlacer As New MapObjects2. the SymbolWidth value represents a diameter. Command2 and Command3.. or PlaceOn have been set. Press F5 and enter a value for the offset in the TextBox.Text = “12” ‘points Text2.Refresh End Sub Private Sub Form_Load() Text1.SymbolWidth = Text2. value An integer in points that represents the space reserved for the feature’s symbol in the horizontal direction. The LabelPlacer will position the label for the feature so that it does not conflict with the specified SymbolWidth.pmd 513 10/28/2004. If it has been set. PlaceBelow. Remarks Commonly used when the LabelPlacer renders point features.LabelPlacer Private Sub Command2_Click() If Text1.Caption = “Refresh” Command3.Text Map1.Text If Text2. Right = -69.1 Flag = StrComp(Font.Fonts(I).Name. Printer. y As Single) ProgrammersReference. x _ As Single. Shift As Integer.Symbol.Size = 8.FullExtent.FontCount .Height / 200 Set LabelPlacer.Font = fnt LabelPlacer.7297134399414 r.Left = -75. 1) If Flag = True Then Debug.Color = moNavy Map1. Flag As Boolean For I = 0 To Printer.Layers.AllowDuplicates = False End Sub Private Sub Command3_Click() Dim I As Integer.Item(“Capitals”).Name = “Times New Roman” fnt.7479599787522 r.Rectangle r.353902605797 r. 514 MapObjects Programmer’s Reference ‘ set an initial extent Dim r As New MapObjects2.Bottom = 40.DefaultSymbol.” Exit For End If Next I End Sub Private Sub Map1_MouseDown(Button As Integer. 10:00 AM .DefaultSymbol.Layers.Item(“states”).Layers.Renderer = LabelPlacer LabelPlacer.Color = moPaleYellow ‘ create a font to be used by the LabelPlacer Dim fnt As New StdFont fnt.1731822024441 r.Item(“capitals”).Symbol.5 Set Map1.Extent = r ‘ default color for the layers Map1.Print “There is a matching font.Field = “CITY_NAME” ‘ default symbol LabelPlacer.ScaleRectangle 0.Height = Map1.Top = 44.Bold = False fnt.75 Set Map1.pmd 514 10/28/2004. 5) to access both Jet and ISAM databases. the PlaceNameTable property of a PlaceLocator object. SDE and ODBC. 10:00 AM . and Paradox. the EventTable property of an EventRenderer object.pmd 515 10/28/2004.FullExtent End Sub Table Object A Table object is a read-only data access object. for example: Dim MyTable as New MapObjects2. A Table object represents a collection of related data values that are organized into rows and columns. The SearchExpression method applied to a Table object will return a Recordset of those records meeting the expression’s criteria. Microsoft FoxPro. DAO drivers also allow access to text file databases and Microsoft Excel or Lotus 1-2-3 worksheets.Table Properties Database Password Server User Name Records ProgrammersReference. If you are writing your application in Visual Basic. and as input to the BatchMatch method of a Geocoder object. Indexed Sequential Access Method (ISAM) databases. MapObjects Programmer’s Reference 515 If Button = 1 Then Map1. the file suffix should not be included in the Name property. MapObjects uses Data Access Objects (DAO 3. for example a dBase file.Extent = Map1. In addition.Pan End If End Sub Private Sub Command1_Click() Map1. you should distinguish the MapObjects Table object from a Visual Basic Table object by fully qualifying the class name in declara- tions.TrackRectangle Else Map1. The records in a Table can be accessed through the Recordset object returned by the Records property. INFO. Formats of ISAM databases include dBase. This object corresponds with a table in a relational database. The Table object can access tables from a number of sources: Microsoft Jet databases. The Table object can be used in the AddRelate method for MapLayer objects.Extent = Map1. Note that even if the data source of the Table object is file-based. and the FieldType. You can use this object when you create a new Recordset object. The property is read-only.pmd 516 10/28/2004. you can return or set properties where appropriate. For international applications you can set the code page for a TableDesc object with the CodePage property. For each Field of the Recordset.TableDesc The TableDesc property syntax has these parts: ProgrammersReference. StreetTable Property TableDesc Object A TableDesc is an object that represents a description of the Fields collection of a Recordset. Fields Object TableDesc Property Applies To Recordset Object Description Returns a TableDesc object that describes the field characteristics of a Recordset. the FieldName. 516 MapObjects Programmer’s Reference Methods SearchExpression See Also MapLayer Object. You can set the number of fields that you want to define by specifying the FieldCount property.e. PlaceNameTable Property. within the limits of the GeoDataset from which the Recordset is derived. using the newly created TableDesc object as a parameter. invoking the DataConnection object’s AddGeoDataset method. These properties are the FieldLength. you can add a GeoDataset to a DataConnection object.TableDesc Properties TableDesc properties See Also Recordset Object. i. Syntax object. the FieldPrecision. EventTable Property. You can create TableDesc objects in Visual Basic with code like this: Dim desc as New MapObjects2. 10:00 AM . Once you’ve defined the Fields that will be associated with the Recordset. the FieldScale. AddRelate Method. _ Add(. See Also TableDesc Object.Add(. td. 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. Option Explicit Private Sub Form_Load() Dim td As MapObjects2.Width / 2) Set clm = ListView1.ListItems. .ColumnHeaders. ListView1. MapObjects Programmer’s Reference 517 Part Description object An object expression that evaluates to an object in the Applies To list.ColumnHeaders. Field Object Example This example uses the TableDesc property to return the TableDesc object of a Recordset in order to return some information about the Recordset. “Type”.TableDesc Set clm = ListView1.Layers(0).FieldName(i)) Select Case td.View = lvwReport Set td = Map1.1 Set itm = ListView1. To try this example. .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.TableDesc Dim clm As ColumnHeader Dim i As Integer Dim itm As ListItem Dim ftype As String ListView1.pmd 517 10/28/2004.SubItems(1) = ftype Next i ProgrammersReference. _ Add(. . ListView1.Width / 2) For i = 0 To td.Records.FieldCount . Press F5. “Field Name”. 10:00 AM . ValueMapRenderer Object. ImageLayer Object.ValueMapRenderer Private Sub Command1_Click() If Map1. GeoEvent Object. when the map displays the MapLayer at county-scale. ClassBreaksRenderer Object. To try this example.Renderer.Layers(0). MapLayer Object. ZRenderer Object. Option Explicit Dim oCountyRenderer As New MapObjects2. 518 MapObjects Programmer’s Reference End Sub Tag Property Applies To Map Object. it uses a second ValueMapRenderer. and is not case-sensitive. 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. Syntax object. 10:00 AM . When the map displays the layer at state-level scale. it uses one ValueMapRenderer.Tag [= expression] The Tag property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Unlike other properties. expression A string expression identifying the object.Renderer = oStateRenderer ProgrammersReference.ValueMapRenderer Dim oStateRenderer As New MapObjects2.Layers(0). The default is a zero-length string (“”). The Tag property is useful when you need to check the identity of a control that is passed as a variable to a procedure.pmd 518 10/28/2004. Click-drag a rectangle to zoom in to the map. See Also Name Property 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. LabelRenderer Object. 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. EventRenderer Object Description Returns or sets any extra data needed for your program. the value of the Tag property is not used by Visual Basic. you can use this property to identify objects. Click Command1 to zoom to the full extent of the Map. Press F5. Remarks The Tag property is a user-defined property. DotDensityRenderer Object.Tag = “County” Then Map1. Caption = “Full Extent” Set oMapRecords = Map1.TrackRectangle If Map1.Renderer = oCountyRenderer MsgBox “Switched to County-level renderer”. MapObjects Programmer’s Reference 519 End If Map1.Extent = Map1.Layers(0).EOF oNames(0).Field = “Cnty_Name” End With ‘iterate through the records and accumulate values Do While Not oMapRecords. 10:00 AM .Tag = “State” .Recordset Dim i As Integer Dim s As Variant Dim oNames(0 To 1) As New MapObjects2.ValueAsString oMapRecords.FullExtent MsgBox “Switched to state-level renderer”.Tag = “County” .Width < Map1.Renderer. vbExclamation End If End If End Sub Sub Form_Load() Dim oMapRecords As MapObjects2.Extent = Map1.Tag = “State” Then Map1.MoveNext Loop ProgrammersReference.FullExtent.Strings Command1.Width / 4 Then If Map1. x As _ Single. y As Single) Map1.Field = “State_Name” End With With oCountyRenderer .Add oMapRecords(“State_Name”). Shift As Integer.Records With oStateRenderer .Extent. vbExclamation End Sub Private Sub Map1_MouseDown(Button As Integer.Layers(0).Layers(0).pmd 519 10/28/2004. If the value of Height is 0.TextSymbol ProgrammersReference.pmd 520 10/28/2004. To position a TextSymbol relative to a label point.Count oStateRenderer. You can create TextSymbol objects in Visual Basic with code like this: Dim s as New MapObjects2.Value(i) = s i = i + 1 Next s ‘ set the values for the county-level renderer i = 0 For Each s In oNames(1) oCountyRenderer. use the Fitted property.MoveFirst Do While Not oMapRecords. then the size of the TextSymbol is the equivalent value in points of the Size of the TextSymbol object’s Font. 520 MapObjects Programmer’s Reference oMapRecords.Layers(0). 10:00 AM . You can set the angle of rotation of a TextSymbol with the Rotation property.Count ‘ set the values for the state-level renderer i = 0 For Each s In oNames(0) oStateRenderer.Renderer = oCountyRenderer ‘state-level End Sub TextSymbol Object A TextSymbol object consists of attributes that control how text is rendered. You can set the font associated with the TextSymbol using the Font property and its color with the Color property. set its HorizontalAlignment and VerticalAlignment properties. To adjust the gap between text characters so that the text will fit between two points.0. either by stretching it or shrinking it. To set the height of a TextSymbol in map units you can specify a value for the Height property.MoveNext Loop oCountyRenderer.ValueAsString oMapRecords.ValueCount = oNames(0).Add oMapRecords(“Cnty_Name”). The Symbol property of a LabelRenderer object returns a TextSymbol.EOF oNames(1).ValueCount = oNames(1).Value(i) = s i = i + 1 Next Set Map1. pmd 521 10/28/2004. Direction Property Example See GeographicTransformation Property ToMapDistance Method Applies To Map Object Description Converts a linear measurement in control units to a distance in map units. 10:00 AM . toCoordSys An object expression that evaluates to a GeoCoordSys object. Syntax object. Syntax object. ToGeoCoordSys [= toCoordSys ] The ToGeoCoordSys property syntax has these parts: Part Description object An object expression that evaluates to a GeoTransformation object. MapObjects Programmer’s Reference 521 Properties Color Font HorizontalAlignment Rotation Fitted Height VerticalAlignment Methods TextSymbol methods See Also LabelRenderer Object ToGeoCoordSys Property Applies To GeoTransformation Object Description Sets or returns an object that identifies the destination GeoCoordSys in a GeoTransformation object.ToMapDistance distance The ToMapDistance method syntax has the following object qualifier and argument: ProgrammersReference. FromGeoCoordSys Property. See Also GeoCoordSys Object. Shift As Integer.ScaleMode <> vbTwips Then X = Form1.g. vbTwips.Ellipse Private Sub Map1_MouseDown(Button As Integer. a ScaleMode of Pixels may have different ScaleX and ScaleY values. Form1. distance The linear measurement in control units Remarks If you have changed the Scale units of your Map container: The ToMapDistance method is dependant upon the ScaleMode of the Map control’s container. vbTwips.ScaleX(dist.Point Dim dist As Double dist = Map1. 10:00 AM . the internal control units of a Map control are Twips. use the ScaleX and ScaleY methods to convert X and Y coordinates before using the ToMapDistance method. Form1.ScaleX(X. See Also FromMapDistance Method. Form1. ToMapPoint Method Example This example uses the ToMapDistance method to convert control units to map units in order to perform a radius search.Recordset Dim el As New MapObjects2.ToMapDistance(Text1. X As _ Single. 522 MapObjects Programmer’s Reference Part Description object Required. Option Explicit Dim recset As MapObjects2. FromMapPoint Method. Centi- meters. Y As Single) Dim pt As MapObjects2.ScaleMode) dist = Form1.Text) ‘If the form has units which are not Twips. 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. If using a ScaleMode of Pixels: Note that whereas most scale units are constant (e. then we should first ‘convert the X and Y coordinates to twips before passing them to the ‘ToMapPoint method If Form1. when converting a distance by the ScaleX or ScaleY method. as pixels are not perfectly square. An object expression that evaluates to an object in the Applies To list. ensure that the method you choose is appropriate.ScaleMode) ProgrammersReference. However. if the Map control’s container has a different ScaleMode. Inches) giving identical ScaleX and ScaleY values.ScaleX(Y.ScaleMode) Y = Form1. Therefore. To try this example. 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. vbTwips. In Visual Basic. and therefore the ToMapDistance converts units from Twips to Map units.pmd 522 10/28/2004. Style = moSolidFill sym.Y + dist el. ByVal hDC As stdole. ByVal _ canceled As Boolean. dist.SymbolType = moFillSymbol sym.Right = pt.Top = pt.DrawShape recset.Symbol sym.Color = moYellow Map1. Y) Set recset = Map1.ToMapPoint( xControl.dist el.Layers(0).ToMapPoint(X.Y .Bottom = pt. sym sym. yControl) The ToMapPoint method syntax has the following object qualifier and arguments: ProgrammersReference.Text = 100 End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer.pmd 523 10/28/2004.SymbolType = moFillSymbol sym.SearchByDistance(pt. sym End If End Sub ToMapPoint Method Applies To Map Object Description Converts a point in control space to map coordinates.Left = pt.X .dist Map1.X + dist el. Syntax Set variable = object.Color = moRed Map1. MapObjects Programmer’s Reference 523 End If Set pt = Map1.Refresh End Sub Private Sub Form_Load() Text1.Style = moLightGrayFill sym.OLE_HANDLE) If Not recset Is Nothing Then Dim sym As New MapObjects2. 10:00 AM .DrawShape el. “”) el. Shift As Integer. Y As Single) Dim Loc As New MapObjects2. vbTwips. if the Map control’s container has a different ScaleMode. and therefore the ToMapPoint converts units from Twips to Map units.pmd 524 10/28/2004. the internal control units of a Map control are Twips. Form1. Form1. 10:00 AM . vbTwips.Point ‘Get the location of the mouse-click in map units If Shift = 0 Then ‘If the form has units which are not Twips. The example displays either the coordinates of a point clicked on the map in map units or the point’s coordinates in control units. To try this example. FromMapPoint Method. In Visual Basic.ScaleMode <> vbTwips Then X = Form1.ScaleX(X. ToMapDistance Method Example This example uses the ToMapPoint method to display the coordinates in map units of a position on a map. use the ScaleX and ScaleY methods to convert X and Y coordinates before using the ToMapPoint method. paste the code into the Declara- tions section of a form containing a Map named Map1 that contains at least one MapLayer. object Required. An object expression that evaluates to an object in the Applies To list. Remarks If you have changed the Scale units of your Map container: The ToMapPoint method is dependant upon the ScaleMode of the Map control’s container. yControl The Y coordinate of a point in control space. Option Explicit Private Sub Map1_MouseDown(Button As Integer. 524 MapObjects Programmer’s Reference Part Description variable An object expression that evaluates to a Point object.ScaleMode) Y = Form1.ScaleMode) End If ‘Convert the twips value to Map units ProgrammersReference. and then press F5 and click the mouse on the map without holding the SHIFT key down. xControl The X coordinate of a point in control space. However.To display control units. X As _ Single. then we should first ‘convert the X and Y coordinates to twips before passing them to ‘the ToMapPoint method If Form1.ScaleX(Y. See Also FromMapDistance Method. hold the SHIFT key down and click the map. ToMapPoint returns a Point object whose X and Y properties are in map units. Position the Label and the ComboBox beneath the bottom edge of the Map. This example provides a simple feature location mechanism.Caption = “Zoom to:” Set oMapRecords = Map1. Press F5. Option Explicit Dim oMapRecords As MapObjects2.ToMapPoint(X. 0#) & “.Records Do While Not oMapRecords.pmd 525 10/28/2004.X. Left Property 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. Rectangle Object Description Returns or sets the distance between the internal top edge of an object and the top edge of its container. See Also Bottom Property. When you click on the ComboBox the map zooms to the feature. To try this example. value A numeric expression specifying distance. and a ComboBox named Combo1.Layers(0).” + Str(Loc. MapObjects Programmer’s Reference 525 Set Loc = Map1. a Label named Label1. Y) MsgBox “Map Units: “ & Format(Loc.” & Str$(Y) End If End Sub Top Property Applies To Ellipse Object. 10:00 AM .EOF Combo1.Y) ‘Get the location of the mouse-click in control units Else MsgBox “Control units: “ & Str$(X) & “. You may want to change the code so that it references a character field other than “Name” in Form_Initialize and Combo1_Click. Syntax object.Recordset Private Sub Form_Initialize() Label1.AddItem oMapRecords. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer.Fields(“Name”) ProgrammersReference.Top [= value] The Top property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Height .iSpace ‘ move the controls Label1. 0.Width.Value. ScaleWidth. 10:00 AM .Combo1.Top + Map1. 526 MapObjects Programmer’s Reference oMapRecords.Left.FlashShape oMapRecords(“Shape”).List(Combo1.Move Combo1.Width ‘ move the map itself Map1.Move 0.Move Label1.iSpace End Sub Private Sub Combo1_Click() Dim sExpr As String sExpr = “name = “ & “‘“ & Combo1. iYFind . iYFind.Refresh .(Map1.pmd 526 10/28/2004.SearchExpression(sExpr) With Map1 .TrackCircle The TrackCircle method syntax has these parts: ProgrammersReference.Layers(0).Left. Combo1.Value.ListIndex) & “‘“ Set oMapRecords = Map1.Extent .Height Combo1. 3 End With Set oMapRecords = Nothing End Sub TrackCircle Method Applies To Map Object Description Rubber-bands a circle on the Map and returns an Ellipse object. Label1. Label1.Height) iYFind = ScaleHeight . iYFind.Top .Extent = oMapRecords(“Shape”). Syntax Set variable = object.MoveNext Loop Form_Resize Set oMapRecords = Nothing End Sub Private Sub Form_Resize() Dim iYFind As Integer ‘ y coordinate of the find controls Dim iSpace As Integer ‘ a constant spacing iSpace = Combo1. When you create a TrackingLayer. See Also Ellipse Object Example See SearchByDistance Method TrackingLayer Object A TrackingLayer object represents a layer in a Map that depicts geographically referenced phenomena whose position may change. Properties Event Symbol SymbolCount Visible EventCount ProgrammersReference. The TrackCircle method returns an Ellipse that is a circle. change the SymbolCount property. If you wish to rubber-band a shape which is an Ellipse with different axes. To add GeoEvent objects to a Map object’s TrackingLayer use the AddEvent property. use the RemoveEvent method. before adding more Symbol objects to the Symbol property array. its SymbolCount is 1. to remove an individual event. use the Clear method. MapObjects Programmer’s Reference 527 Part Description variable An object expression that evaluates to an Ellipse object. You can control whether the entire TrackingLayer is visible or hidden independently of the rest of the map by setting the object’s Visible property. Top and Bottom properties equal to those properties of the Rectangle. then drag the mousepointer to produce an Ellipse of the required size. These phenomena are referred to as events. 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. Note that the TrackCircle method only rubber-bands an Ellipse when the mousepointer is moved horizontally over the Map. Remarks The user should press and hold the mouse button in the center of the required Ellipse. The create a new Ellipse object. Right. Moving the mousepointer in the vertical direction does not affect the size of the Ellipse. you can use the TrackRectangle method to rubber- band a Rectangle. To remove all events on the TrackingLayer. Each event has a Symbol.pmd 527 10/28/2004. and then release the mouse button. 10:00 AM . object An object expression that evaluates to an object in the Applies To list. Any number of events may be drawn with the same Symbol object. and set it’s Left. and are represented by GeoEvent objects. 0 iEvents = Map1.ToMapPoint(X.EventCount If iEvents = 1 Then Label1. See Also TrackingLayer Object. 10:00 AM . Y) Map1. X As _ Single. Y As Single) Dim iEvents As Integer Dim pt As New Point Set pt = Map1. To try this example. Syntax object.AddEvent pt.Caption = “” End Sub Private Sub Map1_MouseDown(Button As Integer. GeoEvent Object Example This example uses the TrackingLayer property to return the TrackingLayer object and report some information about it. 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.TrackingLayer.pmd 528 10/28/2004.TrackingLayer. Remarks You can use the TrackingLayer to display and manipulate GeoEvents. Option Explicit Private Sub Form_Load() Label1. geographically referenced phenomena whose position may change. and then press F5.Caption = iEvents & “ GeoEvent on the Map” Else ProgrammersReference. 528 MapObjects Programmer’s Reference Methods AddEvent FindEvent Refresh RemoveEvent ClearEvents See Also GeoEvent Object TrackingLayer Property Applies To Map Object Description Returns a reference to the Map object’s TrackingLayer. Shift As Integer.TrackingLayer The object placeholder represents an object expression that evaluates to a Map control. Click on the map to add GeoEvents to the Tracking Layer. sym Set ln = Nothing End If End Sub ProgrammersReference.Caption = iEvents & “ GeoEvents on the Map” End If End Sub TrackLine Method Applies To Map Object Description Rubber-bands a multi-point line on the Map and returns a Line object.Symbol sym. and continue to click to add vertices to that Line. object An object expression that evaluates to an object in the Applies To list. See Also Line Object Example This example uses the TrackLine method to draw a line on a map.Size = 2 Map1.TrackLine The TrackLine method syntax has these parts: Part Description variable An object expression that evaluates to a Line object. 10:00 AM .Style = moSolidLine sym. To try this example.OLE_HANDLE) If Not ln Is Nothing Then Dim sym As New MapObjects2. Syntax Set variable = object. Option Explicit Dim ln As MapObjects2.Color = moRed sym. and then double-click to end the Line.DrawShape ln. Remarks The user should click to start the Line.Line Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ stdole.pmd 529 10/28/2004. MapObjects Programmer’s Reference 529 Label1. and then press F5 and click-drag a line on the map.SymbolType = moLineSymbol sym. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer. See Also Polygon Object Example This example uses the TrackPolygon method to draw a polygon on a map.Style = moTransparentFill ProgrammersReference. as MapObjects will add the final vertex when the Polygon is ended. Remarks The user should click to start the Polygon. paste the code into the Declarations section of a form containing a Map named Map1 that contains at least one MapLayer.pmd 530 10/28/2004. 530 MapObjects Programmer’s Reference Private Sub Map1_MouseDown(Button As Integer. Syntax Set variable = object. 10:00 AM .Polygon Private Sub Map1_AfterLayerDraw(ByVal index As Integer.TrackingLayer. ByVal _ canceled As Boolean. and then double-click to end the Polygon. object An object expression that evaluates to an object in the Applies To list. Y As Single) Set ln = Map1. and continue to click to add vertices to that Polygon.TrackLine Map1. Note that a Polygon has identical start and end vertices. However. To try this example.OLE_HANDLE) If Not poly Is Nothing Then Dim sym As New MapObjects2. you do not need to click back at your start vertex when using the TrackPolygon method.Refresh True End Sub TrackPolygon Method Applies To Map Object Description Rubber-bands a polygon on the Map and returns a Polygon object.SymbolType = moFillSymbol sym. ByVal hDC As stdole. X As _ Single. Shift As Integer. Option Explicit Dim poly As MapObjects2.Symbol sym.TrackPolygon The TrackPolygon method syntax has these parts: Part Description variable An object expression that evaluates to a Polygon object. and then press F5 and click-drag a polygon on the map. Syntax Set variable = object. X As _ Single.TrackPolygon Map1.Transform fromCoordSys.OutlineColor = moRed Map1. Remarks The user should press and hold the mouse button to start the Rectangle. and then release the mouse button to end the Rectangle. densifyTol] [.Refresh End Sub TrackRectangle Method Applies To Map Object Description Rubber-bands a rectangle on the Map and returns a Rectangle object. geoTrans] ProgrammersReference. sym End If End Sub Private Sub Map1_MouseDown(Button As Integer. Syntax Set newShape = object. Shift As Integer. object An object expression that evaluates to an object in the Applies To list. fromShape [. See Also Rectangle Object Example See Pan Method Transform Method Applies To GeoCoordSys Object.pmd 531 10/28/2004. 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. 10:00 AM . then drag the mousepointer to the opposite corner of the shape as required. Y As Single) Set poly = Map1.TrackRectangle The TrackRectangle method syntax has these parts: Part Description variable An object expression that evaluates to a Rectangle object. MapObjects Programmer’s Reference 531 sym.DrawShape poly. and click on a shape on Map to highlight it. the coordinates of newShape will remain in the Datum of fromCoordSys. This value is of type Double. and one Command Button named Command1. If a geoTrans object is used. This must be the same object type as newShape. The press the CommandButton to see that shape transformed to the selected coordinate system. Edit the code appropriately to add a sample MapLayer. the Z values on all points for the newShape will be modified appropriately. NB. densifyTol Optional. Supported object types are Point. See Also GeoTransformation Object Example This example shows the use of the Transform method on the ProjCoordSys object. and ensure a sutiable coordinate system is set on it. This defines the coordinate system that the shape should be transformed to. This specifies the coordinate system that fromShape is currently projected in. Line. When the shape is transformed. 10:00 AM . fromShape An object expression that evaluates to a shape object of type Point. Line. Option Explicit ‘Variables holding the selected feature Dim theShape As Object Dim transShape As Object Dim recs As New MapObjects2.Recordset ProgrammersReference. Rectangle or a Points collection. one Label named Label1. Rectangle objects and Points collections. paste the code into the Declarations section of a new Form containing a Map named Map1. Press F5. then this argument should be set to a GeoTransformation object that maps between the two coordinate systems. Use this argument to restrict the density of the vertices that are created.pmd 532 10/28/2004. then no new vertices will be added. If the object and fromCoordSys parameter have different datum. To try this example. geoTrans Optional. Polygon. Polygon. object An object expression that evaluates to an object in the Applies To list. If not specified. it may be necessary to add new vertices to define the new object’s shape. to trans- form a particular shape from the coordinate system of the MapLayer to another coordinate system. If not specified. This will cause the coordinates of newShape to be changed to the Datum of object during the transformation. 532 MapObjects Programmer’s Reference The Transform method syntax has the following object qualifier and arguments: Part Description newShape A variable that has been declared as an shape object. fromCoordSys An object expression that evaluates to an object in the Applies To list. CoordinateSystem = Map1. _ CoordinateSystem.Layers(0).Symbol Private Sub Command1_Click() If Not theShape Is Nothing Then ‘Create a different coordinate system to transform your selected ‘shape to.Type = moProjCS_WGS1972UTM_37N ‘A GeoTransformation should be used if a datum shift is ‘involved in the transformation Set transShape = toCS.FindGeoDataset(“westeuutm33”) If lyr. Dim dc As New MapObjects2. a transformation from moProjCS_WGS1972UTM_33N to ‘moProjCS_WGS1972UTM_37N should result in a transformed shape ‘visible on the current map extent.ProjCoordSys toCS.Transform(Map1.Layers.Database = “C:\Data” If Not dc.Symbol Dim newsym As New MapObjects2. The Label displays ‘details of the extent of the selected and the transformed shapes.Connect Then End Set lyr. theShape) ‘Try using different DensificationTolerance values.DataConnection Dim lyr As New MapObjects2.CoordinateSystem ‘Set the properties of two symbols ProgrammersReference.pmd 533 10/28/2004. MapObjects Programmer’s Reference 533 Dim extentStr As String Dim sym As New MapObjects2.Add lyr ‘The coordinate system is set to the same coordinate system as ‘the MapLayer Map1. as the coordinate systems are ‘similar. ‘allowing you to check if your transformation should be visible or ‘not.For example.Layers(0). to find the _ ‘appropriate values for your data Map1.GeoDataset = dc. 10:00 AM . ‘Note that the different coordinate system may transform the shape ‘to a location beyond the extent of the map.MapLayer dc.Refresh End If End Sub Private Sub Form_Load() ‘The properties should be set to appropriate values for your sample ‘data.Valid Then Map1. Dim toCS As New MapObjects2. 5 . moPointInPolygon.Point Set usrPt = Map1.Caption = extentStr End Sub Private Sub Map1_AfterLayerDraw(ByVal index As Integer.Extent.Extent.Bottom End If End If End Sub Private Sub Map1_MouseDown(Button As Integer.OLE_HANDLE) If Not theShape Is Nothing Then Map1.Bottom Label1.Right & “. 534 MapObjects Programmer’s Reference ‘This symbol is used to display the selected feature With sym . 10:00 AM .Layers(0).Caption = “Transform” extentStr = “Map Extent: “ & Map1.SearchShape(usrPt.Extent.Size = 1.OutlineColor = moCyan .Caption = Label1. x As _ Single.Top & “. “ & Map1.ToMapPoint(x.Extent. “ & _ Map1.Right & “.Caption & vbNewLine & “Shape2 Extent _ : “ & transShape. “ & theShape. “ & transShape. y As Single) If Button = 1 Then Dim usrPt As New MapObjects2.pmd 534 10/28/2004.Extent.Extent.Left & “. newsym Label1.Extent.Color = moRed . ByVal _ canceled As Boolean.Left & “. “ & theShape. ByVal hDC As Stdole. “ & _ Map1. Shift As Integer.Bottom If Not transShape Is Nothing Then Map1. “ _ & theShape. y) Set recs = Map1.Left & “.Style = moTransparentFill End With Command1. sym Label1.Extent. “”) ProgrammersReference. “ & transShape.Caption = extentStr & vbNewLine & “Shape1 Extent: “ _ & theShape.DrawShape transShape.Outline = True .Right _ & “.Extent.Extent.Extent.Extent.SymbolType = moFillSymbol .Top & “.DrawShape theShape.Top & “.Style = moLightGrayFill End With ‘This symbol is used to display the transformed feature With newsym .Outline = True . “ & transShape. Value Set transShape = Nothing Map1.Count = 1 Then Set theShape = recs. True The ImageLayer will display with a transparent color.Transparent [= boolean] The Transparent property syntax has these parts: Part Description object An object expression that evaluates to a ImageLayer object.Refresh End If ‘Right-Clicking zooms in on the tracked rectangle ElseIf Button = 2 Then Dim r As New MapObjects2.TrackRectangle Map1. Settings The settings for boolean are: Setting Description False (Default) The ImageLayer will be displayed with each color visible.Extent = r End If End Sub Transparent Property Applies To ImageLayer Object Description Returns or sets a value indicating whether the ImageLayer will be displayed with a transpar- ent color.Fields(“Shape”). as described in Settings. Remarks When setting the Transparent property to True. Syntax object. boolean A boolean expression specifying whether the ImageLayer is to be displayed with a transparent color. MapObjects Programmer’s Reference 535 If recs.Rectangle Set r = Map1. you should set the TransparentColor property to an appropriate value. 10:00 AM .pmd 535 10/28/2004. ProgrammersReference. OutputMap2 or PrintMap methods are used. ExportMap2.pmd 536 10/28/2004. Option Explicit Private Sub Check1_Click() If Check1. Shift As Integer. OutputMap. and a Map named Map1 containing one ImageLayer. Press F5 and click-drag a rectangle to zoom in.Transparent = False Map1. x As _ Single.Transparent = True Map1.Refresh Else Map1. See Also TransparentColor Property Example This example uses the Transparent and TransparentColor properties to control areas of an ImageLayer which are displayed as transparent.Layers(0).Top ProgrammersReference.Refresh End If End Sub Private Sub Form_Load() Check1. To try this example paste the code into the Declarations section of a form containing a CheckBox named Check1.Layers(0). ExportMap. a label named Label1. Toggle the check box to determine whether this transparent property is used when the map is displayed on screen.Left yf = y + Map1. y As Single) Dim cv As Long Dim r As Long Dim g As Long Dim b As Long Dim xf As Single Dim yf As Single If Button = 1 Then xf = x + Map1. The map control should be set to windowless opaque.Value Then Map1.Caption = “No transparent color set” End Sub Private Sub Map1_MouseDown(Button As Integer. Use the left mouse button to select which color should be set to transpar- ent. 536 MapObjects Programmer’s Reference The Transparent property is not supported for map output. 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. and must be set to False if the CopyMap.Caption = “Use transparent color” Label1. 10:00 AM . Syntax object.Refresh ElseIf Button = 2 Then Dim rect As New MapObjects2. Settings For more information on color settings. in a series of satellite photographs. “ & _ CStr(b) Map1. “ & CStr(g) & “.Extent = rect 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. For example. ProgrammersReference. color A value or constant that determines the color of pixels which are to be displayed as transparent. By setting the background color to transparent. 10:00 AM .Layers(0). MapObjects Programmer’s Reference 537 cv = Point(xf.TransparentColor [= color] The TransparentColor property syntax has these parts: Part Description object An object expression that evaluates to a ImageLayer object.TrackRectangle Map1.Rectangle Set rect = Map1.pmd 537 10/28/2004.TransparentColor = cv Map1. see the Color settings topic in the online help. each image may have outlines that overlap onto the next image. green and blue values r = cv Mod &H100 g = (cv / &H100) Mod &H100 b = (cv / &H10000) Mod &H100 Label1 = Str$(cv) & “: “ & CStr(r) & “. you can display these images together on a Map. Remarks The TransparentColor property may be used when an image has an outline or a background that you do not want to display. if the Transparent property is set to True. yf) ‘ extract the red. The default TransparentColor is White. Type = value The Type property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. as described in Settings. Unit Object Returns or sets a value that indicates the type of the object. Projection Object. The Type property is used with Field objects to indicate the operational type or data type of the field. These are: Field objects: FieldTypeConstants Datum objects:DatumConstants GeoCoordSys objects: GeographicCoordSysConstants GeoTransformation objects: GeographicTransformationConstants PrimeMeridian objects: PrimeMeridianConstants ProjCoordSys objects: ProjectedCoordSysConstants ProgrammersReference. Spheroid Object. value A numeric expression that specifies the type of the object.pmd 538 10/28/2004. See Also TransparentColor Property Example See Transparent Property Type Property Applies To Field Object. 538 MapObjects Programmer’s Reference After changing the TransparentColor. A type setting is made by reference to a constant appropriate for the object. you should Refresh the Map to see your changes. and allows these objects to be specified using a standard definition. PrimeMeridian Object. GeoCoordSys Object Description GeoTransformation Object. The constants use the POSC (Petrochemical Open Software Corporation) integer codes. 10:00 AM . The Type property is also used with objects that relate to map projections and coordinate systems. Datum Object. ProjCoordSys Object. Settings The settings for value should be selected from the appropriate list of constants for the object whose type is being set. Syntax object. Note the use of the FieldType Con- stants. 10:00 AM . Projection Constants.Recordset Dim oField As MapObjects2. Option Explicit Private Sub Form_Load() Option1. PrimeMeridian Constants.Layers(0). Spheroid Constants.Clear Set oRecset = Map1. and a Map named Map1 that has at least one MapLayer.Type > moNone And oField.Type < moString Then List1. paste the code into the Declarations section of a form containing two OptionButtons named Option1 and Option2. Unit Constants 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.Field List1.Name End If Next End Sub Private Sub Option2_Click() Dim oRecset As MapObjects2.Records For Each oField In oRecset. MapObjects Programmer’s Reference 539 Projection objects: ProjectionConstants Spheroid objects: SpheroidConstants Unit objects: UnitConstants See Also FieldType Constants. Press F5.Caption = “Numeric fields” Option2. GeographicTransformation Constants. a ListBox named List1.Caption = “String fields” End Sub Private Sub Option1_Click() Dim oRecset As MapObjects2. Datum Constants. To try this example.Recordset ProgrammersReference.AddItem oField. GeographicCoordSys Constants.pmd 539 10/28/2004.Fields If oField. ProjectedCoordSys Constants. then choose either of the two OptionButtons to list the corresponding field types. This is second of the two Shape objects whose Union is to be calculated. and is used internally. unionShape An object expression that evaluates to an object in the Applies To list. Will contain the resulting Shape after the Union.pmd 540 10/28/2004. ProgrammersReference. object An object expression that evaluates to an object in the Applies To list.Field Set oRecset = Map1. This Rectangle should entirely contain the object’s extent. Polygon Object. and should be of the same dimension as object (See Remarks).Layers(0). Line Object. (See Remarks). the resultShape will be Nothing.Fields If oField.extent]) The Union method syntax has these parts: Part Description resultShape An object expression that evaluates to a Shape object.Name End If Next End Sub Union Method Applies To Point Object. extent Optional.AddItem oField.Union (unionShape [. Remarks If the two Shapes do not have a valid Union.Clear For Each oField In oRecset. This is the first of the two Shape objects whose Union is to be calculated. Rectangle Object. 540 MapObjects Programmer’s Reference Dim oField As MapObjects2. 10:00 AM . Points Collection. An object expression that evaluates to a Rectangle object.Type = moString Then List1.Records List1. Ellipse Object Description Returns a shape that represents the geometric Union of two Shape objects of the same dimension. Syntax Set resultShape = object. g. You can however use a self-intersecting Line. then use an interim Object and then test the result using its ShapeType property to see what type of object it is. specifying Error 5000. and the return result will be a different object type depending on the nature of the objects processed. Rectangle or Polygon). Type of object unionShape Possible resultShape Point Point Point Points collection Points collection Points collection Point Point Points collection Points collection Line Line Line Rectangle Rectangle Rectangle Polygon Polygon Ellipse Polygon Rectangle Rectangle Polygon Polygon Ellipse Ellipse Rectangle Rectangle Polygon Polygon Ellipse An exception will be raised if an incompatible shape type is passed as an argument for unionShape. The following table summarizes the valid combinations and possible return results. Valid Object expected as argument. ProgrammersReference. MapObjects Programmer’s Reference 541 Only certain combinations of shape are valid. an exception is raised in Visual Basic. Where the resultShape could be more than one object type (e. 10:00 AM . You cannot use the Union method with a self-intersecting Polygon. If you do.pmd 541 10/28/2004. Intersect Method. 10:00 AM . x As _ Single.TrackingLayer. y As Single) If Button = 2 Then Dim r As New MapObjects2. Option 2. and 3 OptionButtons named Option1. XOr Method Example This example uses the Union method to allow the user to union rectangles.Polygon Dim unionEvent As New MapObjects2.Rectangle Set r = Map1.TrackRectangle Map1.Value Then Dim rect As New MapObjects2.FullExtent) Set unionEvent = Map1. The user point and the new shape generated by the Union operation are added to the tracking layer as GeoEvents. ellipses and polygons. then click on the map. and Option3. and choose an option.pmd 542 10/28/2004.Rectangle Dim eventRect As New MapObjects2.GeoEvent Set unionShape = shape1. 542 MapObjects Programmer’s Reference See Also Buffer Method. paste the code into the Declarations section of a form containing a Map named Map1 that has at least one MapLayer.union(shape2. To try this example. Shift As Integer. 1) Set shape1 = Nothing union = False End If End Sub Private Sub Map1_MouseDown(Button As Integer.Extent = r Exit Sub End If ‘Rectangle union If Option1. Map1. Option Explicit Dim shape1 As Object Dim shape2 As Object Dim union As Boolean Private Sub doUnion(shape As Object) If Not union Then Set shape1 = shape union = True ElseIf union Then Set shape2 = shape Dim unionShape As MapObjects2. Difference Method.AddEvent(unionShape.GeoEvent ProgrammersReference. Press F5. TrackPolygon Set eventPoly = Map1.SymbolType = moFillSymbol .GeoEvent Set poly = Map1.Style = moGrayFill . 0) Call doUnion(elli) ‘Polygon union ElseIf Option3.Style = moGrayFill .Value Then Dim poly As New MapObjects2.pmd 543 10/28/2004.Bottom elli.TrackingLayer.AddEvent(elli.TrackingLayer.Caption = “Ellipse” Option3.TrackingLayer.Value Then Dim elli As New MapObjects2.TrackingLayer.Caption = “Polygon” Map1.GeoEvent Set theExt = Map1.Left elli.Top elli.TrackingLayer. MapObjects Programmer’s Reference 543 Set rect = Map1.Left = theExt. 0) Call doUnion(rect) ‘Ellipse union ElseIf Option2.SymbolType = moFillSymbol .Rectangle Dim eventElli As New MapObjects2.Right Set eventElli = Map1.Color = moRed .OutlineColor = moRed End With With Map1.Ellipse Dim theExt As New MapObjects2.Bottom = theExt.AddEvent(rect.AddEvent(poly.Right = theExt. 10:00 AM .TrackingLayer.TrackRectangle elli.OutlineColor = moBlue ProgrammersReference.Symbol(0) .Caption = “Rectangle” Option2.SymbolCount = 2 With Map1. 0) Call doUnion(poly) End If End Sub Private Sub Form_Load() Option1.TrackRectangle Set eventRect = Map1.Color = moBlue .Top = theExt.Polygon Dim eventPoly As New MapObjects2.Symbol(1) . an attempt to add both strings would be successful. The Strings collection does represent a unique collection of strings.) Settings The settings for value are: Setting Description True (Default). on your second attempt. whereas if you attempted to add ‘Massachusetts’ twice. 10:00 AM . it considers ‘Maine’ and ‘MAINE’ distinct. as described in Settings. however. Remarks Strings is case-sensitive. To add multiple instances of the same string to a Strings collection. on your first attempt.Unique [= value] The Unique property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. See Also Add Method 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. especially the ValueMapRenderer. (Data type is Boolean. set Unique to False. To try this example. unique strings. The Strings collection and the Unique property are commonly used in association with Renderers. the method would return False and only the first string would be added to the collection. False The Strings collection represents a non-unique collection.pmd 544 10/28/2004. the Add method would return True. Syntax object. conse- quently. paste the code into the Declarations ProgrammersReference. however in this example the Strings collection merely populates the ListBox for illustration purposes only. 544 MapObjects Programmer’s Reference 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. value A boolean expression that specifies a unique collection. Value = 1 End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Dim sChar As String.Add Text1. 10:00 AM . Option Explicit Dim strs As New MapObjects2.Unique = Check1. Try to add one of the same text strings again.Caption = “Unique” Text1.Text = “” End If End Sub Unit Constants MapObjects defines the following constants for use with the Type property of a Unit object.AddItem vStr Next Text1. Click on the CheckBox to remove the check mark. The default Unit is moUnit_Degree. Constant Value Description moUnit_Meter 9001 International meter ProgrammersReference. MapObjects Programmer’s Reference 545 section of a Form that contains a TextBox named Text1. and a Map named Map1.pmd 545 10/28/2004. Press Enter to signal the end of the text. vStr As Variant strs. a CheckBox named Check1.Value sChar = Chr(KeyAscii) If Asc(sChar) = 13 Then strs.Strings Private Sub Form_Load() Check1. Press F5 and enter some text in the TextBox. a ListBox named List1.Text List1. Add additional text strings. and now try add the same text again.Clear For Each vStr In strs List1.Text = “” Check1. value 9102. 546 MapObjects Programmer’s Reference moUnit_Foot 9002 International foot moUnit_SurveyFoot 9003 US survey foot moUnit_AmericanFoot 9004 Modified American foot moUnit_ClarkeFoot 9005 Clarke’s foot moUnit_IndianFoot 9006 Indian geodetic foot moUnit_Link 9007 Link (Clarke’s ratio) moUnit_BenoitLink 9008 Link (Benoit) moUnit_SearsLink 9009 Link (Sears) moUnit_BenoitChain 9010 Chain (Benoit) moUnit_SearsChain 9011 Chain (Sears) moUnit_SearsYard 9012 Yard (Sears) moUnit_IndianYard 9013 Indian yard moUnit_Fathom 9014 Fathom moUnit_NauticalMile 9030 International nautical mile moUnit_GermanMeter 9031 German legal meter moUnit_SearsFoot 9032 Sears’ foot moUnit_Radian 9101 Radian moUnit_Degree 9102 Degree moUnit_ArcMinute 9103 Arc-minute moUnit_ArcSecond 9104 Arc-second moUnit_Grad 9105 Grad moUnit_Gon 9106 Gon moUnit_Microradian 9109 Microradian See Also Unit Object. 10:00 AM . Type Property ProgrammersReference.pmd 546 10/28/2004. Now press F5. 10:00 AM . Option Explicit Private Sub Form_Load() With Map1. unit An object expression that evaluates to a Unit object Example This example reads the Unit property of a MapLayer which has a coordinate system previsouly defined. or alternatively by setting the Factor property to specify the conversion factor between meters and a user-defined unit. ProjCoordSys Object Description Sets or returns a value that identifies the Unit upon which a coordinate system is based.Caption = “Units of MapLayer: “ & . Datum Object Unit Property Applies To GeoCoordSys Object.Layers(0).IsProjected Then Label1. Spheroid Object. Unit [= unit ] The Unit property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Projection Object. 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).Unit.GeoCoordSys. GeoCoordsys Object. The Unit object can be defined by reference to a pre-defined UnitConstant using the Type property.CoordinateSystem If .name ProgrammersReference. and a Label named Label1. PrimeMeridian Object. MapObjects Programmer’s Reference 547 Unit Object A Unit object is used to define the units of measurement used in a GeoCoordSys or ProjCoordSys coordinate system object. See Also Unit Object Syntax object. To try this example. Properties Factor Name Type See Also Unit Constants.pmd 547 10/28/2004. See Also Edit Method. an ARC/INFO coverage or an attribute table data source.g. Alterna- tively. Return Values The Updatable property return values are: Value Description True The object can be changed or updated. of a type that MapObjects cannot edit.Unit. Syntax object. 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. e. Update Method. MapObjects will not perform edits on a shapefile that has been opened for editing by another application. 10:00 AM . If the return value is False then either the data source underlying the Recordset is read-only.Updatable The Updatable property syntax has these parts: Part Description object An object expression that evaluates to a Recordset object.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. EditMode Property Example See CancelUpdate Method ProgrammersReference. 548 MapObjects Programmer’s Reference Else Label1.Caption = “Units of MapLayer: “ & .pmd 548 10/28/2004. or that the data source is currently being edited by another application. Delete Method. False The object cannot be changed or updated. a value of True indicates that the Recordset represents an SDE layer that the applica- tion may edit. its measure will be set using linear extrapolation.UpdateMeasures The UpdateMeasures method syntax has these parts: Part Description object An object expression that evaluates to a Line object. Delete Method. Where a vertex has more than one non-null measure value on one side. Syntax object. Remarks If you do not use Edit first.pmd 549 10/28/2004. an error occurs when you use Update or attempt to change a field’s value. See Also Edit Method. Update Method.Update The Update method syntax has these parts: Part Description object An object expression that evaluates to a Recordset object. If a Line object has only one non-null measure value. 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. MapObjects Programmer’s Reference 549 Update Method Applies To Recordset Object Description Saves the current record and any changes you have made to it. EditMode Property Applies To See EditMode Property Example See CancelUpdates Method UpdateMeasures Method Applies To Line Object Description Calculates a measure value for every vertex on a Line object that has a null value. Syntax object. either by interpolation or extrapolation. 10:00 AM . all vertices ProgrammersReference. and no non-null measure values on the other side. pmd 550 10/28/2004. all vertices will be set to zero. False The Map will not update while the application draws the ImageLayer. Settings The settings for boolean are: Setting Description True (Default) The Map will update while the application draws the ImageLayer. boolean A boolean expression specifying whether the Map updates while the application draws the ImageLayer. For a Line object with no non-null measures. See Also Point Object. Syntax object. 550 MapObjects Programmer’s Reference will receive this value. as described in Settings. Use the right mouse button to zoom to the full extent of the map. See Also Refresh Method Example This example uses the UpdateWhileDrawing property to control whether the Map will update while the application draws an ImageLayer. Measure Property Example See IsFullyMeasured Property UpdateWhileDrawing Property Applies To ImageLayer Object Description Returns or sets a value indicating whether the Map updates while the application draws the ImageLayer. whose bottom layer is an ImageLayer. 10:00 AM . Toggle the check box to determine whether to update the Map while drawing the 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. Option Explicit Private Sub Check1_Click() ProgrammersReference. Press F5 and click-drag a rectangle to zoom in.UpdateWhileDrawing [= boolean] The UpdateWhileDrawing property syntax has these parts: Part Description object An object expression that evaluates to a ImageLayer object. Extent = Map1. _ “UpdateWhileDrawing Example” End Else .1). Shift As Integer. ProgrammersReference.Layers(.Layers.Value = 1 Then .Value = 1 End Sub Private Sub Map1_MouseDown(Button As Integer.UpdateWhileDrawing = True ElseIf Check1.Count .Value = 0 Then .1).Count .Caption = “Update while drawing” Check1.1).Count .LayerType = moMapLayer Then MsgBox “Bottom layer must be an ImageLayer”. MapObjects Programmer’s Reference 551 With Map1 If .1).Refresh End With End Sub Private Sub Form_Load() With Map1 If .Extent = Map1.Layers.Count .LayerType = moMapLayer Then MsgBox “Bottom layer must be an ImageLayer”.Layers.Layers(.1).Layers.Layers. LabelPlacer Object.Count . 10:00 AM . _ “UpdateWhileDrawing Example” End End If If Check1.pmd 551 10/28/2004.UpdateWhileDrawing = False End If .Layers(.TrackRectangle Else Map1. vbCritical.Layers(.FullExtent End If End Sub UseDefault Property Applies To EventRenderer Object. y As Single) If Button = 1 Then Map1. 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.UpdateWhileDrawing = True End If End With Check1. vbCritical.Layers(. x As _ Single. as described in Settings. Table Object Description Returns or sets the name of a User for an SDE DataConnection or an ODBC Table. Settings The settings for value are: Setting Description True The renderer will use the symbol specified in the DefaultSymbol property. DefaultSymbol Property Example See DefaultSymbol property User Property Applies To DataConnection Object.UseDefault [= value] The UseDefault property syntax has these parts: Part Description object An object expression that evaluates to a renderer in the Applies To list. Syntax object. username A string expression that evaluates to a valid user name for the specified object. False The renderer will not use the symbol specified in the DefaultSymbol property.pmd 552 10/28/2004. See Also Symbol Object. See Also Password Property Example See Password property ProgrammersReference. 10:00 AM . value A boolean expression that determines whether the Renderer should use the DefaultSymbol to draw the field values that are not listed explicitly. 552 MapObjects Programmer’s Reference Syntax object.User [= username] The User property syntax has these parts: Part Description object An object expression that evaluates an object in the Applies To list. since the StreetTable and all comparison fields are valid. MapObjects Programmer’s Reference 553 Valid Property Applies To ImageLayer Object. as indicated in Return Values. Syntax object. To try this example. MapObjects found a world file that corresponds to the ImageLayer object and supports its image file type.Valid [= boolean] The Valid property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. True indicates that you can call the LocateCandidate method or the BatchMatch method. False In the case of a MapLayer. Return Values The Valid property return values are: Value Description True In the case of a MapLayer. 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. True indicates that you can call the StandardizeAddress method to standardize an address. Geocoder Object. In the case of an ImageLayer. indicates that the object is not valid. Use the LastError property to check the type of error See Also File Property. Option Explicit ProgrammersReference. however. In the case of a Standardizer object. MapObjects did not find a world file for the object or does not support the image file type specified. For a Geocoder or Standardizer. MapObjects determined that the GeoDataset of the MapLayer is valid and in the case of an ImageLayer. StreetTable Property Example This example uses the Valid property to determine whether an ImageLayer or a MapLayer can be added to a Map. this does not guarantee that a match will occur. Standardizer Object Description Returns a value that indicates whether the object is valid. MapObjects determined that the GeoDataset of the MapLayer was not valid. 10:00 AM . press F5 and then click Command1.pmd 553 10/28/2004. boolean A boolean expression specifying whether the object is valid or not. In the case of a Geocoder object. MapLayer Object. value An expression that evaluates to a value appropriate to the data type as specified by the Type property of an object. vbExclamation.Count > 0 Then If Map1.LayerType Case 0 sMsg = “MapLayer” Case 1 sMsg = “ImageLayer” End Select MsgBox “Valid “ & sMsg. vbExclamation. _ “MapObjects2” End If Else MsgBox “No layers available”.Valid Then Select Case Map1.Value (index) [= value] ProgrammersReference. ValueMapRenderer Object.Layers(0). “MapObjects2” Else MsgBox “The “ & sMsg & “ is not valid”. 10:00 AM . Syntax For a EventRenderer. 554 MapObjects Programmer’s Reference Private Sub Command1_Click() Dim sMsg As String If Map1. (Data type is Variant). LabelPlacer or ValueMapRenderer Object object.Layers(0). “MapObjects2” End If End Sub Value Property Applies To Field Object.Value [= value] The Value property syntax for a Field object has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. or sets a value at the specified index in the Value collection.pmd 554 10/28/2004. vbInformation. LabelPlacer Object Description Returns or sets the value of an object. EventRenderer Object. Syntax For a Field Object object.Layers. Index must be a number from 0 to a number that is one less than the ValueCount property of the EventRenderer. and a red symbol to those with “Jones”. One solution is to return the value as a String.147.Value The Variant data type stores whole numbers as Long values. For example. 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. as follows. Dim varValue As Variant varValue = myRecordSet.Color = moRed . index An integer that specifies the position of a member of a group of Values. which have an upper limit of 2.Value(1) = “Jones” .483.147. the code below would assign a blue symbol to those features with “Smith” in the Name Field. LabelPlacer or ValueMapRenderer object. With myEvRend .Records. MapObjects Programmer’s Reference 555 The Value property syntax for a EventRenderer.Fields(“ID”). LabelPlacer or ValueMapRenderer object has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Symbol(1). 10:00 AM .Symbol(0). using the ValueAsString function. This can be trapped for and appropriate action taken. For example. If MapObjects encounters a value in a Field of FieldType moLong that cannot be held as a Long value it will raise an error.647 and a lower limit of –2. and convert it to a floating-point data type.483. LabelPlacer or ValueMapRenderer indicates which Symbol is used by the Renderer to draw each feature. value A string expression that evaluates to the required value for the renderer.ValueCount = 2 . the following code returns a Variant containing the value of the “ID” field for the current record.pmd 555 10/28/2004.Field = “Name” .648.Value(0) = “Smith” ‘ Value 0 is drawn with Symbol 0 .ValueAsString) Setting a Value in the value array of an EventRenderer.Color = moBlue End With See Also Type Property ProgrammersReference. In Visual Basic this can be done using the CDbl function.Fields(“ID”). Dim dblVal As Double dblVal = CDbl(lyr. Some supported data sources can store whole numbers that are beyond these limits. pmd 556 10/28/2004.ListIndex)).ValueAsString [= value] The ValueAsString property syntax has these parts: Part Description object An object expression that evaluates to a Field object.Layers(0).Layers(0).Fields Combo1.Value oMapRecords.AddItem oMapRecords.name Next Combo1. a ListBox named List1. ProgrammersReference. paste the code into the Declarations section of a form containing a ComboBox named Combo1.Text = “Select a field name” End Sub ValueAsString Property Applies To Field Object Description Returns a value of a Field as a String.EOF List1.AddItem oField.List(Combo1. and a Map named Map1 that contains at least one MapLayer.MoveNext Loop End Sub Private Sub Form_Load() Dim oField As MapObjects2. 10:00 AM .Records List1.Recordset Set oMapRecords = Map1. 556 MapObjects Programmer’s Reference Example This example uses the Value property to return the value of a specified field for each record of a MapLayer’s recordset. Press F5 and choose the name of a Field in the ComboBox. Option Explicit Private Sub Combo1_Click() Dim oMapRecords As MapObjects2.Records.Clear Do While Not oMapRecords.Field For Each oField In Map1.Fields _ (Combo1. To try this example. Syntax object. .Clear Set oColHead = .Width / 3) Set oColHead = . To try this example.ColumnHeaders.MapLayer Dim oField As MapObjects2.Symbol.SymbolType = moFillSymbol Then Set oRecset = oLayer.Layers(0) If oLayer.FromMapPoint oPoint. then click a feature to identify it.ListItems. Value Property Example This example uses the ValueAsString property to populate a column of Field values. y) Set oLayer = Map1. .Add(. Shift As Integer. 10:00 AM .pmd 557 10/28/2004. _ ToMapDistance(100). 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.Width / 3) For Each oField In oRecset.Add(. “Value”. fYCoord With ListView1 . oField.ListItems. “”) Else Set oRecset = oLayer. Press F5.Add(. “Field”. . fXcoord. y As Single) Dim oRecset As MapObjects2. Map1.ToMapPoint(x. .ColumnHeaders.View = lvwReport . fYCoord As Single Dim oPoint As Point Dim oLayer As MapObjects2. “”) End If If Not oRecset. . when you click a feature to identify it.SearchShape(oPoint. moPointInPolygon.SearchByDistance(oPoint. See Also Recordset Object.Fields Set oItem = .Recordset Dim oColHead As ColumnHeader Dim oItem As ListItem Dim fXcoord As Single. MapObjects Programmer’s Reference 557 value A variable declared to be of string data type that contains a string represen- tation of the value contained in the Field. regardless of their type. x As _ Single. Option Explicit Private Sub Map1_MouseDown(Button As Integer.Field Set oPoint = Map1.Name) ProgrammersReference.EOF Then Map1. 558 MapObjects Programmer’s Reference oItem.Caption = “Apply Renderer” ProgrammersReference. The Map should have one maplayer. Try choosing the different options to render using different value calaulations.Caption = “Render by Minimum Z” Command1. as described in Settings Settings The settings for value are ZValueCalcConstants. Option2 and Option3. paste the code into the Decalarations section of a form Containing a Map named Map1.pmd 558 10/28/2004. consisting of polygons which have Z values.Caption = “Render by Mean Z” Option3. Press F5 and click the command button.ZRenderer Private Sub Form_Load() Option1. The ValueCalculation property allows either the Maximum. To try this example.Caption = “Render by Maximum Z” Option2. value An integer specifying how the Z value is to be used for rendering.SubItems(1) = oField.ValueCalculation [= value] The ValueCalculation property syntax has these parts: Part Description object An object expression that evaluates to a ZRenderer object. a CommandButton named Command1 and 3 OptionButtons named Option1. 10:00 AM . Minimum or Mean Z value for a shape to be used for rendering Syntax object. See Also Z Property Example This example show the use of the ValueCalculation property of a Z Renderer. Option Explicit Dim oZRend As New MapObjects2.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. Try changing the fBreakVal numbers to suit the Z values in your dataset. Renderer = oZRend Map1.Break(0) = fBreakVal .pmd 559 10/28/2004.RampColors moRed.Value = True Then .Value = True Then . MapObjects Programmer’s Reference 559 End Sub Private Sub Command1_Click() Dim fBreakVal As Double With oZRend .ValueCalculation = moMeanZValue End If End With Set Map1. 10:00 AM .Value = True Then .Layers(0).ValueCalculation = moMinZValue ElseIf Option3.SymbolType = moPointSymbol .BreakCount = 2 ‘Try changing these values to suit the range of Z values in ‘your data fBreakVal = 500# fBreakVal = 1000# .Break(1) = fBreakVal ‘Ensure the symbol type is appropriate for your dataset .ValueCalculation = moMaxZValue ElseIf Option2.Refresh End Sub Private Sub Option1_Click() Command1_Click End Sub Private Sub Option2_Click() Command1_Click End Sub Private Sub Option3_Click() Command1_Click End Sub ProgrammersReference. moYellow If Option1. paste the code into the Declara- tions section of a form containing a ListBox named List1. 10:00 AM .Strings Dim i As Integer Dim vStr As Variant ProgrammersReference.Fields If VarType(oField. Value Property 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.AddItem oField. EventRenderer Object. and then press F5 and click a field name in the list whose unique values to display. LabelPlacer Object Description Returns or sets the number of values of its Field property that a renderer will assign a Symbol.Value) _ <= moString Then List1.ValueCount [= value] The ValueCount property syntax has these parts: Part Description object An object expression that evaluates to a renderer .name End If Next End Sub Private Sub List1_Click() Dim sFldname As String Dim strs As New MapObjects2.Layers(0).Field Set moRecs = Map1.Recordset Private Sub Form_Load() Dim oField As MapObjects2. 560 MapObjects Programmer’s Reference ValueCount Property Applies To ValueMapRenderer Object.pmd 560 10/28/2004. and a Map named Map1 that contains at least one MapLayer. See Also Field Property. value An integer from 0 to the number of values of its Field property that will be symbolized by the renderer. Option Explicit Dim moRecs As New MapObjects2. Syntax object.Value) > vbNull And VarType(oField. To try this example.Records For Each oField In moRecs. ValueAsString moRecs. value A string expression that specifies a name of a field in a Recordset.ValueField [= value] The ValueField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Refresh End Sub 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.ValueCount = strs.pmd 561 10/28/2004. MapObjects Programmer’s Reference 561 Dim oRenderer As New MapObjects2.ValueMapRenderer Set moRecs = Map1.Layers(0). 10:00 AM . Syntax object.EOF strs.MoveNext Loop ‘ set up a ValueMap renderer Set Map1.Records sFldname = List1.Renderer = oRenderer With oRenderer .ListIndex) ‘iterate through the records and accumulate values Do While Not moRecs.Value(i) = vStr i = i + 1 Next End With Map1.List(List1.Layers(0).Count ‘ set the values for the renderer i = 0 For Each vStr In strs .Field = sFldname . ProgrammersReference.Add moRecs(sFldname). whose values you can use to set a factor by which to scale the Symbol associated with the feature. $ANGLE and $SCALE. features with the value ‘A31’ are labeled with larger text. A ValueMapRenderer may have up to 32. A ValueMapRenderer is a creatable object in MapObjects. If you are using the ValueMapRenderer with a MapLayer that contains Point features. Boolean data type is not supported in a ValueMapRenderer. ValueCount Property Example See LabelPlacer Object 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. By setting its ValueCount property you can determine how many values of its Field property the ValueMapRenderer will provide a symbol for. 562 MapObjects Programmer’s Reference Remarks The ValueField property should be set to a name of a Field in the MapLayer’s Recordset. In Visual Basic.e. In the example code. the size of the Symbol array. by setting the SymbolType property. and providing a Value and Symbol. In addition. By setting the ValueCount property you can determine how many values of its ValueField property the LabelPlacer will provide a Symbol for. Developers familiar with ARC/INFO label feature classes will recognize that these two latter properties map well onto two pseudo items associated with labels. 10:00 AM . 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. You may set the Field property to equal any field in the MapLayer which contains numeric or string values. i.pmd 562 10/28/2004. The named Field should contain a range of values value indicating which TextSymbol from the Symbol array is used to draw the labels. depending on what kinds of features are associated with the MapLayer. By setting the ValueField property to ‘CFCC’. the sample dataset contains a field named ‘CFCC’ containing road classification data. See Also Field Property. you can set a property and refer to the coverage’s pseudo items using the name of the pseudo item without the preceding dollar sign ($). 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. If you base the MapLayer you’re working with on an ARC/INFO point coverage. You can specify the type of Symbol to associate with the ValueMapRenderer. here’s one way to create a ValueMapRenderer: ProgrammersReference. for example $SCALE should be referenced as SCALE.767 different Values in the value array. Renderer = New MapObjects2. value A value or constant that determines the vertical alignment as described in Settings.pmd 563 10/28/2004. Settings The settings for value are AlignmentConstants.Layers(0).VerticalAlignment [= value] The VerticalAlignment property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. MapLayer Object. Symbol Object VerticalAlignment Property Applies To TextSymbol Object Description Returns or sets a value that determines the vertical alignment of text for a TextSymbol object. TrackingLayer Object ProgrammersReference. See Also HorizontalAlignment Property Example See HorizontalAlignment Property Visible Property Applies To ImageLayer Object. Note that only the Top. Bottom. MapObjects Programmer’s Reference 563 Set Map1. 10:00 AM .ValueMapRenderer Properties DefaultSymbol ScalingField Tag ValueCount Field Symbol UseDefault RotationField SymbolType Value See Also MapLayer Object. Center and Baseline AlignmentConstants are valid for VerticalAlignment. Syntax object. See Also Enabled Property Example This example uses the Visible property to toggle whether a MapLayer displays when you refresh a Map. 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.Refresh End Sub Private Sub Form_Load() Command1. Option Explicit Private Sub Command1_Click() Map1. Settings The settings for boolean are: Setting Description True (Default) Object is visible.pmd 564 10/28/2004.Caption = “Hide” Else Command1. 564 MapObjects Programmer’s Reference Description Returns or sets a value indicating whether an object is visible or hidden. Press F5 and click the button to toggle whether the first MapLayer is visible.Layers(0). boolean A boolean expression specifying whether the object is visible or hidden as indicated in Settings. False Object is hidden.Visible [= boolean] The Visible property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Visible = Not Map1.Layers(0).Caption = “Show” End If Map1.Visible Then Command1.Layers(0). Syntax object. 10:00 AM .Visible If Map1. To try this example.Caption = “Hide” End Sub ProgrammersReference. VisibleRegion [= shape ] The VisibleRegion property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. the map should only be visible inside the polygon you just drew. when setting the VisibleRegion of a Map placed on a Form with a ScaleMode of centimeters. Rectangle or Ellipse. For example. Areas of the Map control outside the VisibleRegion become transparent. Syntax object. ExportMap2. ExportMap. This property is write-only. This defines the visible region of the map. for example the container form. Extent Property Example This example uses the VisibleRegion change the shape of the map visible to the user. MapObjects Programmer’s Reference 565 VisibleRegion Property Applies To Map Object Description Allows the shape of a Map control to be changed to that of a specific shape object. OutputMap2 or PrintMap methods are used. To try this example. Multipart shapes are not supported for the VisibleRegion property. Remarks When a VisibleRegion is set. The VisibleRegion property is not supported for map output. When you finish the polygon by double-clicking. paste the code into the Declarations section of a form containing a Map named Map1 containing at least one map layer. The resultant effect is that only the areas of the MapLayers or ImageLayers contained in the Map control’s Layer collection which fall within the shape specified will be drawn. Rectangle Object. and reveal the objects below them. 10:00 AM . or other controls. The shape should be defined in the same units as the Map’s container object. ensure that ScrollBars are disabled. the Map extent itself remains rectangular. Ellipse Object. when the CopyMap. the shape should be defined in centimeters. OutputMap. shape An object of type Polygon. If setting a Map’s VisibleRegion. Care should be taken to ensure the shape is defined in the correct coordinate system. Option Explicit ProgrammersReference. the full area of the Map canvas will be output.pmd 565 10/28/2004. and then press F5. Click on the map to track a polygon. See Also Polygon Object. Count . 10:00 AM . Width is in the scale units of the object’s container. 566 MapObjects Programmer’s Reference Private Sub Map1_MouseDown(Button As Integer.Points Dim newPoly As New MapObjects2.Y = tempY tempParts.Points Dim tempX As Single Dim tempY As Single For Each polyPts In poly. tempX.pmd 566 10/28/2004.X = tempX tempPt.Parts.Add tempPt Next i Next polyPts newPoly.FromMapPoint polyPts.1 Map1.Width The Width property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list.Add tempParts Set Map1. Rectangle Object Description Returns the horizontal dimension of an object.Polygon Dim tempPt As New MapObjects2. Y As Single) Dim poly As New MapObjects2. map units. Return Values The property returns a numeric expression specifying the dimension of an object. that is.Point Dim tempParts As New MapObjects2. X As _ Single. tempY tempPt. Syntax object.Item(i).VisibleRegion = newPoly End Sub Width Property Applies To Ellipse Object.Polygon Set poly = Map1.Parts Dim i As Integer For i = 0 To polyPts. Measure- ments are from the center of the object’s border so that objects with different border widths align correctly.TrackPolygon Dim polyPts As MapObjects2. Shift As Integer. ProgrammersReference. Visible = False End If End With End Sub Private Sub Map1_MouseDown(Button As Integer.Press F5.Rectangle Set oRect = Map1. ByVal hDC _ As Stdole.Width > (. MapObjects Programmer’s Reference 567 See Also Height Property Example This example uses the Width property to control whether or not a MapLayer displays. 10:00 AM .pmd 567 10/28/2004.TrackRectangle If oRect.Layers(0). x As _ Single. Shift As Integer.FullExtent. vbInformation Else Map1.Layers(0). y As Single) Dim oRect As MapObjects2.Extent = oRect End If End Sub WindowMode Constants MapObjects defines the following type constants for use with the WindowMode property of Map objects.Visible = True Else . ProgrammersReference. Layers(0) should contain more detail than Layers(1).Visible = True .Width / 4) Then . Option Explicit Private Sub Map1_BeforeLayerDraw(ByVal index As Integer.Visible = False .Height = 0 Then MsgBox “Drag a box to zoom in”. the visibility of the first layer is established based on the current zoom level. Zooming in causes more map content to be displayed.Layers(1). To try this example.Extent. You can drag a box on the Map to zoom in. Before the layers of the map are drawn.OLE_HANDLE) With Map1 If . If the current map Extent is less than half the FullExtent.Layers(1). paste the code into the Declarations section of a form containing a Map named Map1 that contains at least two MapLayers. the first layer becomes visible. Settings The WindowMode property settings are WindowModeConstants. A refresh of a Windowless Transparent Map control will only redraw features in the MapLayer. 10:00 AM .WindowMode The object placeholder represents an object expression that evaluates to a Map. moTransparent 2 Only the foreground of the Map is drawn. i. ScrollBars are not supported in either of the Windowless modes (Opaque or Transparent). windowed controls will be drawn on top of the Map. controls positioned behind the Map will be visible through parts of the Map which have no features. Mouse cursors used for Windowless controls should be Windows standard cursors. Z order is respected between other windowless controls. Windowed controls will be drawn on top of it. Like Opaque mode. Unlike Opaque mode. This will force the ProgrammersReference. irrespective of their relative Z order. If your application does not refresh the entire Map area. The Map control is drawn on all container forms in a Windowed state. irrespective of their relative Z order. therefore panning and zooming in may result in artifacts remaining in areas of the Map which have not been re-drawn. the features in the Map’s Layers collection.pmd 568 10/28/2004. DragFiles and DropFiles events are not supported for Windowless Map controls. See Also Map Object WindowMode Property Applies To Map Object Description Returns or sets the way that a Map control is rendered on its container form. 568 MapObjects Programmer’s Reference Constant Value Description moWindowed 0 (Default).e. Remarks Windowless controls are not supported by Visual C++ or Visual Basic for Applications. Syntax object. except that in a Windowless state. The WindowMode of a Map control may only be changed during design time. moOpaque 1 The Map is drawn exactly the same as in Windowed mode. a solid filled rectangle may be placed on the form behind the Map control. Z order is respected between other windowless controls. In the case of a GeoEvent.name = “Wingdings” . The horizontal coordinate is the X property and the vertical coordinate is the Y property. a CheckBox named Check1. See Also Measure Property.Bold = False End With Randomize ‘prepare for random movement ‘label positioning and initialization With Label1 . and a Map named Map1 that contains at least one MapLayer. MapObjects Programmer’s Reference 569 entire area to be re-drawn. Syntax object. Panning on a Windowless Transparent Map control will change the background of the Map control to the current BackColor.Y [= value] The X and Y property syntaxes have these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Z Property Example This example uses the X and Y properties to report the location of a moving GeoEvent object on a Tracking Layer. Press F5. Option Explicit Private Sub Form_Load() Dim oFont As New StdFont Dim oPoint As New Point With oFont . a Label named Label1. paste the code into the Declarations section of a form containing a Timer named Timer1. X. the properties are read-only.Caption = “” ProgrammersReference. Y Properties Applies To Point Object Description Return or set the coordinates of an object. The code positions the GeoEvent at the center of the Map initially. 10:00 AM .X [= value] object. Click on the check box to toggle the GeoEvent motion on and off.pmd 569 10/28/2004. To try this example. value A numeric expression specifying a coordinate. 5) With Map1.Interval = 500 End If End Sub ProgrammersReference.Symbol(0) .Left .TrackingLayer.pmd 570 10/28/2004.Style = moTrueTypeMarker .” & .0.Width / 20 Set oGEvt = Map1.Caption = “GeoEvent motion” ‘symbol properties Map1.TrackingLayer.y ‘report the coordinates End With End Sub Private Sub Check1_Click() If Check1. fMaxdist * (Rnd .TrackingLayer.SymbolCount = 1 With Map1.Center oPoint. 0 End With End Sub Private Sub timer1_Timer() Dim fMaxdist As Double Dim oGEvt As MapObjects2.Value = 0 Then Timer1.y = .Height End With Check1.0.Interval = 0 Else Timer1.5).Color = moDarkGreen .TrackingLayer.x = .GeoEvent fMaxdist = Map1.x oPoint.y Map1.CharacterIndex = 81 End With ‘put a GeoEvent object on the TrackingLayer With Map1.AutoSize = True ‘coordinates vary in width .Extent.Size = 14 .x & “.Caption = .Move fMaxdist * (Rnd .Font = oFont .Event(0) Label1.TrackingLayer.Event(0) oGEvt.Extent.AddEvent oPoint. 570 MapObjects Programmer’s Reference . 10:00 AM .Top + Map1.Top = Map1.Left = Map1.Height + . Line Object.extent]) The Xor method syntax has these parts: Part Description resultShape An object expression that evaluates to a shape object.e.Xor (xorShape [. value A string expression that specifies a name of a Field in a Recordset. ProgrammersReference. MapObjects Programmer’s Reference 571 XOffsetField Property Applies To LabelRenderer Object Description Returns or sets the Field that contains horizontal offset distance information for a LabelRenderer object.XOffsetField [= value] The XOffsetField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. 10:00 AM . See Also TextSymbol Object Example See FittedField Property XOr Method Applies To Point Object. Syntax Set resultShape = object. Ellipse Object Description Returns a shape that represents the symmetrical difference (eXclusive OR) of two shape objects of the same dimension i. the resulting shape will be equivalent to the Difference of the Union and the Intersection of the two shapes. Syntax object. (See Remarks). Remarks The property is especially useful when rendering ARC/INFO annotation features. the LabelRenderer makes use of the value of the specified Field to set the horizontal offset distance of the label. Points Collection. If specified. Will contain the resultant shape that represents the symmetrical difference. Rectangle Object.pmd 571 10/28/2004. Polygon Object. and the return result will be a different object type depending on the nature of the objects processed. 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. extent An object expression that evaluates to a Rectangle object. This Rectangle should entirely contain the object’s extent. the resultShape will be Nothing. 572 MapObjects Programmer’s Reference object An object expression that evaluates to an object in the Applies To list. 10:00 AM . and is used internally. The following table summarizes the valid combinations and possible return results.pmd 572 10/28/2004. Only certain combinations of shape are valid. Remarks If the two Shapes do not have a valid Xor. This is the first of the two shape objects whose symmetrical difference is to be calculated. Type of object Valid xorShape Possible resultShape Point Point Point Points collection Points collection Points collection Point Point Points collection Points collection Line Line Line Rectangle Rectangle Rectangle Polygon Polygon Ellipse Polygon Rectangle Rectangle Polygon Polygon Ellipse Ellipse Rectangle Rectangle Polygon Polygon Ellipse ProgrammersReference. and should be of the same dimension as object (See Remarks). Option Explicit Dim shape1 As Object Dim shape2 As Object Dim exclOr As Boolean Private Sub doXor(shape As Object) If Not exclOr Then Set shape1 = shape exclOr = True ElseIf exclOr Then Dim xorShape As Object Dim xorEvent As New MapObjects2.Xor(shape2. Map1. an exception is raised in Visual Basic. Care must be taken to add events to the tracking layer using the appropriate symbol for the resultant shape type. press F5. Where the resultShape could be more than one object type (e. The line and the new shape generated by the Intersect operation are added to the tracking layer as GeoEvents.ShapeType You cannot use the XOr method with a self-intersecting Polygon. Rectangle or Polygon).FullExtent) Set xorEvent = Map1. then use an interim object and then test the result using its ShapeType property to see what type of object it is. paste the code into the Declarations section of a form containing a Map named Map1 that has at least one MapLayer. many points. Union Method Example This example uses the ExclusiveOr method to allow the user to perform Exclusive Or opera- tions lines. Intersects Method. MapObjects Programmer’s Reference 573 An exception will be raised if an incompatible shape type is passed as an argument for xorShape. specifying Error 5000. as in the Visual Basic code fragment below: Dim resultShape as Object resultShape = myPolygon. Note. and then click on the map to track two lines. 1) Set shape1 = Nothing exclOr = False End If End Sub ProgrammersReference.Intersect(secondPolygon. If you do. To try this example. See Also Difference Method. Valid Object expected as argument.GeoEvent Set shape2 = shape Set xorShape = shape1.AddEvent(xorShape.TrackingLayer.Extent) MsgBox “Result of Intersect is a “ & resultShape .pmd 573 10/28/2004. You can however use a self-intersecting Line.myLayer. or a line. an intersection of two lines may be a point.g. 10:00 AM . TrackingLayer.Polygon Dim eventLine As New MapObjects2.SymbolType = moFillSymbol .Symbol(0) .pmd 574 10/28/2004.Rectangle Set r = Map1.YOffsetField [= value] ProgrammersReference.SymbolCount = 2 With Map1.TrackPolygon Set eventLine = Map1.TrackingLayer.SymbolType = moFillSymbol .Color = moMagenta .AddEvent(poly.Style = moGrayFill .Extent = r Exit Sub End If ‘Line difference Dim poly As New MapObjects2.GeoEvent Set poly = Map1. Syntax object. x As _ Single.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.Symbol(1) . Shift As Integer.Color = moCyan .OutlineColor = moCyan End With With Map1.TrackingLayer.TrackRectangle Map1.TrackingLayer. 574 MapObjects Programmer’s Reference Private Sub Map1_MouseDown(Button As Integer.Style = moGrayFill . 10:00 AM . y As Single) If Button = 2 Then Dim r As New MapObjects2. 0) Call doXor(poly) End Sub Private Sub Form_Load() exclOr = False Map1. If specified.Point. by allowing the user to specify a Z value for a selected vertex in a polygon. Remarks The property is especially useful when rendering ARC/INFO annotation features. paste the code into the Declarations section of a form containing a Map named Map1. and two corresponding labels named Label1 and Label2. value A string expression that specifies a name of a Field in a Recordset. Y Property Example This example demonstrates how a Z values may be assigned to point objects. 10:00 AM . Press F5. See Also ZRenderer Object.pmd 575 10/28/2004. To try this example. oPoly As _ ProgrammersReference. Option Explicit Dim moPoly As MapObjects2.Z [= value ] The Z property syntaxes has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. X Property. MapObjects Programmer’s Reference 575 The YOffsetField property syntax has these parts: Part Description object An object expression that evaluates to an object in the Applies To list. Syntax object. two TextBoxes named Text1 and Text2. value A numeric expression specifying a height value.Polygon Function SelectVertex(oPoint As MapObjects2. the LabelRenderer makes use of the value of the specified Field to set the vertical offset distance of the label. See Also TextSymbol Object Example See FittedField Property Z Property Applies To Point Object Description Return or set the height coordinate of an object. 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. Text <> “” Then Dim zVal As Double zVal = Text2.Y = oPoints(iVertex). moPoly Dim oPoint As New MapObjects2.DistanceTo(oPoint) < fTol Then SelectVertex = i Exit Function End If Next SelectVertex = -1 End Function Private Sub Map1_MouseDown(Button As Integer.ToMapDistance(Text1.Text) Set oPoints = oPoly. moPoly) If iVertex <> -1 Then ‘SetZVertex iVertex.Point Dim oPoints As MapObjects2. oPoint ProgrammersReference.Z = zVal End If oPoints. 10:00 AM .ToMapPoint(X.Parts(0) If oPoints. X As _ Single. 576 MapObjects Programmer’s Reference Polygon) As Integer ‘Find the vertex of the polygon closest to the user selected point Dim fTol As Double Dim oPoints As MapObjects2.TrackPolygon ‘Get selected vertex and set the z value ElseIf Button = 2 And Not moPoly Is Nothing Then iVertex = SelectVertex(Map1.Count .Y If Text2.X = oPoints(iVertex).Count >= 3 Then oPoint.Parts(0) For i = 0 To oPoints. Y As Single) Dim iVertex As Integer ‘Create a polygon If Button = 1 Then Set moPoly = Map1.Text oPoint.1 ‘2 If oPoints(i). Shift As Integer.pmd 576 10/28/2004.Set iVertex.X oPoint.Points Dim tolerance As Double If iVertex >= 0 Then Set oPoints = moPoly. Y).Points Dim i As Integer fTol = Map1. Bottom = 0: oRect.Color = moRed oPtZSym. oTxtSym Else Map1. MapObjects Programmer’s Reference 577 End If End If End If End If Map1.06 oTxtSym. oPtSym End If Next End If End Sub Private Sub Form_Load() Dim oRect As New Rectangle oRect.Symbol Dim oPtSym As New MapObjects2.Color = moBlack Map1. oSym ‘Draw each vertex differently depending upon if it has a ‘z value set or not For Each oPoint In moPoly.DrawShape moPoly.Color = moPaleYellow oPtSym.Top = 100 ProgrammersReference.Refresh True End Sub Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As _ Stdole.Parts(0) If Not oPoint.DrawText oPoint.DrawShape oPoint.Z = 0 Then Map1.DrawShape oPoint.OLE_HANDLE) Dim oPoint As MapObjects2.TrackingLayer.SymbolType = moPointSymbol oPtSym.Color = moBlue oTxtSym.Left = 0: oRect. oPtZSym Map1.SymbolType = moPointSymbol oPtZSym.Right = 100: oRect.pmd 577 10/28/2004.Height = 0.Point Dim oSym As New MapObjects2. 10:00 AM .TextSymbol If Not moPoly Is Nothing Then oSym.Font = “Arial” oTxtSym.Symbol Dim oTxtSym As New MapObjects2.Symbol Dim oPtZSym As New MapObjects2. oPoint.Z. Renderer = New MapObjects2. here’s one way to create a ZRenderer: Set Map1.Caption = “Tolerance” Label2. depending on what kinds of features are associated with the MapLayer.pmd 578 10/28/2004. In Visual Basic.Layers(0).Text = 100 Text2. by setting the SymbolType property. If you want. The method of calculation can be set using the ValueCalculation property. It does this by drawing different symbols for each category of Z values. ClassBreaksRenderer Object Properties Break Symbol Tag BreakCount SymbolType ValueCalculation Methods RampColors ProgrammersReference. A ZRenderer is a creatable object in MapObjects.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. Recordset Object. Symbol Object.Caption = “Z Value” Text1. The Z values of a feature are used to calculate the category it falls into. You can assign a specific Symbol to each category. so if you set BreakCount to be 2.ZRenderer See Also Field Object. 10:00 AM . The ZRenderer assigns a symbol to a category using the indexed Symbol property. There is always one more category than the number of breaks.Extent = oRect Label1. you can use the RampColors method to assign a start color to the first class and an end color to the last class. there will be three categories. The ClassBreaksRenderer will interpolate colors for intervening classes. 578 MapObjects Programmer’s Reference Map1. This property takes one of three ZValueCalcConstants. You can set the number of breaks between categories with the BreakCount property. You can specify the type of Symbol to associate with the ClassBreaksRenderer. The read- write ValueCalculation property returns or sets this value. 10:00 AM .pmd 579 10/28/2004. MapObjects Programmer’s Reference 579 ZValueCalc Constants MapObjects defines the following type constants for use with ZRenderer objects. Constant Value Description moMaxZValue 0 Use each shape’s largest Z Value for rendering moMinZValue 1 Use each shape’s smallest Z Value for rendering moMeanZvalue 2 Use the average Z Value of each shape for rendering See Also ZRenderer Object ProgrammersReference.


Comments

Copyright © 2024 UPDOCS Inc.