Ian Usher7109531
Posts: 0
Joined: Tue Sep 16, 2014 6:57 pm

Gecoding - Find nearest 3 based on lat long held in database.

Hello,

I have used the geocoding app as an example to see if i could do what i wanted, and have so far been successful. (http://devcenter.appery.io/tutorials/...)

However i now want to take this one step further and need a little assistance with this. Am i after mainly two things, these are:

1) Using lat long contained within the database rather than the Google Geocoding API. I have tried to comment out the 'Google Geocoding' API server code to say use true coodinates held within the database but i cant see how this could be acheived. Could somebody please shed some light on this?

2) I want the database to bring back the nearest 2/3 items rather than all those contained within 1000 metres for example. How would the code need to change to represent this.

If you could please help with this that would be greatly appreciated. If you need anything else then please do not hesitate to contact me.

Ian

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

Gecoding - Find nearest 3 based on lat long held in database.

Hi Ian,

You just need to use geoSpatial query to Appery.io DB. See details here: http://devcenter.appery.io/documentat...

Also you can add "limit" parameter and set it with value "3" to limit all results to 3 nearest items.

Regards.

Ian Usher7109531
Posts: 0
Joined: Tue Sep 16, 2014 6:57 pm

Gecoding - Find nearest 3 based on lat long held in database.

Hi Yurii,

Thank you for your reply, i now know how to get this working. My next question on from this is how do i get the coordinate to return the nearest two items from the device and into phone? For example i want to use the "Get Coordinate" example and add the above query you have helped me with, so that it returns the nearest two items from a database using the coordinates from the phone? I hope that makes sense.

Ian

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

Gecoding - Find nearest 3 based on lat long held in database.

Hi Ian,

Yes it makes sense.

But i can not understand where is problem with implementation.

Brief plan is:

  1. Get current geo position with geolocation service.

  2. Pass this geoposition to list/query service with geospatial.

    That's all.

    Regards.

Ian Usher7109531
Posts: 0
Joined: Tue Sep 16, 2014 6:57 pm

Gecoding - Find nearest 3 based on lat long held in database.

Thanks Yurii,

Thanks for getting back to me. I think the problem is that im not a programmer. So i can see what i am suppose to do (and can do that when following examples), but if i wanted to do this on "my own" i wouldn't know where to start.

Is it as easy as just changing the code within the 'geocoding' app to just say fetch the nearest 3 based on these coordinates and how would you implement this within the code?

Thanks again.

Ian

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

Gecoding - Find nearest 3 based on lat long held in database.

Hi Ian,

Okay, you can learn how to do it in following tutorials:

  1. How to use geolocation: http://devcenter.appery.io/tutorials/...

  2. How to use list service with "where" parameter: http://devcenter.appery.io/tutorials/...

    Regards.

Ian Usher7109531
Posts: 0
Joined: Tue Sep 16, 2014 6:57 pm

Gecoding - Find nearest 3 based on lat long held in database.

Hi Yurii,

Im still struggling to see how i can do this unfortunatley, even after going through both tutorials that you mentioned above. I can see how they work and understand how it should work.
What im failing to understand is how to grab the coordinates from the gelocation service, but then use these same coordinates for the search service i have set up to query the database and return the nearest two.

I have written the request service as follows for the query of the database and when i enter a location i get a response back. Image

What im struggling with is how you tell the application to choose the coorindates from the geocoding service and return a value. For example im taking the coordinates out and replacing it with standard lat/long field names (obviously its not pulling anything back), but this is where my knowledge is a little vague. Image

Any further advice or guidance you could provide would be massively appreciated. Thanks greatly.

Ian

Ian Usher7109531
Posts: 0
Joined: Tue Sep 16, 2014 6:57 pm

Gecoding - Find nearest 3 based on lat long held in database.

Im also just going to add that what im trying to do is very similar to this problem that you answered recently....only difference for me is that im only after the lat long rather than letting the user specify a distance:

https://getsatisfaction.com/apperyio/...

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

Gecoding - Find nearest 3 based on lat long held in database.

Hi Ian,

To get coordinates of the device you should use geolocation service.

  1. Add two inputs on the page.(lat and long).

  2. Add geolocation service on the page.

  3. Edit service "Success" mapping. To link response to input components(step 1). http://prntscr.com/5xkyij/direct

  4. Invoke service on the button "click" event handler.

  5. Add error event handler with alert to see if something goes wrong.

    Now you can test your app.

    Regards.

Ian Usher7109531
Posts: 0
Joined: Tue Sep 16, 2014 6:57 pm

Gecoding - Find nearest 3 based on lat long held in database.

Thanks Yurii,

I understand this bit completley. Having returned the lat long succesfully how do you then send that lat long so that it can be used in the list query? From what ive seen you need to create the lat long as a local storage, and then use some java script to specify where the lat long should be used in the query In order to return the nearest two items in the database....how do you do this please?

Return to “Issues”