sowmen choudhury
Posts: 0
Joined: Sat Feb 01, 2014 3:32 pm

How to get query with geo and distance working

I am trying to get a query working with geocode and radius but its not working the way I want it to...

I tried using the following code with no success.

var map = Appery('googlemap_52');
var GLat = map.gmap.getCenter().lat();
var GLon = map.gmap.getCenter().lng();
var geo = [GLat, GLon];

return '{"StartGeo" : {"$nearSphere" : "'+JSON.stringify(geo)+'","$maxDistanceInKilometers" : "'+JSON.stringify(value)+'"} }';

Value is just a numeric distance from local storage..

Any help would be appreciated...

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

How to get query with geo and distance working

Hello!
Please check in console or show in alert what you return in where. Check if it's correct request.

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

How to get query with geo and distance working

Hi Maryna,
I use the following, and it works perfectly for me. My only issue is that it appears to require miles in whole numbers like 5 - and not 5.5 as I need. If this is in fact a limitation, do you know of any workarounds?

http://screencast.com/t/0o6XQBDC7dY1

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to get query with geo and distance working

Hi Robert.

Please provide us with information about your request.

Make screen shot from "net" tab of debuger. Where we can see URL, all request parameters and headers.

Also please make screenshot with response.

Thanks & regards.

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

How to get query with geo and distance working

Hello Robert,

How do you define your query service? Does it work in test mode with value like 5.5?
http://docs.appery.io/documentation/r...

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

How to get query with geo and distance working

Evgene, thank you. Upon further investigation, I believe there is no problem in using decimals. What was happening in my case is that the database records reflected geographical areas that were larger in radius than the miles I was using- so that a too-small radius was not capturing any records. In any case, I believe the problem was in my not knowing about my database and not in using decimals. I'm sorry for wasting your time, but really appreciate your help.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to get query with geo and distance working

Hi Robert,

Thank you for the update. Let us know if you need any further help.

Return to “Issues”