Rocky Smolin
rockysmolin at bchacc.com
Mon Jan 7 21:12:30 CST 2013
Way cool. Thank you. I might just surprise my client! :)
Rocky
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan
Sent: Monday, January 07, 2013 6:39 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Distance Between Two Points
Here ya go - quick and dirty, but it works for me:
Type geoloc
lat As Double
lon As Double
End Type
Function GetGeoCode(strAddress As String) As geoloc
Dim oHTTP As Object
Dim lngresult As Long
Dim strPage As String
Dim strParam As String
Dim lngPtr As Long
Dim strFixedAddress As String
Dim gl As geoloc
strFixedAddress = Replace(strAddress, vbCrLf, "")
strFixedAddress = Replace(strFixedAddress, " ", "+")
strParam = "http://maps.googleapis.com/maps/api/geocode/json?address=" &
_
strFixedAddress & "&sensor=false"
Set oHTTP = CreateObject("Msxml2.XMLHTTP")
lngresult = oHTTP.Open("GET", strParam, False)
lngresult = oHTTP.Send("")
strPage = oHTTP.Responsetext
Set oHTTP = Nothing
lngPtr = InStr(strPage, """location"" : {") + 20
strPage = Mid$(strPage, lngPtr)
lngPtr = InStr(strPage, "},")
strPage = Left$(strPage, lngPtr)
strPage = Replace(strPage, " ", "")
gl.lat = Val(Mid$(strPage, 7))
strPage = Mid$(strPage, InStr(strPage, """lng"":"))
gl.lon = Val(Mid$(strPage, 7))
GetGeoCode = gl
End Function
Function TestGeocode()
Dim strA As String
Dim gl As geoloc
strA = "1600 Amphitheatre Parkway, Mountain View, CA"
gl = GetGeoCode(strA)
MsgBox strA & " is as Lat: " & gl.lat & " and Lon: " & gl.lon End Function
On 8 Jan 2013 at 12:05, Stuart McLachlan wrote:
> I've got a few similar things floating around for currency exchange
> etc. Give ma half an hour or so :-)
>
> --
> Stuart
>
>
> On 7 Jan 2013 at 17:47, Rocky Smolin wrote:
>
> > Thanks Stuart. Do you know of a site where I can see a snip of VBA
> > code using it?
> >
> >
> > Rocky
> >
> >
> > -----Original Message-----
> > From: accessd-bounces at databaseadvisors.com
> > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart
> > McLachlan
> > Sent: Monday, January 07, 2013 5:34 PM
> > To: Access Developers discussion and problem solving
> > Subject: Re: [AccessD] Distance Between Two Points
> >
> > It's can be as simple as parsing the return from an http request
> > such as
> >
> > http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphit
> > heatre+P
> > arkway,
> > +Mountain+View,+CA&sensor=false
> >
> > See
> > https://developers.google.com/maps/documentation/geocoding/index
> >
> > One caveat:
> >
> > Note: the Geocoding API may only be used in conjunction with a
> > Google map; geocoding results without displaying them on a map is
prohibited.
> >
> >
> > Alternatives:
> >
> > https://webgis.usc.edu/Services/Default.aspx
> >
> >
> >
> > On 7 Jan 2013 at 17:01, Doug Murphy wrote:
> >
> > > I think others on the list have discussed ways of doing this. It
> > > can be
> > done
> > > from the Google Maps api. You need a Google developer ID or
> > > something like that to use it. It has been a while since I played with
it.
> > >
> > > Doug
> > >
> > > -----Original Message-----
> > > From: accessd-bounces at databaseadvisors.com
> > > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky
> > > Smolin
> > > Sent: Monday, January 07, 2013 3:56 PM
> > > To: 'Access Developers discussion and problem solving'
> > > Subject: [AccessD] Distance Between Two Points
> > >
> > > Dear List:
> > >
> > > I have a client who wants to add to his app the distance from his
> > > office
> > to
> > > various properties they appraise. I see some code snips on the
> > > web to calculate this (as the crow flies) but is there a way to
> > > translate a complete address into latitude and longitude coordinates?
> > >
> > > MTIA
> > >
> > > Rocky Smolin
> > > Beach Access Software
> > > 858-259-4334
> > > www.bchacc.com <http://www.bchacc.com/> www.e-z-mrp.com
> > > <http://www.e-z-mrp.com/>
> > > Skype: rocky.smolin
> > >
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > http://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > http://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> >
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com