473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Google Reverse Geocoding

Hi,
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
Else
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
XMLHTTP.send

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

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<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);
rg.reverseGeocode(point);
}

// handy method to fill in the lat and lng fields by clicking on the map.
function handleClicks(marker, point){
lat.value=point.lat();
lng.value=point.lng();
}
</script>

</head>

<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>
<table>
<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>
</table>
<!-- Google Analytics -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2430635-1";
urchinTracker();
</script>
</body></html>

****************************************
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 10723
Just send the Lat/Lon instead of the address.

ex.
<pre>http://maps.google.com/maps/geo?q=35.109149,-106.604076&output=xml&key=abcdefg</pre>

-Kirk
Jan 10 '09 #2

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

Similar topics

5
by: adrianTNT | last post by:
Hello; Anyone knows how can I create a scrip that returns the google page rank of a given web page? I have seen this on many web pages but I want to host my own script and I dont know how it...
35
by: Raymond Hettinger | last post by:
Here is a discussion draft of a potential PEP. The ideas grew out of the discussion on pep-284. Comments are invited. Dart throwing is optional. Raymond Hettinger ...
14
by: ford_desperado | last post by:
Why isn't ALLOW REVERSE SCANS the default? Why do we have to - drop PK - create an index - recreate PK What are the advantages of indexes that do not allow reverse scans?
15
by: Fady Anwar | last post by:
Hi while browsing the net i noticed that there is sites publishing some software that claim that it can decompile .net applications i didn't bleave it in fact but after trying it i was surprised...
1
by: El Benjamino | last post by:
Hey guys, I'm wanting to learn PHP and have an idea for a new project. I'd like to put up a simple page for my family members / friends to input their address and contact info, and then a script...
0
by: M D | last post by:
I need to use geocoding function in Google Ajax API from PHP. I want to use this one as a tool to conver an adderss to gis location. ( google map api doesn't provide japaanese geocoding ) ...
1
by: xahlee | last post by:
Elisp Tutorial: Make Google Earth Xah Lee, 2006-12 This page shows a example of writing a emacs lisp function that creates a Google Earth file, and creates a link to the file, as well a link...
6
by: Gumbatman | last post by:
Is there a way to use the Google Maps API in C-Sharp? I've found very little when seaching the web. I don't know JavaScript very well and I thought doing it in C-Sharp would be easier. Thank...
2
by: CpVermont | last post by:
Good morning, I didn't see a forum for Google Maps so I figured this would be the best place to post. My question has more to do with geocoding than JS, but I will be using JS to perform the search...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.