intro to mapobjects
play

Intro to MapObjects What is (are) MapObjects? MapObjects-Windows - PDF document

Intro to MapObjects What is (are) MapObjects? MapObjects-Windows Edition ActiveX control with ca. 50 programmable objects Suitable for various developm ent environm ents: Visual Basic Visual C+ + Visual FoxPro .


  1. Intro to MapObjects What is (are) MapObjects? � MapObjects-Windows Edition ActiveX control with ca. 50 programmable objects � Suitable for various developm ent environm ents: � Visual Basic � � Visual C+ + � Visual FoxPro . . . � � Current VI SC version (2.1) predates .NET February 7, 2003 Jan 2003 release of version 2.2 � � MapObjects LT Mark McDonald Basic functionality � MapObjects- Java Standard Edition � Recently released (early 2002) � Com pletely different im plem entation (Java Beans) � For m ulti-platform use � Differences with other ESRI Products Intro to Map Objects � ArcGI S Desktop “ Geographic data creation, m anagem ent, This presentation assum es: integration, analysis ” Common interface � Basic knowledge of ESRI products � Two products with common interface � � ArcMap ArcView 8.x ArcView, or ArcCatalog � � ArcToolbox � ArcI nfo – m ore advanced and ArcI nfo � Developer Tools � com prehensive ArcObjects � Basic program m ing skills � � “ The technology fram ework of ArcGI S ” � Custom izes, extends: ArcI nfo, ArcEditor, ArcView 8.x � MS Visual Basic 6, or � Requires one of above � other program m ing language � MapObjects � Adapted for “ foreign ” (non- ESRI ) com ponents � Suitable for m ore general use Objectives: Know w hat’s possible � Reference on where to start � 1

  2. Basics � Creating a Map Add MapObjects Control to VB Toolbox � Add Map to a form � Add data layer(s) to Map � Project1.vbp 2

  3. 3

  4. MapObjects Basics � Basics Add MapObjects Control to VB Toolbox � Add Map to a form � Add data layer(s) to Map � � Map manipulation Add VB controls � Add three lines of code � Results in ability to: � Zoom I n � Pan � Draw VB controls on blank form Zoom Out to original view � Object Browser view Project2.vbp 4

  5. I NSERT OBJECT BROWSER VI EW HERE Private Sub Com m and1_Click() 'Extent: Returns or sets the spatial extent of an object Map Objects by Type 'FullExtent: Returns or sets a special Rectangle object ‘ (Rectangle represents the bounding box of a Map) Map1.Extent = Map1.FullExtent � Dat a Access End Sub Obtain geographic data from database � Projection � Private Sub Map1_MouseDown(Button As I nteger, Shift As I nteger, _ � Transform 3- D data for display X As Single, Y As Single) � Map Display Display data on a 2- D map � I f Option1.Value = True Then ' Zoom In � Address Matching 'Function TrackRectangle(): Match address(es) with location(s) on m ap � ' Rubber- bands a rectangle on the Map and returns a Rectangle object Geom etric & Utility � Map1.Extent = Map1.TrackRectangle Create and m anipulate points, lines, polygons, ... � Manipulate text strings � ElseIf Option2.Value = True Then ' Pan 'Sub Pan(): Tracks the mouse while panning the Map � MapObjects Helper Com ponents Map1.Pan Add Legend, Scalebar � End If Com m ents: End Sub − objects grouped by function − not an object hierarchy 5

  6. Map Objects Map Objects � Data Access � DataConnection � Dat a Access � GeoDataset (GeoDatasets Collection) DataConnection � � Recordset � Represents connection to geographic data source � Other objects � Analogous to VB Connection object � TableDesc GeoDataset � � Represents a description of the Fields collection of a Recordset. Represents layer of geographic data on a m ap � � Return or set properties for Field in a Recordset, where � Associated with a MapLayer object appropriate, i.e. within the lim its of the GeoDataset from which Can be in m ost vector data form ats the Recordset is derived � Recordset � FieldLength, FieldNam e, FieldPrecision, FieldScale, FieldType � among choices � Represents records from a GeoDataset, or … . � Table � … .resulting from a query � read- only object corresponding to a table in a relational St at ist ics � database � Result of calculation on a num eric Field of a Recordset using � Used for standard relational DB ’s, not geodatasets Recordset object's CalculateStatistics m ethod � Field (Fields Collection) Other objects- . . . � � represents a colum n of data within a Recordset with a com m on � Projection data type and a com m on set of properties. Map Display � � Projection Address Matching � � Map Display � Geom etric & Utility � Address Matching � MapObjects Helper Com ponents � Geometric & Utility � MapObjects Helper Com ponents Searching GeoDatasets Can be done by searching for: � Text in an attribute Proxim ity to a spatial feature � Project3.vbp 6

  7. Private Sub Com m and2_Click() ' build a search expression Dim exp As St ring ' "NAME" is field nam e in shapefile city_bnd.shp Searching GeoDatasets exp = "NAME = '" & UCase(Text1.Text) & "'" ' perform t he search Can be done based by searching for: Dim recs As MapObjects2.Recordset Set recs = Map1.Layers("city_bnd").SearchExpression(exp) � Text in an attribute Proxim ity to a spatial feature � ' show the results, if any I f Not recs.EOF Then Dim sh p As Obj ect Set shp = recs. Fields( "Shape “ ). Value Dim r ect As MapObj ects2.Rectangle Set r ect = shp.Extent ' r ect equals city’s ext ent rect.ScaleRectangle 1 0 ' Scale up r ect by factor of 10 Set Map1.Extent = rect ' Make t he m ap’s extent = rect Map1.Refresh ' redraw the m ap Map1.FlashShape shp, 10 ' flash it so we see it End I f End Sub Project3.vbp 7

  8. Dim gSel As MapObjects2.Recordset Dim gSel As MapObjects2.Recordset . . . . . . Private Sub Map1_MouseDown(Button As I nteger, …… Private Sub Map1_MouseDown(Button As I nteger, …… ………. ………. ElseIf Option3.Value = True Then ElseIf Option3.Value = True Then ' spatial query ' spatial query Dim p As Point Dim p As Point Set p = Map1.ToMapPoint(x, y) ‘Converts com puter’s (x,y) to m ap’s (x,y) Set p = Map1.ToMapPoint(x, y) ' search for a highway within the tolerance ' search for a highway within the tolerance Dim recs As MapObjects2.Recordset Dim recs As MapObjects2.Recordset Set recs = Map1.Layers("interstates"). SearchByDistance(p, Map1. _ Set recs = Map1.Layers("interstates"). SearchByDistance(p, Map1. _ ToMapDistance(200), "") ToMapDistance(100), "") 'SearchByDistance() searches "interstates.shp" for anything near Point p ' If nothing is found 'ToMapDistance() converts computer distance units to map distance units If recs.EOF Then Set gSel = Nothing ' If nothing is found ' Else search for townships intersecting If recs.EOF Then Else Set gSel = Nothing Set gSel = Map1.Layers("township_bnd") _ ' Else search for townships intersecting .SearchShape(recs.Fields ("Shape").Value, m oAreaI ntersect, "") Else End If Set gSel = Map1.Layers("township_bnd") _ .SearchShape( recs.Fields ("Shape“ ).Value, m oAreaI ntersect, "") Map1.Refresh ' trigger a redraw of the map End If End If Map1.Refresh ' trigger a redraw of the map End Sub End If Private Sub Map1_AfterLayerDraw(ByVal index As _ Integer, ByVal canceled As Boolean, ByVal hDC _ As stdole.OLE_HANDLE) Connecting to a GeoDatabase I f Map1.Layers(index).Nam e = "township_bnd" Then I f Not gSel I s Nothing Then � Data not known during developm ent? Dim sym As New MapObjects2.Symbol Connect to data as needed! � sym .Color = m oYellow Map1.DrawShape gSel, sym Allows flexibility � End If End If End Sub DescribeShapefile.Vbp 8

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend