Fedora Gore
Posts: 0
Joined: Mon May 12, 2014 7:14 pm

Tutorial wrong?

testing geocoding
"status":"400 Bad Request",
"url":"https://api.appery.io/rest/1/code/6ed...",
"response":"An error occured"

Fedora Gore
Posts: 0
Joined: Mon May 12, 2014 7:14 pm

Tutorial wrong?

As I said before - try to make step by step exactly what you advice to do - its not working.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Tutorial wrong?

We will check again

Fedora Gore
Posts: 0
Joined: Mon May 12, 2014 7:14 pm

Tutorial wrong?

any news? it will work?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Tutorial wrong?

Hello Fedora,

We' ve just built application according to this tutorial and everything is working. Could you please share your script server code with us.

Fedora Gore
Posts: 0
Joined: Mon May 12, 2014 7:14 pm

Tutorial wrong?

requestParams = {},

paramKeys = request.keys();

for (var key = 0; key < paramKeys.length; key++) {

requestParams[paramKeys[key]] = request.get(paramKeys[key]);

}
// Get request parameters
var latitude = request.object().latitude;

var longitude = request.object().longitude;

var radius = request.object().radius;

// Database Id

var dbId = "538cb5a5e4b0889b402e56fb";

// The function that calculates the distance between two points

function getDistance(lat1, lat2, lon1, lon2) {

var R = 3959; // Earth radius in miles

var dLat = (lat2 - lat1)*Math.PI/180;

var dLon = (lon2 - lon1)*Math.PI/180;

var lat1 = lat1*Math.PI/180;

var lat2 = lat2*Math.PI/180;

var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2);

var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));

var d = R * c;

return d;

}

try {

// Check if all the necessary parameters are present and valid

if (latitude && longitude && radius && !isNaN(latitude) && !isNaN(longitude) && !isNaN(radius)) {

var results = [];

var params = {};

// Sort the results by contact name

params.sort = "contactName";

// Get all customers from the database

var customers = Collection.query(dbId, "customers", params);

for (var i = 0; i < customers.length; i++) {

// 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;

// If the customer's coordinates are within the radius,

// add the customer record to the results array

if (getDistance(lat, latitude, lng, longitude) , 400);

}

Fedora Gore
Posts: 0
Joined: Mon May 12, 2014 7:14 pm

Tutorial wrong?

its exactly your tutorail,just little changes , you adviced to do

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Tutorial wrong?

Hello Fedora,

Its just the part of the code, it won't work. You should use the full code as it is shown in the tutorial. And in your code the last string should be:

code&#47;&#47; add the customer record to the results array

if (getDistance(lat, latitude, lng, longitude) <= radius) { /code

Fedora Gore
Posts: 0
Joined: Mon May 12, 2014 7:14 pm

Tutorial wrong?

I made everything exactly like your tutorial advice - its not works.
You can explain me what kind of mistake i did - its helpless, its not me - its your tutorial. I made all needed not 2 and not even 20 times. Including tips you giving me here. Its not working. Rewrite tutorial - ill make it again and ready to bet 1000 against 1 - it will not work. Its all about money for service division. You didnt read my topic message good.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Tutorial wrong?

Fedora,

We are very grateful to you for your feedback. We've just updated and checked the tutorial - it works. Could you please do the following:

  1. Log out from the Appery.io
  2. Clear the cache and cookies
  3. Close the browser
    and after that check this tutorial once more. If you'll get any errors, could you please give us screenshots of the test tab for this service for we could check it.

Return to “Issues”