home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Add_a_Goog2113475212008.psc / google_map / frmMap.frm < prev    next >
Text File  |  2008-05-21  |  8KB  |  287 lines

  1. VERSION 5.00
  2. Object = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0"; "ieframe.dll"
  3. Begin VB.Form frmMap 
  4.    Caption         =   "Google Map"
  5.    ClientHeight    =   7350
  6.    ClientLeft      =   165
  7.    ClientTop       =   555
  8.    ClientWidth     =   8505
  9.    Icon            =   "frmMap.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   7350
  12.    ScaleWidth      =   8505
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.CommandButton Command2 
  15.       Caption         =   "Map Lat/Long"
  16.       Height          =   375
  17.       Left            =   7200
  18.       TabIndex        =   14
  19.       Top             =   1200
  20.       Width           =   1215
  21.    End
  22.    Begin VB.CommandButton Command1 
  23.       Caption         =   "Map Address"
  24.       Height          =   375
  25.       Left            =   5880
  26.       TabIndex        =   13
  27.       Top             =   1200
  28.       Width           =   1215
  29.    End
  30.    Begin VB.TextBox txtLong 
  31.       Height          =   285
  32.       Left            =   6000
  33.       TabIndex        =   12
  34.       Top             =   720
  35.       Width           =   2415
  36.    End
  37.    Begin VB.TextBox txtLat 
  38.       Height          =   285
  39.       Left            =   6000
  40.       TabIndex        =   11
  41.       Top             =   120
  42.       Width           =   2415
  43.    End
  44.    Begin VB.TextBox txtZipCode 
  45.       Height          =   285
  46.       Left            =   2760
  47.       TabIndex        =   10
  48.       Top             =   1080
  49.       Width           =   1215
  50.    End
  51.    Begin VB.TextBox txtState 
  52.       Height          =   285
  53.       Left            =   960
  54.       TabIndex        =   9
  55.       Top             =   1080
  56.       Width           =   735
  57.    End
  58.    Begin VB.TextBox txtCity 
  59.       Height          =   285
  60.       Left            =   960
  61.       TabIndex        =   8
  62.       Top             =   600
  63.       Width           =   4215
  64.    End
  65.    Begin VB.TextBox txtStreet 
  66.       Height          =   285
  67.       Left            =   960
  68.       TabIndex        =   7
  69.       Top             =   120
  70.       Width           =   4215
  71.    End
  72.    Begin SHDocVwCtl.WebBrowser WebBrowser1 
  73.       Height          =   5655
  74.       Left            =   0
  75.       TabIndex        =   0
  76.       Top             =   1680
  77.       Width           =   8535
  78.       ExtentX         =   15055
  79.       ExtentY         =   9975
  80.       ViewMode        =   0
  81.       Offline         =   0
  82.       Silent          =   0
  83.       RegisterAsBrowser=   0
  84.       RegisterAsDropTarget=   1
  85.       AutoArrange     =   0   'False
  86.       NoClientEdge    =   0   'False
  87.       AlignLeft       =   0   'False
  88.       NoWebView       =   0   'False
  89.       HideFileNames   =   0   'False
  90.       SingleClick     =   0   'False
  91.       SingleSelection =   0   'False
  92.       NoFolders       =   0   'False
  93.       Transparent     =   0   'False
  94.       ViewID          =   "{0057D0E0-3573-11CF-AE69-08002B2E1262}"
  95.       Location        =   ""
  96.    End
  97.    Begin VB.Label Label6 
  98.       Caption         =   "Long"
  99.       Height          =   255
  100.       Left            =   5520
  101.       TabIndex        =   6
  102.       Top             =   720
  103.       Width           =   1215
  104.    End
  105.    Begin VB.Label Label5 
  106.       Caption         =   "Lat"
  107.       Height          =   255
  108.       Left            =   5640
  109.       TabIndex        =   5
  110.       Top             =   120
  111.       Width           =   1215
  112.    End
  113.    Begin VB.Label Label4 
  114.       Caption         =   "Zip Code"
  115.       Height          =   255
  116.       Left            =   1920
  117.       TabIndex        =   4
  118.       Top             =   1080
  119.       Width           =   1215
  120.    End
  121.    Begin VB.Label Label3 
  122.       Caption         =   "State"
  123.       Height          =   255
  124.       Left            =   120
  125.       TabIndex        =   3
  126.       Top             =   1080
  127.       Width           =   1215
  128.    End
  129.    Begin VB.Label Label2 
  130.       Caption         =   "City"
  131.       Height          =   255
  132.       Left            =   120
  133.       TabIndex        =   2
  134.       Top             =   600
  135.       Width           =   1215
  136.    End
  137.    Begin VB.Label Label1 
  138.       Caption         =   "Street"
  139.       Height          =   255
  140.       Left            =   120
  141.       TabIndex        =   1
  142.       Top             =   120
  143.       Width           =   1215
  144.    End
  145. End
  146. Attribute VB_Name = "frmMap"
  147. Attribute VB_GlobalNameSpace = False
  148. Attribute VB_Creatable = False
  149. Attribute VB_PredeclaredId = True
  150. Attribute VB_Exposed = False
  151. Private Type ControlPositionType
  152.     Left As Single
  153.     Top As Single
  154.     Width As Single
  155.     Height As Single
  156.     FontSize As Single
  157. End Type
  158.  
  159. Private m_ControlPositions() As ControlPositionType
  160. Private m_FormWid As Single
  161. Private m_FormHgt As Single
  162.  
  163. Private Sub SaveSizes()
  164. Dim i As Integer
  165. Dim ctl As Control
  166. ' Save the controls' positions and sizes.
  167. ReDim m_ControlPositions(1 To Controls.Count)
  168. i = 1
  169. For Each ctl In Controls
  170.     With m_ControlPositions(i)
  171.         If TypeOf ctl Is Line Then
  172.             .Left = ctl.X1
  173.             .Top = ctl.Y1
  174.             .Width = ctl.X2 - ctl.X1
  175.             .Height = ctl.Y2 - ctl.Y1
  176.         Else
  177.             .Left = ctl.Left
  178.             .Top = ctl.Top
  179.             .Width = ctl.Width
  180.             .Height = ctl.Height
  181.             On Error Resume Next
  182.             .FontSize = ctl.Font.Size
  183.             On Error GoTo 0
  184.         End If
  185.     End With
  186.     i = i + 1
  187. Next ctl
  188. ' Save the form's size.
  189. m_FormWid = ScaleWidth
  190. m_FormHgt = ScaleHeight
  191. End Sub
  192.  
  193. Private Sub Command1_Click()
  194. Dim street As String
  195. Dim city As String
  196. Dim state As String
  197. Dim zip As String
  198. Dim queryAddress As String
  199. queryAddress = "http://maps.google.com/maps?q="
  200. ' build street part of query string
  201. If txtStreet.Text <> "" Then
  202.     street = txtStreet.Text
  203.     queryAddress = queryAddress & street + "," & "+"
  204. End If
  205. ' build city part of query string
  206. If txtCity.Text <> "" Then
  207.     city = txtCity.Text
  208.     queryAddress = queryAddress & city + "," & "+"
  209. End If
  210. ' build state part of query string
  211. If txtState.Text <> "" Then
  212.     state = txtState.Text
  213.     queryAddress = queryAddress & state + "," & "+"
  214. End If
  215. ' build zip code part of query string
  216. If txtZipCode.Text <> "" Then
  217.     zip = txtZipCode.Text
  218.     queryAddress = queryAddress & zip
  219. End If
  220. ' pass the url with the query string to web browser control
  221. WebBrowser1.Navigate queryAddress
  222. End Sub
  223.  
  224. Private Sub Command2_Click()
  225. If txtLat.Text = "" Or txtLong.Text = "" Then
  226.     MsgBox "Supply a latitude and longitude value.", "Missing Data"
  227. End If
  228. Dim lat As String
  229. Dim lon As String
  230. Dim queryAddress As String
  231. queryAddress = "http://maps.google.com/maps?q="
  232. If txtLat.Text <> "" Then
  233.     lat = txtLat.Text
  234.     queryAddress = queryAddress & lat + "%2C"
  235. End If
  236. ' build longitude part of query string
  237. If txtLong.Text <> "" Then
  238.     lon = txtLong.Text
  239.     queryAddress = queryAddress & lon
  240. End If
  241. WebBrowser1.Navigate queryAddress
  242. End Sub
  243.  
  244. Private Sub Form_Load()
  245. SaveSizes
  246. End Sub
  247.  
  248. Private Sub Form_Resize()
  249. ResizeControls
  250. End Sub
  251.  
  252. Private Sub ResizeControls()
  253. Dim i As Integer
  254. Dim ctl As Control
  255. Dim x_scale As Single
  256. Dim y_scale As Single
  257. ' Don't bother if we are minimized.
  258. If WindowState = vbMinimized Then Exit Sub
  259. ' Get the form's current scale factors.
  260. x_scale = ScaleWidth / m_FormWid
  261. y_scale = ScaleHeight / m_FormHgt
  262. ' Position the controls.
  263. i = 1
  264. For Each ctl In Controls
  265.     With m_ControlPositions(i)
  266.         If TypeOf ctl Is Line Then
  267.             ctl.X1 = x_scale * .Left
  268.             ctl.Y1 = y_scale * .Top
  269.             ctl.X2 = ctl.X1 + x_scale * .Width
  270.             ctl.Y2 = ctl.Y1 + y_scale * .Height
  271.         Else
  272.             ctl.Left = x_scale * .Left
  273.             ctl.Top = y_scale * .Top
  274.             ctl.Width = x_scale * .Width
  275.             If Not (TypeOf ctl Is ComboBox) Then
  276.                 ' Cannot change height of ComboBoxes.
  277.                 ctl.Height = y_scale * .Height
  278.             End If
  279.             On Error Resume Next
  280.             ctl.Font.Size = y_scale * .FontSize
  281.             On Error GoTo 0
  282.         End If
  283.     End With
  284.     i = i + 1
  285. Next ctl
  286. End Sub
  287.