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.do cumentElement
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.Va lue) And IsNull(Text4.Va lue) Then
MsgBox "Please Provide State or Zip"
Exit Sub
Else
strURL = "http://maps.google.com/maps/geo?q=" & sendstring & "&output=xml&ke y=
'MsgBox strURL
'lat123.Value = strURL
Set objIE = Me.WebBrowser9. Object
objIE.Navigate strURL
Set XMLHTTP = CreateObject("M sxml2.XMLHTTP")
XMLHTTP.Open "GET", strURL, False
XMLHTTP.send
MyLat = XMLHTTP.respons eXML.childNodes .length
xml_document.lo ad XMLHTTP.respons eXML
Set rootNode = xml_document.do cumentElement
Text30.Value = Left(rootNode.s electSingleNode ("//coordinates").T ext, InStr(rootNode. selectSingleNod e("//coordinates").T ext, ",") - 1)
Text28.Value = Mid(rootNode.se lectSingleNode( "//coordinates").T ext, InStr(rootNode. selectSingleNod e("//coordinates").T ext, ",") + 1, InStr(rootNode. selectSingleNod e("//coordinates").T ext, ",") - 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@g mail.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>GReverse Geocoder v1.0.4 Example</title>
<script src="http://maps.google.com/maps?file=api&a mp;v=2&key= ABQIAAAA9K1YkDo Sv7ab5ZNpy7jKoR SNkqYZ2vhDE-J87_S4BEuTB46WE hTQ4bSutMETYeFC AGxideDhBPvI_w" type="text/javascript"></script>
<script src="http://nicogoeminne.go oglepages.com/greversegeocode rv104.js" type="text/javascript"></script>
<script type="text/javascript">
// GMap2 object
var map;
// GReverseGeocode r object
var rg;
// text input fields
var lat;
var lng;
// result div
var info;
function load() {
if (GBrowserIsComp atible()) {
lat = document.getEle mentById("lat") ;
lng = document.getEle mentById("lng") ;
info = document.getEle mentById("info" );
map = new GMap2(document. getElementById( "map"));
map.setCenter(n ew GLatLng(51.0522 6693177032, 3.7238931655883 79), 15);
map.addControl( new GLargeMapContro l());
rg = new GReverseGeocode r(map);
// add listners for the results
GEvent.addListe ner(rg, "load", goodresult);
GEvent.addListe ner(rg, "error", badresult);
// Clicking on the map fills in the lat and lng fields
// Just handy
GEvent.addListe ner(map, "click", handleClicks);
}
}
// is called with a placemark if the reverse geocode request was successfull
// sets the result div
function goodresult(plac emark) {
var html = placemark.addre ss + '<br />' + '<b>Country code:</b> ' + placemark.Addre ssDetails.Count ry.CountryNameC ode;
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.val ue,lng.value);
rg.reverseGeoco de(point);
}
// handy method to fill in the lat and lng fields by clicking on the map.
function handleClicks(ma rker, point){
lat.value=point .lat();
lng.value=point .lng();
}
</script>
</head>
<body onload="load()" onunload="GUnlo ad()">
<p>Reverse Geocoding Example using the GReverseGeocder v1.0.4<br />
Copyright 2007, Nico Goeminne<br />
nicogoeminne at gmail.com</p>
<table>
<tr><td>Latitud e (WGS84)</td><td><input id="lat" type="text" size="20" value="" /></td></tr>
<tr><td>Longitu de (WGS84)</td><td><input id="lng" type="text" size="20" value="" /></td></tr>
<tr><td><inpu t type="button" onclick="revers e()" value="Get Address"></td><td><div id="info"></div></td></tr>
<tr><td colspan="2"><di v 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.
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.do cumentElement
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.Va lue) And IsNull(Text4.Va lue) Then
MsgBox "Please Provide State or Zip"
Exit Sub
Else
strURL = "http://maps.google.com/maps/geo?q=" & sendstring & "&output=xml&ke y=
'MsgBox strURL
'lat123.Value = strURL
Set objIE = Me.WebBrowser9. Object
objIE.Navigate strURL
Set XMLHTTP = CreateObject("M sxml2.XMLHTTP")
XMLHTTP.Open "GET", strURL, False
XMLHTTP.send
MyLat = XMLHTTP.respons eXML.childNodes .length
xml_document.lo ad XMLHTTP.respons eXML
Set rootNode = xml_document.do cumentElement
Text30.Value = Left(rootNode.s electSingleNode ("//coordinates").T ext, InStr(rootNode. selectSingleNod e("//coordinates").T ext, ",") - 1)
Text28.Value = Mid(rootNode.se lectSingleNode( "//coordinates").T ext, InStr(rootNode. selectSingleNod e("//coordinates").T ext, ",") + 1, InStr(rootNode. selectSingleNod e("//coordinates").T ext, ",") - 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@g mail.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>GReverse Geocoder v1.0.4 Example</title>
<script src="http://maps.google.com/maps?file=api&a mp;v=2&key= ABQIAAAA9K1YkDo Sv7ab5ZNpy7jKoR SNkqYZ2vhDE-J87_S4BEuTB46WE hTQ4bSutMETYeFC AGxideDhBPvI_w" type="text/javascript"></script>
<script src="http://nicogoeminne.go oglepages.com/greversegeocode rv104.js" type="text/javascript"></script>
<script type="text/javascript">
// GMap2 object
var map;
// GReverseGeocode r object
var rg;
// text input fields
var lat;
var lng;
// result div
var info;
function load() {
if (GBrowserIsComp atible()) {
lat = document.getEle mentById("lat") ;
lng = document.getEle mentById("lng") ;
info = document.getEle mentById("info" );
map = new GMap2(document. getElementById( "map"));
map.setCenter(n ew GLatLng(51.0522 6693177032, 3.7238931655883 79), 15);
map.addControl( new GLargeMapContro l());
rg = new GReverseGeocode r(map);
// add listners for the results
GEvent.addListe ner(rg, "load", goodresult);
GEvent.addListe ner(rg, "error", badresult);
// Clicking on the map fills in the lat and lng fields
// Just handy
GEvent.addListe ner(map, "click", handleClicks);
}
}
// is called with a placemark if the reverse geocode request was successfull
// sets the result div
function goodresult(plac emark) {
var html = placemark.addre ss + '<br />' + '<b>Country code:</b> ' + placemark.Addre ssDetails.Count ry.CountryNameC ode;
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.val ue,lng.value);
rg.reverseGeoco de(point);
}
// handy method to fill in the lat and lng fields by clicking on the map.
function handleClicks(ma rker, point){
lat.value=point .lat();
lng.value=point .lng();
}
</script>
</head>
<body onload="load()" onunload="GUnlo ad()">
<p>Reverse Geocoding Example using the GReverseGeocder v1.0.4<br />
Copyright 2007, Nico Goeminne<br />
nicogoeminne at gmail.com</p>
<table>
<tr><td>Latitud e (WGS84)</td><td><input id="lat" type="text" size="20" value="" /></td></tr>
<tr><td>Longitu de (WGS84)</td><td><input id="lng" type="text" size="20" value="" /></td></tr>
<tr><td><inpu t type="button" onclick="revers e()" value="Get Address"></td><td><div id="info"></div></td></tr>
<tr><td colspan="2"><di v 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.
Comment