Ask A Question

Notifications

You’re not receiving notifications from this thread.

Best way to measure distance between current user's location and place location?

Matias Fernandez asked in General

I'm building an app similar to Yelp. The user should have a current location (taken automatically) and a chosen location (defaulted to current location). Each place should also have a location. I would then take the difference between both the chosen location and the place location to get the distance. Then filter results based on distance. I don't really need more functionality than that.

I've researched some tools that might help such as Google Map's JS API and Ruby Geocoder, but I'm curious how you guys would tackle this.

Reply

I would probably use the Geocoder gem for this. You can back it with interchangeable APIs and cache results in Redis which is really handy.

Have you considered using the geosearch that's built into ElasticSearch? You can pass it in either a bounding box (like the coordinates of a Google Map embedded on the page like Yelp does if you drag the map), or you can search within a radius, so you can easily find things by km or miles away.

What's your UI going to look like for the interactions?

Reply

Here's a preview of how the site is going:

http://www.drinklist.io/

I actually have ElasticSearch already so geosearch might be the way to go. Thanks man.

Reply

This looks like a fun project! If you've already got elasticsearch going, it'll do really well to handle the search queries (plus it should handle the ordering from closes to furthest as well). Curious to hear how it goes man!

Reply

Perfect, I'll give it a try. Yeah, the project's been a blast! Couldn't have built it without your help!

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 81,842+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.