470,855 Members | 2,898 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

Google Reverse Geocoding

I was creating an Application in MS Access for Geocoding a particular Address from Google to get the Lat & Long.
I successfully able to did that.
Here is the code:
On Error Resume Next 'if address not found, just move along

Dim xml_document As DOMDocument
Set xml_document = New DOMDocument
Dim rootNode As IXMLDOMNode
Set rootNode = xml_document.documentElement

Dim strURL1 As String
Dim objIE As Object
Dim IE As Object
Dim strSavePath As String
Dim URL As String, ext As String
Dim buf, ret As Long
Address = Text0.Value
city = Text2.Value
State = Text4.Value
Address = Replace(Address, " ", "+", 1)
zip = Text6.Value
sendstring = Address & ",+" & city & ",+" & State & ",+" & zip
If IsNull(Text6.Value) And IsNull(Text4.Value) Then
MsgBox "Please Provide State or Zip"
Exit Sub
strURL = "http://maps.google.com/maps/geo?q=" & sendstring & "&output=xml&key=
'MsgBox strURL
'lat123.Value = strURL
Set objIE = Me.WebBrowser9.Object
objIE.Navigate strURL

Set XMLHTTP = CreateObject("Msxml2.XMLHTTP")

XMLHTTP.Open "GET", strURL, False

MyLat = XMLHTTP.responseXML.childNodes.length

xml_document.load XMLHTTP.responseXML

Set rootNode = xml_document.documentElement

Text30.Value = Left(rootNode.selectSingleNode("//coordinates").Text, InStr(rootNode.selectSingleNode("//coordinates").Text, ",") - 1)
Text28.Value = Mid(rootNode.selectSingleNode("//coordinates").Text, InStr(rootNode.selectSingleNode("//coordinates").Text, ",") + 1, InStr(rootNode.selectSingleNode("//coordinates").Text, ",") - 2)
End If
Now what I want to do it, Is to do the reverse Geocoding. Like If I put the lat & Long in the Textbox in Ms Access Form, I should be able to get the Address for that lat or long. Or If I click anywhere on map. It should give me the lat & long in the textbox of that point.

I know the javascript function of that.
I got it from Google Reverse geocoding Reference guide.
Here is the code.

<html xmlns="http://www.w3.org/1999/xhtml">
Copyright 2007 Nico Goeminne (nicogoeminne@gmail.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
<title>GReverseGeocoder v1.0.4 Example</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA9K1YkDoSv7ab 5ZNpy7jKoRSNkqYZ2vhDE-J87_S4BEuTB46WEhTQ4bSutMETYeFCAGxideDhBPvI_w" type="text/javascript"></script>
<script src="http://nicogoeminne.googlepages.com/greversegeocoderv104.js" type="text/javascript"></script>
<script type="text/javascript">

// GMap2 object
var map;
// GReverseGeocoder object
var rg;
// text input fields
var lat;
var lng;
// result div
var info;

function load() {
if (GBrowserIsCompatible()) {
lat = document.getElementById("lat");
lng = document.getElementById("lng");
info = document.getElementById("info");

map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(51.05226693177032, 3.723893165588379), 15);
map.addControl(new GLargeMapControl());
rg = new GReverseGeocoder(map);

// add listners for the results
GEvent.addListener(rg, "load", goodresult);
GEvent.addListener(rg, "error", badresult);
// Clicking on the map fills in the lat and lng fields
// Just handy
GEvent.addListener(map, "click", handleClicks);

// is called with a placemark if the reverse geocode request was successfull
// sets the result div
function goodresult(placemark) {
var html = placemark.address + '<br />' + '<b>Country code:</b> ' + placemark.AddressDetails.Country.CountryNameCode;
info.innerHTML = html;

// is called if the reverse geocode request was unsuccessfull
function badresult() {
info.innerHTML = "Unable to reverse geocode";

// get the input form lat and lng fields and issue a reverse geocode
// request
function reverse(){
var point = new GLatLng(lat.value,lng.value);

// handy method to fill in the lat and lng fields by clicking on the map.
function handleClicks(marker, point){


<body onload="load()" onunload="GUnload()">
<p>Reverse Geocoding Example using the GReverseGeocder v1.0.4<br />
Copyright 2007, Nico Goeminne<br />
nicogoeminne at gmail.com</p>
<tr><td>Latitude (WGS84)</td><td><input id="lat" type="text" size="20" value="" /></td></tr>
<tr><td>Longitude (WGS84)</td><td><input id="lng" type="text" size="20" value="" /></td></tr>
<tr><td><input type="button" onclick="reverse()" value="Get Address"></td><td><div id="info"></div></td></tr>
<tr><td colspan="2"><div id="map" style="width: 400px; height: 400px;"></div></td></tr>
<!-- Google Analytics -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
<script type="text/javascript">
_uacct = "UA-2430635-1";

Now I want to translate this in Access VBA.
I wonder How to do that.
OR If anyone else has done the same thing in the past in VBA.
Or If u know a reverse geocoding app in MS Access.
I want to do that specially in Access.
Thank you for your Help.
Mar 21 '08 #1
1 10368
Just send the Lat/Lon instead of the address.


Jan 10 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by adrianTNT | last post: by
35 posts views Thread by Raymond Hettinger | last post: by
14 posts views Thread by ford_desperado | last post: by
1 post views Thread by El Benjamino | last post: by
reply views Thread by M D | last post: by
1 post views Thread by xahlee | last post: by
6 posts views Thread by Gumbatman | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.