Hi, I am attempting to modify the server code found in the geocoding tutorial:
https://devcenter.appery.io/tutorials...
The only difference is that longitude and lattitude values of all 'customers' are stored on a database.
Having explored other solutions to similar problems, I wish to avoid:
Mapping 'Where' queries with JavaScript (using $nearSphere)
Database services (in preference of server code services)
Main question:
From the geocoding tutorial, would it be possible to remove the server code lines 55 to 77 and replace it with code that queries a database for known values of lat and lng?
// server code lines 55 to 77 from tutorial shown below:
// Geocode customer's address with Google API
var XHRResponse = XHR.send("GET", "https://maps.googleapis.com/maps/api/...", {
"parameters": {
"address": customers.address,
"sensor": "false"
}
});
console.log(XHRResponse);
if (XHRResponse.status == 200) {
// Get coordinates from the response
var lat = JSON.parse(XHRResponse.body).results[0].geometry.location.lat;
var lng = JSON.parse(XHRResponse.body).results[0].geometry.location.lng;
I am not sure of the right approach but was thinking something along the lines of:
var lat = Collection.query(dbId, "customers");
var long = Collection.query(dbId, "customers");
However, the Response is not populated with the information I expect to receive, i.e:
Status:200
{"results":[]}
Something is incorrect with the code above. However, the results are properly populated when abitary values are set for the customer location, i.e:
var latitude = '50';
var longitude = '0';
Any assistance you can provide would be much appreciated.