Map in Access

Victory!!!!!!!!!!!!!!!!!!!!!!!

After scouring the web and fiddling with exotic API's and stuff, I found bits and pieces to at least download a Google static map directly to a file. All my attempts to create a picture/image directly failed. But now at least I can get the map, and pick it up from the file. :D

The code ran just fine in Access 2007, and did not require any additional references:

Code:
Option Compare Database
Option Explicit


Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long


Sub download()

        Dim done
    
        Dim URL_base As String
       
        URL_base = "http://maps.google.com/maps/api/staticmap?center=141+Worth+Street,New+York,NY,10013&zoom=18&size=640x640&format=jpg&maptype=hybrid&sensor=false"
    
        done = URLDownloadToFile(0, URL_base, "C:\test.jpg", 0, 0)
    
        If done = 0 Then
               MsgBox "File has been downloaded!"
        Else
               MsgBox "File not found!"
        End If

End Sub

Private Sub Command0_Click()
        download
End Sub
For A2010 there is some good news: the ActiveX WebBrowser object has either been extended or replaced, so one can seemingly save an image from it directly: http://www.databasestation.net/2010/12/14/save-a-google-map-programmatically/
 
Last edited:
Spikepl,
I have maps in my db. I have a map program on my machine that lets me paste bit maps into an ole object.
 
#22 Is that some open source or commercial map thing available to all? Otherwise, how can it help me getting a map into access?
 
Spikepi,
Sorry it took so long to get back to you. I have Street Atlas by Delorme on my machine. It has a print to file feature. I paste it into any image program and save it as a bit map, then link it into the field (OLE Object) that I have for pictures. Now I don't publish the db so if you plan to do that you would have to check with Delorme. I am a evangelist so I try and add a map to each file of supporting church, so that I know how to get there two or three years later.
 

Users who are viewing this thread

Back
Top Bottom