Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
CLOSE DATABASES
TEXT TO lcXml NOSHOW
<?xml version="1.0"?>
<ResultSet xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL]
xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps
[URL unfurl="true"]http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd">[/URL]
<Result precision="address">
<Latitude>39.566221</Latitude>
<Longitude>-104.85991</Longitude>
<Address>15 INVERNESS WAY E</Address>
<City>ENGLEWOOD</City>
<State>CO</State>
<Zip>80112-5710</Zip>
<Country>US</Country>
</Result>
</ResultSet>
<!-- ws02.search.scd.yahoo.com uncompressed/chunked Mon May 1 08:40:15 PDT 2006 -->
ENDTEXT
LOCAL oXA AS XMLAdapter
oXA = CREATEOBJECT("XmlAdapter")
oXA.LoadXML(lcXml)
oXA.Tables.Item(1).ToCursor(,"crsResult")
BROWSE LAST NOWAIT
cAddress1 = "123 main st anywhere ny"
cAddress2 = "123 oak st anywhere ny"
?distance(google_geo(cAddress1),google_geo(cAddress2))
PROCEDURE google_geo
LPARAMETERS tcAddress
LOCAL CRLF, cUrl, oHTTP, cKey, cResult, cTag, lTag, oIE
STORE CHR(13)+CHR(10) TO CRLF
cKey = MyGoogleKey
SET LIBRARY TO Home()+"Foxtools.fll" ADDITIVE
tcAddress = CHRTRAN(ALLTRIM(reduce(tcAddress)),CHR(32), "+")
cURL = "[URL unfurl="true"]http://maps.google.com/maps/geo?q="[/URL] + tcAddress + "&output=csv&key=" + cKey
oHTTP = CreateObject("MSXML2.XMLHTTP")
oHTTP.Open("GET", cURL, .f.)
oHTTP.Send
cResult=(oHTTP.ResponseText)
nCode=GETWORDNUM(cResult,1,",")
nAccuracy=GETWORDNUM(cResult,2,",")
nLat=GETWORDNUM(cResult,3,",")
nLon=GETWORDNUM(cResult,4,",")
STRTOFILE(cResult,'cut.txt')
RETURN nLon + "," + nLat + "," + nCode + "," + nAccuracy
ENDIF
*!* CODE
*!* G_GEO_SUCCESS (200)
*!* No errors occurred; the address was successfully parsed and its geocode has been returned. (Since 2.55)
*!* G_GEO_SERVER_ERROR (500)
*!* A geocoding request could not be successfully processed, yet the exact reason for the failure is not known. (Since 2.55)
*!* G_GEO_MISSING_ADDRESS (601)
*!* The HTTP q parameter was either missing or had no value. (Since 2.55)
*!* G_GEO_UNKNOWN_ADDRESS (602)
*!* No corresponding geographic location could be found for the specified address. This may be due to the fact that the address is relatively new, or it may be incorrect. (Since 2.55)
*!* G_UNAVAILABLE_ADDRESS (603)
*!* The geocode for the given address cannot be returned due to legal or contractual reasons. (Since 2.55)
*!* G_GEO_BAD_KEY (610)
*!* The given key is either invalid or does not match the domain for which it was given. (Since 2.55)
*!* Accuracy
*!* 0 Unknown location. (Since 2.59)
*!* 1 Country level accuracy. (Since 2.59)
*!* 2 Region (state, province, prefecture, etc.) level accuracy. (Since 2.59)
*!* 3 Sub-region (county, municipality, etc.) level accuracy. (Since 2.59)
*!* 4 Town (city, village) level accuracy. (Since 2.59)
*!* 5 Post code (zip code) level accuracy. (Since 2.59)
*!* 6 Street level accuracy. (Since 2.59)
*!* 7 Intersection level accuracy. (Since 2.59)
*!* 8 Address level accuracy. (Since 2.59)
ENDPROC
PROCEDURE distance
LPARAMETERS tcGeo1, tcGeo2
lnLon1 = VAL(GETWORDNUM(tcGeo1,1,","))
lnLat1 = VAL(GETWORDNUM(tcGeo1,2,","))
lnLon2 = VAL(GETWORDNUM(tcGeo2,1,","))
lnLat2 = VAL(GETWORDNUM(tcGeo2,2,","))
lnDistance = 3963.000000*ACOS(COS(DTOR(90-lnLat1))*COS(DTOR(90-lnLat2))+;
SIN(DTOR(90-lnLat1))*SIN(DTOR(90-lnLat2))*COS(DTOR(lnLon1 - lnLon2)))
IF lnDistance < .25
lcDistance = TRANSFORM(ROUND(lnDistance*5280,2)) +" feet"
ELSE
lcDistance = TRANSFORM(ROUND(lnDistance,2)) + " miles"
ENDIF
RETURN lcDistance
ENDPROC