Google Maps
Posted: Tue Jan 20, 2009 2:39 pm
Hi,
I thought, everything will be so easy now
I just want to capture a map from google maps to get an idea where some GPS data has been collected (see screenshots). I paused the project because of my problems with TransformSprite3D, but now it should be the right time for the next try (or not)
...
Because waldschrath gave me the right tip, I should be able to get a map copied into a bitmap.
But there are still more problems than expected:
The results of the different approaches are totally different and i don't know why...
- first approach, nothing of the map will be loaded
- second approach, I'll get an google maps error, that the API is wrong (I don't know why this message appears nor how to hide such pop ups)
- the third approach works, but I don't like to create a temp file
Can anyone tell me, why all these things leads to completely different results? Any idea how to "optimize" on of the first approaches?
Thanks,
Michael
I thought, everything will be so easy now

I just want to capture a map from google maps to get an idea where some GPS data has been collected (see screenshots). I paused the project because of my problems with TransformSprite3D, but now it should be the right time for the next try (or not)

Because waldschrath gave me the right tip, I should be able to get a map copied into a bitmap.
But there are still more problems than expected:
Code: Select all
Procedure SavePicture()
UsePNGImageEncoder()
windowhandle=GadgetID(1)
GetClientRect_(windowhandle, @cr.RECT)
CreateImage(0, cr\right-cr\left, cr\bottom-cr\top, 24)
hdc=StartDrawing(ImageOutput(0))
SendMessage_(windowhandle, #WM_PRINT, hdc, #PRF_CLIENT|#PRF_CHILDREN|#PRF_ERASEBKGND)
StopDrawing()
Debug SaveImage(0, "c:\Screenshot.png",#PB_ImagePlugin_PNG)
EndProcedure
Procedure InitHTMLCode()
Global HTML.s
Repeat
Read.s zeile.s
If zeile="*"
Break
EndIf
HTML+zeile+#CRLF$
ForEver
CreateFile(0,"c:\test.html")
WriteString(0,HTML)
CloseFile(0)
EndProcedure
InitHTMLCode()
If OpenWindow(0,0,0,800,500,"X",#PB_Window_SizeGadget | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget
|#PB_Window_MaximizeGadget | #PB_Window_ScreenCentered);|#PB_Window_Invisible)
; First Approach...
; WebGadget(1, 0, 0, 800, 500,HTML);,#PB_Web_Mozilla )
; Second Approach...
WebGadget(1, 0, 0, 800, 500, "");,#PB_Web_Mozilla )
SetGadgetItemText(1,#PB_Web_HtmlCode,HTML)
; Third Approach...
;WebGadget(1, 0, 0, 800, 500, "file://c|/test.html");,#PB_Web_Mozilla )
saveflag=0
Repeat
Event = WaitWindowEvent(100)
If saveflag=1
Debug "wait..."
If GetGadgetAttribute(1,#PB_Web_Busy)=0
Delay(10)
Debug "Save now!"
saveflag=2
Repeat
WindowEvent()
Until WaitWindowEvent(0)=0
SavePicture()
End
EndIf
EndIf
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Select EventType()
Case #PB_Event_DataReceived
;Debug "Data"
Case #PB_EventType_DownloadEnd
If saveflag=0
saveflag=1
EndIf
;Debug "Download"
Case #PB_EventType_StatusChange
;Debug "Changes"
EndSelect
EndSelect
EndSelect
Until Event=#PB_Event_CloseWindow
EndIf
DataSection
Data.s "<!DOCTYPE html PUBLIC "+#DQUOTE$+"-//W3C//DTD XHTML 1.0 Strict//EN"+#DQUOTE$
Data.s " "+#DQUOTE$+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"+#DQUOTE$+">"
Data.s "<html xmlns="+#DQUOTE$+"http://www.w3.org/1999/xhtml"+#DQUOTE$+">"
Data.s " <head>"
Data.s " <meta http-equiv="+#DQUOTE$+"content-type"+#DQUOTE$+" content="+#DQUOTE$+"text/html; charset=utf-8"+#DQUOTE$+"/>"
Data.s " <title>Google Maps JavaScript API Example</title>"
Data.s " <script src="+#DQUOTE$+"http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA45pVCvzTSuvt6AO3V1TbBhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxS-e6HzAF46gYlJucyeiXO5uoeS0w"+#DQUOTE$
Data.s " type="+#DQUOTE$+"text/javascript"+#DQUOTE$+"></script>"
Data.s " <script type="+#DQUOTE$+"text/javascript"+#DQUOTE$+">"
Data.s " //<![CDATA["
Data.s " function load() {"
Data.s " if (GBrowserIsCompatible()) {"
Data.s " var map = new GMap2(document.getElementById("+#DQUOTE$+"map"+#DQUOTE$+"));"
Data.s " map.setCenter(new GLatLng(48.000, 16.000), 15);"
Data.s " map.hideControls();"
Data.s " }"
Data.s " }"
Data.s " //]]>"
Data.s " </script>"
Data.s " </head>"
Data.s " <body onload="+#DQUOTE$+"load()"+#DQUOTE$+" onunload="+#DQUOTE$+"GUnload()"+#DQUOTE$+">"
Data.s " <div id="+#DQUOTE$+"map"+#DQUOTE$+" style="+#DQUOTE$+"width:500px;height:300px"+#DQUOTE$+"></div>"
Data.s " </body>"
Data.s "</html>"
Data.s "*"
EndDataSection
- first approach, nothing of the map will be loaded

- second approach, I'll get an google maps error, that the API is wrong (I don't know why this message appears nor how to hide such pop ups)

- the third approach works, but I don't like to create a temp file

Can anyone tell me, why all these things leads to completely different results? Any idea how to "optimize" on of the first approaches?
Thanks,
Michael