GettingStartedwithMOinVB.docx
- 文档编号:5362858
- 上传时间:2022-12-15
- 格式:DOCX
- 页数:34
- 大小:360.68KB
GettingStartedwithMOinVB.docx
《GettingStartedwithMOinVB.docx》由会员分享,可在线阅读,更多相关《GettingStartedwithMOinVB.docx(34页珍藏版)》请在冰豆网上搜索。
GettingStartedwithMOinVB
GettingStartedwithMapObjects
Copyright©2002EnvironmentalSystemsResearchInstitute,Inc.
AllRightsReserved.
PrintedintheUnitedStatesofAmerica.
TheinformationcontainedinthisdocumentistheexclusivepropertyofEnvironmentalSystemsResearchInstitute,Inc.ThisworkisprotectedunderUnitedStatescopyrightlawandthecopyrightlawsofthegivencountriesoforiginandapplicableinternationallaws,treaties,and/orconventions.Nopartofthisworkmaybereproducedortransmittedinanyformorbyanymeans,electronicormechanical,includingphotocopyingorrecording,orbyanyinformationstorageorretrievalsystem,exceptasexpresslypermittedinwritingbyEnvironmentalSystemsResearchInstitute,Inc.AllrequestsshouldbesenttoAttention:
ContractsManager,EnvironmentalSystemsResearchInstitute,Inc.,380NewYorkStreet,Redlands,CA92373-8100USA.
Theinformationcontainedinthisdocumentissubjecttochangewithoutnotice.
SAMPLEDATALICENSEANDDISCLAIMER
ThesampledataincludedinthispackageistheexclusivepropertyandcopyrightofEnvironmentalSystemsResearchInstitute,Inc.andtherespectivedatapublishers.ThissampledataisprotectedunderUnitedStatescopyrightlawandotherinternationalcopyrighttreatiesandconventions.ThesampledataisprovidedunderlicensefromeachoftherespectivedatapublishersfortheLicensee’sowninternaluse.Licenseeshallnotsell,rent,lease,sublicense,lend,assign,time-share,ortransfer,inwholeorinpart,orprovideunlicensedthirdpartiesaccesstothesampledataorportionsofthedata,documentationormetadata,anyupdates,orLicensee’srightsunderthisAgreement.Thesampledatahereinhavebeenobtainedfromsourcesbelievedtobereliable,butitsaccuracyandcompleteness,andtheopinionsbasedthereon,arenotguaranteed.Everyefforthasbeenmadetoprovideaccuratesampledatainthispackage.ESRIisnotinvitingrelianceonthissampledata,andyoushouldalwaysverifyactualmapdataandinformation.Thesampledatacontainedinthispackageissubjecttochangewithoutnotice.THESAMPLEDATAISPROVIDED“AS-IS,”WITHOUTWARRANTYOFANYKIND,EITHEREXPRESSORIMPLIED,INCLUDINGBUTNOTLIMITEDTO,THEIMPLIEDWARRANTIESOFMERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSE.ESRIshallnotbeliableforindirect,special,incidental,orconsequentialdamagesrelatedtoLicensee’suseofthesampledata,evenifESRIisadvisedofthepossibilityofsuchdamage.
RESTRICTEDRIGHTSLEGEND
Use,duplication,anddisclosurebytheU.S.GovernmentaresubjecttorestrictionsassetforthinFAR§164§52.227-14AlternateIII(g)(3)(JUN1987),FAR§164§52.227-19(JUN1987),DFARS§164§252.227-7015(JUN1995)[TechnicalData],and/orDFARS§164§252.227-7202(JUN1995)[ComputerSoftware],asapplicable.Contractor/ManufacturerisEnvironmentalSystemsResearchInstitute,Inc.,380NewYorkStreet,Redlands,CA92373-8100USA.
ESRIisaregisteredtrademark,andMapObjects,SpatialDatabaseEngine,SDE,theESRIcorporatelogo,theMapObjectslogo,andGISbyESRIaretrademarksofEnvironmentalSystemsResearchInstitute,Inc.
Thenamesofothercompaniesandproductshereinaretrademarksorregisteredtrademarksoftheirrespectivetrademarkowners.
ContentsIntroduction5
LoadingMapObjects6
Gettinghelp6
Addingamap7
Addingpanandzoomcontrols9
Addingatoolbar11
Creatingafindtool14
Handlingresize16
Displayingmaplayersbasedonscale17
Addingaspatialquerytool18
Statisticalmapping20
Eventtracking21
WorkingwithDataConnectionobjects24
WorkingwithImageLayerobjects25
Congratulations27
GettingStarted
INTHISBOOK
∙LoadingMapObjectsintoVisualBasic
∙Addingsimpledisplaytools
∙Creatingbasicspatialquerytools
∙Displayingmaplayers
∙Trackingevents
∙WorkingwiththeDataConnectionobject
∙Addinganimagelayer
InthisintroductorydocumentyouwilluseMapObjects®andMicrosoft®VisualBasic®tobuildanapplicationthatusesmaps.Alongthewayyouwilllearnhowto:
∙Displayamapwithmultiplelayers.
∙Controlpanningandzooming.
∙Createatoolbarcontrol.
∙Displaymaplayersbasedonscale.
∙Performspatialandlogicalqueries.
∙Drawsimplegraphicsonthemap.
∙Displayfeatureswiththematicrenderers.
∙Dynamicallydisplayreal-timedatawithaneventtrackinglayer.
∙Programmaticallyadddatatoamap.
NoteIfyouacceptedthedefaultswheninstallingMapObjects,thegeographicdatathatthistutorialreferstocanbefoundinC:
\ProgramFiles\ESRI\MapObjects2\Samples\Data\Usa.ThebitmapsyoucanuseareintheSamples\Bitmapsfolder.
LoadingMapObjects
StartVisualBasicandselectNewprojectfromthedialogbox.Nowright-clickonthetoolbox(theleft-hand-sidetoolbar)andchooseAdditionalControls.
Tip:
youcanalsoaddcontrolsbyselectingComponentsfromtheProjectmenu,orbypressingCTRL+T.
Find‘ESRIMapObjects2.2’inthelistofavailablecontrols,andchecktheboxbesideit.ClickOKtoclosethedialog.NoticethatanewtoolappearsintheVisualBasicToolbox.ThisnewtoolistheMapObjectsversion2.2Mapcontrol.
MapObjects
MapControl
Gettinghelp
TheMapcontrolisoneofover45objectsthatmakeupMapObjects.Tofindoutaboutthevariousobjects,clicktheObjectBrowserbuttonintheVisualBasictoolbar.
Pulldownthe“Libraries”combobox,andchooseMapObjects2.
MapObjectsobjectsandconstantsarelistedintheClassesbottomleft-handlist.
Toseethepropertiesandmethodsforanobject,clickontheobjectinthelist.ThepropertiesandmethodsofthatobjectarelistedintheMemberslisttotheright.
Toseethesignatureofamethod,clickonthemethodintheright-handlist.ThedetailswillappearinthespaceatthebottomoftheObjectBrowser.
Tip:
thesimplestwaytogethelpistoselectthemapcontroland
pressF1.
Gettinghelp
TheMapObjectsonlinehelpsystemisintegratedwiththeVisualBasicObjectBrowser.
1.ClickSymbolintheClasses/Moduleslist.
2.ClickRotationintheMethods/Propertieslist.
3.Clickthehelp(questionmark)button.
Thehelpsystemprovideshelpforeveryobject,property,method,eventandconstantinMapObjects.InadditiontotheObjectBrowser,thehelpsystemisaccessibleformtheVisualBasicCodewindow.Simplytypeinthenameofanobject,property,method,eventorconstant,andpressF1.
Addingamap
TheMapcontrolistheobjectyouusetodisplaymaps.
AddtheMapcontroltotheform
1.Double-clicktheMapcontrolbuttonintheToolboxtoaddanewmaptotheform.
2.Resizethemaptofilltheform.
Selectthedatatodisplayonthemap
YoucanspecifythedatathatisdisplayedinthemapbysettingpropertiesintheMapcontrol’spropertysheet.
1.Right-clickthemouseonthemaptodisplaythecontextmenu.
2.ChoosePropertiestodisplaythepropertysheet.
3.ClicktheAddbuttonandlocatethefoldercontainingtheStatessampledata.IfyouselectedthedefaultswhenyouinstalledMapObjects,thiswillbeinc:
\ProgramFiles\ESRI\MapObjects2\Samples\Data.
4.ClicktheStates.shpfileandthenclickOpen.
5.AddthefileUSHigh.shpinthesamemanner.
Setpropertiesforthelayers
1.ClicktheStateslayerintheLayerslistandthenclickProperties.
2.ClicktheColorbuttontoselectacolorfortheStateslayer.
3.ClickOKtoclosethedialog.
4.SelectacolorfortheUSHighlayerinthesamemanner.
5.ClickOKtoclosethepropertysheet.
Savetheproject
1.ClicktheFilemenuandthenclickSaveProject.
2.Browsetoasuitablefolder,thenintheFileNameboxtypeStarterMap.frm.
3.ClickSave.
4.InthesecondSavedialog,typeStarterMap.vbpintheFileNamebox.
5.ClickSave.
Run
Testyourapplication
1.ClicktheRunbuttonintheVisualBasictoolbar.
Stop
2.Tostoprunningyourapplicationandreturntodesignmode,clicktheStopbuttonintheVisualBasictoolbar.
Addingpanandzoomcontrols
Atthispointyourapplicationcandisplaythemapatitsfullextent.Inthissectionyouwilladdsomesimplepanandzoomcontrolsthatyourapplicationwillactivateinresponsetomouseclicksinsidethemap.YouwillwritesomecodethattheapplicationwillexecuteinresponsetotheMouseDowneventonthemap.
RespondtotheMouseDownevent
1.Double-clickthemaptodisplaytheVisualBasicCodewindow.
2.AddcodetoMap1’sMouseDownprocedure.
PrivateSubMap1_MouseDown(ButtonAsInteger,_ShiftAsInteger,xAsSingle,yAsSingle)
SetMap1.Extent=Map1.TrackRectangle
EndSub
Testyourchange
1.ClicktheRunbuttonintheVisualBasictoolbar.
2.Clickthemapwiththeleftmousebuttonanddragoutarectangle.
3.Releasethemousebuttonandnoticethatthemapisredrawnatthelocationyouspecified.
TrackRectangleisamethodthatappliestoamap.Ittracksthemovementofthemousewhiletheuserpressesthemousebutton,rubber-bandingarectangleatthesametime.Whentheuserreleasesthemousebutton,theTrackRectanglemethodreturnsaRectangleobjectthattheapplicationassignsintotheExtentpropertyofthemap,causingthemaptoberedrawnwithanewmapextent.
4.ClickthestopbuttoninVisualBasictoreturntodesignmode.
Addpanning
1.Double-clickthemaptodisplaytheVisualBasicCodewindowagain.
2.ChangethecodefortheMouseDownevent.
PrivateSubMap1_MouseDown(ButtonAsInteger,_ShiftAsInteger,xAsSingle,yAsSingle)
IfButton=vbLeftButtonThen
SetMap1.Extent=Map1.TrackRectangle
ElseifButton=vbRightButtonthen
Map1.Pan
EndIf
EndSub
IftheButtonparameterisequaltovbLeftButtonwhentheMouseDowneventoccu
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- GettingStartedwithMOinVB
![提示](https://static.bdocx.com/images/bang_tan.gif)