http://www.youtube.com/watch?v=WxizVm66TII
You’ll notice a couple of problems with it. Firstly, my screen saver kicked in and it grabbed a frame of that (oops).
The other problems is that in places, the map has not fully loaded, so you get the odd grey square. I’d like to be able to detect that the whole thing has loaded before the screen grab is taken.
The scrips works like this:
Calculates the lat & long to display
Loads an HTML file (stored locally) which is populated with necessary data
Saves in the temporary folder using specialFolderPath("temporary")
Opens this as a URL and then takes a screen shot
The HTML file is this:
Code: Select all
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<iframe width="__width__" height="__height__" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.google.com/maps?t=h&ie=UTF8&ll=__lat__,__long__&spn=0.001173,0.002607&z=__zoom__&output=embed"></iframe>
</body>
</html>
I am using some delaying code that I believe checks that the page has loaded, but I’m not so sure it’s actually working too well.
Code: Select all
revBrowserSet gBrowserId, "rect" , rect of graphic "Browser Rect Graphic"
revBrowserSet gBrowserId , "url" , displayHTML & "?"
revBrowserSet gBrowserId , "scrollbars" , "false"
put rect of graphic "Browser Rect Graphic" into imageSize
-- Check to see if the browser has loaded
put "" into tIAmBusy
put revBrowserGet (gBrowserId, "busy") into tIAmBusy
repeat until not tIAmBusy
put revBrowserGet (gBrowserId, "busy") into tIAmBusy
if not tIAmBusy then exit repeat
wait 1200 milliseconds
end repeat
wait 2400 milliseconds with messages
--carry on to do screen shot things…
The original code which I found online had a much smaller delay - but I decided to increase it and add a extra 2400 milliseconds for good measure, just in case. Now, I am aware that I’m loading a Google map, and that this may cause unexpected behaviour. However, I’d be interested to know if there is a more robust way of detecting that an HTML page has finished loading before taking the screen shot.
Other than this little niggle, it’s all coming together rather nicely.