embedded image from Web

bbulla

I'd rather be golfing
Local time
Today, 17:29
Joined
Feb 11, 2005
Messages
101
Hi,

I'm trying to create a report that would use a static map image from Google Maps on each page of the report. I use some GPS coordinates from the database to help generate a URL to show the image from Google in a Web Browser ActiveX control.

Is there a way I can use this ActiveX control on a Report? It works fine in a form.

Or any other solutions to this?

Thanks,
 
OK, I figured this out. I can download the PNG file from GoogleMaps, save it to a file, and then show the downloaded image in an Image object on the form. Here is the code for anyone interested.

Code:
Option Compare Database

'This is an API we can use to download the Google Maps image to a file
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

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim strURL As String
    
    'Create the URL based on the X,Y coordinate
    strURL = "http://maps.google.com/maps/api/staticmap?center=" & Y & "," & X & "&markers=color:green|label:P|" & Y & "," & X & "&zoom=17&maptype=hybrid&size=350x375&sensor=false"
    
    'Donload the PNG file from Google to the MapImages folder and name it Page#
    Dim done
    done = URLDownloadToFile(0, strURL, "C:\Inspection_Data\Road Patrol\MapImages\" & Me.Page & ".png", 0, 0)
    
    'Set the mapImage to the download image
    mapImage.Picture = "C:\Inspection_Data\Road Patrol\MapImages\" & Me.Page & ".png"
End Sub

Private Sub Report_Close()
    'Delete all the images from the folder
    Kill "C:\Inspection_Data\Road Patrol\MapImages\*.png"
    
End Sub
 

Users who are viewing this thread

Back
Top Bottom