Selasa, 08 Mei 2012

Menampilkan Peta MapInfo di Visual Basic 6.0

Format peta GIS ada berbagai macam antara lain SHP (ArcView) dan MapInfo. Untuk SHP (ArcView) bisa ditampilkan ke Visual Basic 6.0, Delphi maupun VB.NET menggunakan MapObject, sedangkan untuk MapInfo bisa ditampilkan di VB 6.0 menggunakan MapBasic. Dengan cara tambahkan file MapBasic.bas. Kemudian peta MapInfo dapat ditampilkan dengan kode program berikut :

Option Explicit
'Dim konexi As New ADODB.Connection
Dim EditPeta As Boolean    'Cek fungsi ini
Dim pilihCari As String    'Cek fungsi ini
Public mapinfo As Object
Public mapid As Long
Public legendid As Long
Public CariAppDir As String
'Dim rspengembang As New ADODB.Recordset
'Dim rsperumahan As New ADODB.Recordset
'Dim rstipe As New ADODB.Recordset


Private Sub Form_Load()

'DATA PETA
'Set konexi = New ADODB.Connection
'konexi.Provider = "microsoft.jet.oledb.4.0"
'konexi.CursorLocation = adUseClient
'konexi.Open "skripsi.mdb"
'E:\Dokumenku\Folderskripsi\peta Skripsi\
'*** Eksekusi awal program
Dim Direc, Embex As String
Dim szStr  As String
Dim tdkcreateobj  As Integer
Dim nRows As Integer
Dim i As Integer
Dim KirimTxt As String

'Start mapinfo,...

tdkcreateobj = False
'On Error GoTo cant_createApplicationObject
Set mapinfo = CreateObject("MapInfo.Application")
On Error GoTo 0

If tdkcreateobj Then
    'On Error GoTo cant_getApplicationObject
    Set mapinfo = CreateObject("MapInfo.Application")
On Error GoTo 0
End If

'*** Mencari directori kerja dari program...
CariAppDir = LCase(App.Path)
If (Right$(App.Path, 1) <> "\") Then
    CariAppDir = CariAppDir + "\"
End If


'** indikasi bahwa legendwindow belum dibuat.
legendid = 0

'** Inisialisasi Aplikasi program...
mapinfo.Do "Set Application Window " & Menut.mapview.hWnd

'** matikan help subsystem,..
mapinfo.Do "Set Window Help Off"

'** info tool dalam form.
mapinfo.Do "Set Window Info Parent " & Menut.hWnd

'** supaya info tidak bisa diubah
mapinfo.Do "Set Window Info default access"

'** ruler tool dalam form.
mapinfo.Do "Set Window Ruler Parent " & Menut.hWnd
mapinfo.Do "Set Window Message Parent " & Menut.hWnd
mapinfo.Do "Set Window Legend Parent " & Menut.hWnd

  If mapinfo.eval("SystemInfo(4)") = "T" Then
     mapinfo.Do "Create ButtonPad ID 3 As ToolButton Calling DDE ""skripsiku"",""menut"" Cursor 128 DrawMode 34 ID 101"
  
  Else
     mapinfo.Do "Alter ButtonPad ID 3 Add ToolButton Calling DDE ""skripsiku"",""menut"" Cursor 128 DrawMode 34 ID 101"
  
  End If
  
  '*** Proses Pembuatan Map Window
  mapinfo.Do "Set Next Document Parent " & mapview.hWnd & "Style 1"
  szStr = "Run Application """ + CariAppDir + "skripsiku1.wor" + """"
  mapinfo.Do szStr
  mapid = Val(mapinfo.eval("WindowID(0)"))
  

 '** grabber tool
  mapinfo.runmenucommand 1702
  
End Sub