Use geoLocation Lat/Lon to query database
As a user of my web site drives around, her latitude/longitude changes. I would like for her to be able to click a button and have her current coordinates (which are captured through JS in a geoLocation script) passed to the query below through a form as #userLat# and #userLon#. The resultset would be displayed in a new cfml template.
If I have to use the JS variables within one of the JS scopes, can I create the form using javascript and pass the variables to the query that way?
Perhaps the question is as simple as, can a javascript variable be made available for use in a cfml template? And, if so, how?
Sounds simple to some, I'm sure, but I've had only cursory dealings with javascript and none with Ajax. I'm hoping for a conceptual overview that can lead me to focused self-education. Your advice is welcome.
~John
========================
SELECT MID, AptName, round(calc_dist,2) AS Distance
FROM (
SELECT MID, AptName, sqrt(power((#userLat# - lat),2)
+ power((#userLon# - lon),2)) * 62 as calc_dist
FROM test_maps
) AS calculated
ORDER BY calc_dist
LIMIT 3
This yields:
| MID | AptName | Distance |
| 116 | Depot 16 | 0.10 |
| 10 | Briq on 4th Street | 0.17 |
| 3 | Town Square Apartments | 0.46 |
