Page 2 of 5

Google places Rankby Distance

Posted: Thu Dec 04, 2014 2:53 am
by Cristian Hidalgo

get an error message when testing the query...


Google places Rankby Distance

Posted: Thu Dec 04, 2014 4:35 am
by Yurii Orishchuk

Christian,

I gave you a JS code.

So this code should be used for "JS" field in the "where" request parameter in the service mapping.

Please take a look about queries here: http://devcenter.appery.io/documentat...

Regards.


Google places Rankby Distance

Posted: Thu Dec 04, 2014 4:39 am
by Cristian Hidalgo

var currentlat = localStorage.getItem("current_lat");
var currentlong = localStorage.getItem("current_long");
var slider_value = localStorage.getItem("slider_value");

return{
"location" : {
"$nearSphere" : [currentlat, currentlon],
"$maxDistanceInKilometers" : slider_value
}
} ;


Google places Rankby Distance

Posted: Thu Dec 04, 2014 4:39 am
by Cristian Hidalgo

var currentlat = localStorage.getItem("current_lat");
var currentlong = localStorage.getItem("current_long");
var slider_value = localStorage.getItem("slider_value");

return{
"location" : {
"$nearSphere" : [currentlat, currentlon],
"$maxDistanceInKilometers" : slider_value
}
} ;


Google places Rankby Distance

Posted: Thu Dec 04, 2014 4:41 am
by Cristian Hidalgo

Image

Like this?


Google places Rankby Distance

Posted: Thu Dec 04, 2014 4:42 am
by Cristian Hidalgo

Google places Rankby Distance

Posted: Thu Dec 04, 2014 4:42 am
by Cristian Hidalgo

in the js of the where on the before send mapping...


Google places Rankby Distance

Posted: Thu Dec 04, 2014 4:50 am
by Cristian Hidalgo

apparently nearsphere uses long,lat and not like stated above


Google places Rankby Distance

Posted: Thu Dec 04, 2014 5:30 am
by Yurii Orishchuk

Cristian,

Basically you implementation correct. But needed some changes:

  1. Delete links to "where" parameter: http://prntscr.com/5d1e28/direct

  2. Modify your JS code with following:

    precode

    var currentlat = localStorage.getItem("current_lat");
    var currentlong = localStorage.getItem("current_long");
    var slider_value = localStorage.getItem("slider_value");

    var whereObject = {
    "location" : {
    "$nearSphere" : [currentlat, currentlong],
    "$maxDistanceInKilometers" : slider_value
    }
    }

    console.log("Where object is:");
    console.log(whereObject):

    return JSON.stringify(whereObject);

    /code/pre

    That's all.

    Regards.


Google places Rankby Distance

Posted: Thu Dec 04, 2014 5:43 am
by Cristian Hidalgo

Image
gives me this error message...