Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've actually done this in VBA, I'll give you my solution:</p> <p>I use the google earth API (Reference: Earth 1.0 Type Library) I start by taking the address information (from cell Tools.Range(rngGeocoderAddress)). I construct KML data for the point and send it to google earth (probably not necessary), I then execute a search on the address information. This will trigger google to start zooming the to resulting location.</p> <p>In a loop, I periodically monitor google earth to see whether it is still in the process of zooming to a new location. Once it has stopped moving, I know that it has zoomed to the search result, and I can capture the Lat Long using GetPointOnTerrainFromScreenCoords(0,0)</p> <p>The end result is I have used google earth to geocode the address.</p> <pre><code>Public Sub LookUpAddress_Click() Dim GEI As ApplicationGE Dim PointOnTerrain As PointOnTerrainGE Dim Search As SearchControllerGE Dim KMLData As String Dim row As Long 'Get the row of the location selected to look up' With ddGeocoderID() If .listCount &lt;= 1 Then Exit Sub row = .ListIndex + 1 End With Set GEI = GEInit() If GEI Is Nothing Then Exit Sub KMLData = "&lt;?xml version=""1.0"" encoding=""UTF-8""?&gt;" &amp; _ "&lt;kml xmlns=""http://www.opengis.net/kml/2.2""&gt;" &amp; _ "&lt;Placemark&gt;" &amp; _ "&lt;name&gt;" &amp; ddGeocoderID().List(ddGeocoderID().ListIndex) &amp; "&lt;/name&gt;" &amp; _ "&lt;visibility&gt;1&lt;/visibility&gt;" &amp; _ "&lt;open&gt;1&lt;/open&gt;" &amp; _ "&lt;description&gt;" &amp; "&lt;![CDATA[" &amp; Tools.Range(rngGeocoderDescription) &amp; "]]&gt;&lt;/description&gt;" &amp; _ "&lt;address&gt;" &amp; Tools.Range(rngGeocoderAddress) &amp; "&lt;/address&gt;" &amp; _ "&lt;/Placemark&gt;" &amp; _ "&lt;/kml&gt;" GEI.LoadKmlData KMLData Set Search = GEI.SearchController() Call Search.Search(Tools.Range(rngGeocoderAddress)) Dim resul As Variant Set resul = Search.GetResults() Dim lat As Double, lon As Double, prevlat As Double, prevlon As Double, checkChange As Double Dim steady As Boolean steady = False: checkChange = -1 lat = 0: lon = 0: prevlat = -1: prevlon = -1 While Not steady Set PointOnTerrain = GEI.GetPointOnTerrainFromScreenCoords(0, 0) lat = PointOnTerrain.Latitude lon = PointOnTerrain.Longitude lblGeoedLat().Caption = sigFigs(lat, 8) lblGeoedLong().Caption = sigFigs(lon, 8) DoEvents If (checkChange = 100) Then If (lat = prevlat And lon = prevlon) Then steady = True prevlat = lat: prevlon = lon checkChange = -1 End If checkChange = checkChange + 1 Sleep 10 Wend End Sub </code></pre> <p>Here's some screen-shots showing how I made it work with a UI:</p> <p><strong>Image 1</strong> Enter an Address <img src="https://i.stack.imgur.com/JncwW.png" alt="enter image description here"></p> <p><strong>Image 2</strong> Click Geocode, code waits for zooming to stop <img src="https://i.stack.imgur.com/gJiEd.png" alt="enter image description here"></p> <p><strong>Image 3</strong> Code records the the final lat/long, user clicks record if they are satisfied. <img src="https://i.stack.imgur.com/FPmky.png" alt="enter image description here"></p> <p>I've tried looping the code to geocode many locations programatically. It works best if you configure google earth's Zoom speed to be as quite fast (but not instantaneous)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload