Jump to content
TeslaNaut

Google Maps.au3, or a similar UDF

Recommended Posts

TeslaNaut

Big picture first:

I often generate 6-8 row CSV's containing street addresses that have been geocoded using the Google API (using Autoit, in fact). 

For anything other than "ROOFTOP" quality, I must then open the csv in Excel to correct the lat/long and save as I work.

I would like to be able to open a Google Map to show the updated markers as I edit, maybe even indicate the geocoding precision. A link to street view would be nice.

What I tried:

I installed "Google Maps.au3" by  @seangriffin (can we tag people here?)

Last update was Oct 2010. There was a minor bug but I was able to run "Google Maps Example.au3" but got an error from Google:

"You are using a browser that is not supported by the Google Maps JavaScript API. Consider changing your browser"

The link told me they only supported IE10 and IE11. My system has IE11 although my default is Chrome.

 

 

Is this any easy fix? Maybe a version string somewhere? I don't want to dig into this if there is better UDF or completely different approach to my plan.

 

 

Share this post


Link to post
Share on other sites
SlackerAl

I just had a play with this as it seemed fun. I managed to generate the same problem as you and fixed it with a meta line:

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

Local $oIE = _IECreateEmbedded()
GUICreate("Embedded Web control Test", 640, 580, 200, 200, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 10, 40, 620, 520)

GUICtrlSetColor(-1, 0xff0000)

GUISetState(@SW_SHOW) ;Show GUI

_IENavigate($oIE, "about:blank")


Local $sHTML = "<!doctype html>"
$sHTML &= "<HTML>" & @CRLF
$sHTML &= "<HEAD>" & @CRLF
$sHTML &= '<meta http-equiv="X-UA-Compatible" content="IE=edge">' & @CRLF
$sHTML &= "<TITLE>_IE_Example('frameset')</TITLE>" & @CRLF
$sHTML &= "</HEAD>" & @CRLF
$sHTML &= "<BODY>" & @CRLF
$sHTML &= '<IFRAME width="600" height="480" '
$sHTML &= "src='https://www.google.com/maps/embed/v1/place?q=Harrods,Brompton%20Rd,%20UK"
$sHTML &= "&zoom=17"
$sHTML &= "&key=YOURAPIKEYGOESHERE'>" & @CRLF
$sHTML &= "</IFRAME>" & @CRLF
$sHTML &= "</BODY>" & @CRLF
$sHTML &= "</HTML>"

_IEDocWriteHTML($oIE, $sHTML)
_IEAction($oIE, "refresh")

While 1
    Local $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete()

Exit

 

At first I added <!doctype html> to force it to HTML5, but that did not help, however, adding <meta http-equiv="X-UA-Compatible" content="IE=edge"> prevented the unsupported browser problem.

To make the above code work you need to update "YOURAPIKEYGOESHERE" to a valid key. (get a free key from https://developers.google.com/maps/documentation/embed/ )

As to the rest of your problem, I'm afraid writing the map script is up to you :-)

Edited by SlackerAl

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Share this post


Link to post
Share on other sites
Burgs

Howdy,

  I stumbled upon this post today and thought I'd give it a try.  I am also having the same problem with the 'Unsupported browser' (even though I'm using IE 11)...so I thought I'd try to modify this provided script.  When I run it I do not get any errors...which is good...however nothing shows up in the GUI window either...which is bad...hehe

  Anybody have any idea or suggestions to get this to work properly...?  (NOTE:  I DO HAVE my Google API key inserted in my running code, I just do not include it here for security reasons so I put "MY API KEY" instead where the actual key would be).  Thanks in advance for any inputs. 

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

Local $oIE = _IECreateEmbedded()
GUICreate("Embedded Web control Test", 640, 580, 200, 200, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 10, 40, 620, 520)

GUICtrlSetColor(-1, 0xff0000)

GUISetState(@SW_SHOW) ;Show GUI

_IENavigate($oIE, "about:blank")


Local $sHTML = "<!doctype html>"
$sHTML &= "<HTML>" & @CRLF
$sHTML &= "<HEAD>" & @CRLF
$sHTML &= "<meta charset='utf-8'>"
$sHTML &= '<meta http-equiv="X-UA-Compatible" content="IE=edge">' & @CRLF
$sHTML &= "<TITLE>_IE_Example('frameset')</TITLE>" & @CRLF
$sHTML &= "<style>" & @CRLF
$sHTML &= "html, body {" & @CRLF
$sHTML &= "height: 100%;" & @CRLF
$sHTML &= "margin: 0;" & @CRLF
$sHTML &= "padding: 0;" & @CRLF
$sHTML &= "}" & @CRLF
$sHTML &= "#map, #pano {" & @CRLF
$sHTML &= "float: left;" & @CRLF
$sHTML &= "height: 100%;" & @CRLF
$sHTML &= "width: 45%;" & @CRLF
$sHTML &= "}" & @CRLF
$sHTML &= "</style>" & @CRLF
$sHTML &= "</HEAD>" & @CRLF
$sHTML &= "<BODY>" & @CRLF
$sHTML &= '<IFRAME width="600" height="480" '
$sHTML &= "<div id='map'></div>" & @CRLF
$sHTML &= "<div id='pano'></div>" & @CRLF
$sHTML &= "<script>" & @CRLF
$sHTML &= "function initialize() {" & @CRLF
$sHTML &= "var location = {lat: 42.345573, lng: -71.098326};" & @CRLF
$sHTML &= "var map = new google.maps.Map(document.getElementById('map'), {" & @CRLF
$sHTML &= "center: location," & @CRLF
$sHTML &= "zoom: 14" & @CRLF
$sHTML &= "});" & @CRLF
$sHTML &= "var panorama = new google.maps.StreetViewPanorama(" & @CRLF
$sHTML &= "document.getElementById('pano'), {" & @CRLF
$sHTML &= "position: location," & @CRLF
$sHTML &= "pov: {" & @CRLF
$sHTML &= "heading: 34," & @CRLF
$sHTML &= "pitch: 10" & @CRLF
$sHTML &= "}" & @CRLF
$sHTML &= "});" & @CRLF
$sHTML &= "map.setStreetView(panorama);" & @CRLF
$sHTML &= "}" & @CRLF
$sHTML &= "</script>" & @CRLF
$sHTML &= "<script async defer src='https://maps.googleapis.com/maps/api/js?key=MY API KEY&callback=initialize'" & @CRLF
$sHTML &= "type='text/javascript'>" & @CRLF
$sHTML &= "</script>" & @CRLF


$sHTML &= "</IFRAME>" & @CRLF
$sHTML &= "</BODY>" & @CRLF
$sHTML &= "</HTML>" & @CRLF

_IEDocWriteHTML($oIE, $sHTML)
_IEAction($oIE, "refresh")

ConsoleWrite($sHTML)


While 1
    Local $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

GUIDelete()

Exit

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×